I'm trying to use socket to exchange data between two computers in Python. Right now, I'm able to connect the computer together but I have to manually go in the code and specify the IP address of the other computer. However the code needs to be fully autonomous on boot. How should I do that? Is there a way in python to achieve this? Thanks.
Related
My question is how to connect two BBB (Beagle Bone Black) into one PC using USB and communication with them at the same time.
I am trying to write a python script that two BBB boards to communicate with each other. The idea is that these boards should communicate with each other using iperf and an external cape (OpenVLC).
The problem is that I need to use the iperf on the server-side and then read the data on the client-side.
For this purpose, I need to connect them to one PC to be able to read commands and write the results.
##USB_NETWORK_DISABLED=yes
###To Run Multple Boards on one USB HOST, change the 3rd octal on every
###USBx_SUBNET define and USBx_ADDRESS
###BeagleBone Number 2: USB0: 192.168.11.2 USB1: 192.168.10.2
###BeagleBone Number 3: USB0: 192.168.13.2 USB1: 192.168.12.2
###And So On..
This is from bb-boot on the images from rcn-ee.net/com.
That's going to be a struggle. Both BBB grab the same IPs (192.168.6.2 and/or 192.168.7.2 depending on your PC's operating system) on their virtual Ethernet adapters and assign the same address to the PC side (192.168.6.1 and/or 192.168.7.1). You can change that in the startup scripts (google for details). Then you'd need to set your PC up to route traffic between the two which depends on your operating system. If you haven't done networking before, it's going to be hard.
Instead of USB, I'd strongly recommend connecting all devices to a simple router box using Ethernet. It just works.
This is somewhat of a repost from Is there a way to find out the BSSID a computer is connected to in a local network? but there was no answer there so I will try to quantify more specifically what I am trying to do here.
I'm working on a project for my job where we have a very large network. The goal is to be able to guesstimate on a map where a given machine is on the campus by finding out what AP the device is connected to. I have worked in the past on something similar (much smaller scale) with Scapy and Python, so I know it's possible. Unfortunately, and fortunately, ICMP responses are disabled, rendering tracert's that point only to the building's main switch, followed by an immediate hop to the device (missing hops).
Doing testing with netsh, I can find the BSSID that any given computer on the domain is connected to when I am physically using the machine. In essence, the goal then here is to find a way to get the machine to report to me what the BSSID is of its own network connection, which would allow me to reference our network map and work on that.
I am using Python for the bulk of this program, as I've worked with Scapy before on similar tasks. I have code all prepared for resolving IP from hostname, mac from IP, etc etc. However, these functions are all working so until I resolve this there is no point in including that code in this post. I'm open to any alternative ideas, though I have tried scanning ports and running TCP traceroutes to no avail. Note: this is a Windows environment so Linux is out of the question, sadly. Show me what you've got!
I am working on a GUI program to command power supplies by Ethernet.
I have the DHCP of my computer activated, therefore I guess that the IP adresses of my power supplies are fixed by my computer.
I would like to know the IP addresses of my power supplies, in order to communicate with them through the TCP/IP protocol, using Python.
For the moment, I use a program called LXI discovery tools, and while I run it, the Window command arp -a command gives me the IP adresses of my power supplies.
The problem is that I need to run this LXI program. Is it obligatory?
Owing to the DCHP, my computer is the one which sets the IP addresses, therefore isn't there a way to get those addresses more easily?
Moreover, is the Python socket library able to help me?
Finally I solved my problem, using statique IP addresses. Therefore I know them and I don't need anymore to "scan" my network.
I need advice on some problem I've been having.
The situation is like this. I have two devices in Local Network that are not directly connected with each other. Basically they don't know of each other existence. The problem is that I want one device to send message to the other device.
So the plan i have is this.
Make script that scans every ip address in local network and save output in txt file. Then send message to every ip address that is present in that file. On the other device make script that listens for upcoming messages(problem there is that i don't know where to listen, to whitch ip address to listen). Then that python script would send that to websocket so that js app can easily pick every message that has been sent.
This is my first app that includes some networking problems and message queues, so if any of you have some advice for me, or would do something different i would be very greatful if you can answer :)
Thank you.
In order to find communication peers on the network you might want to have a look at udp broadcasts.
Basically what I'm trying to achieve is a program which allow users to connect to a each other over a network in, essentially, a chat room. What I'm currently struggling with is writing the code so that the users can connect to each other without knowing the IP-address of the computer that the other users are using or knowing the IP-address of a server.
Does anyone know of a way in which I could simply have all of the users scan the IP range of my network in order to find any active 'room' and then give the user a chance to connect to it?
Also, the hope is that there will be no need for a central server to run this from, rather every user will simply be connected to all other user, essentially being the server and client at the same time.
I can give you two suggestions. First of all, UDP packets to the broadcast address of your network will be received by everybody. Secondly, there is a protocol for programs offering certain services to find each other on a local network. That protocol is called mDNS, ZeroConf, or Bonjour.
Using broadcast UDP is likely going to be the faster route. But if I were you, I'd learn how to use ZeroConf instead. It's supported well under IPv6 and already used by several interesting programs such as SubEthaEdit and Gobby.
Here is a link to a nice tutorial for implementing something that speaks ZeroConf in Python.
Another recommendation... If you want to hand roll your own broadcast/multicast UDP code and you can be sure that all of the systems you're on are running a Linux that's newer than 2003 or so, and all the Windows systems are XP or better, you can probably get away with using IPv6. The IPv6 link-local (think same LAN) all hosts multicast address is ff02::1. That's really simple and easy, and it will reach all the other systems on the same LAN. It's much better than having to figure out what your network's broadcast address is with IPv4.