Mininet socket programming in python
I have emulated a network topology using mininet. The topology contains two nodes connected by multiple switches. On host 1, we run a client application that creates a socket and tries to connect to the server application on host 2 , however it doesn't work. If I run my client and server script locally on one of the two hosts, it connects without issue.
server.py:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind(('127.0.0.1', 10021))
s.listen(5)
while 1:
(clientsocket, address) = s.accept()
#DO STH.
clientsocket.close()
client.py:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((args['ip'], 10021))
while 1:
#DO STH.
s.close()
Here's the code used to execute commands to start the server and client application
topology.py:
server = net.getNodeByName('host2')
client = net.getNodeByName('host1')
server.cmd('./server.py & > serveroutput')
client.cmd('./client.py -i %serverIP > clientfile' % server.getIP())
source to share
Are you using OVS openflow switches in your topology?
If they are open access enabled, you need to have an SDN controller like Ryu or POX. The controller will create a path between the two hosts.
The correct host 1 is trying to connect to host 2. Sends some TCP messages to the switch, but the switch does not know what to do, so it needs to contact the SDN controller for help. But there is no controller. Therefore, the connection fails.
If they weren't public keys, it would find its way to host 2.
So check if the switch is using openflow.
source to share