sonata-nfv / son-emu

Attention! Legacy! This repo will be replaced with https://github.com/containernet/vim-emu
https://github.com/containernet/vim-emu
Apache License 2.0
36 stars 32 forks source link

Using Client Server #251

Closed PedroPCardoso closed 6 years ago

PedroPCardoso commented 7 years ago

Hello, I'm trying to add a docker server and a client, the problem is that I need to know the ip of the server. I am trying to get the ip address of the server, but I can not find the ip address of the server. do ?

mpeuster commented 7 years ago

Hi, assuming you server container is called d1 and you client is called d2, you can do:

containernet> d1 ifconfig

to see the IPs of the server.

However, can you link/paste the commands you are using to start the containers? The used topology etc.?

And, also important, the used containers need to follow these requirements in order to work with son-emu. This especially means that your server software in the container needs to be started in a "non-blocking" way so that son-emu can interact with the container's shell to configure its networking, e.g., execute ip, ifconfig, etc. in the container.

PedroPCardoso commented 7 years ago

in case, I have a docker image, do I need to use EXPOSE 2004 in the image?

My server.py file `` TCP_IP = '0.0.0.0' TCP_PORT = 2004 BUFFER_SIZE = 20 # Usually 1024, but we need quick response

tcpServer = socket.socket(socket.AF_INET, socket.SOCK_STREAM) tcpServer.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) tcpServer.bind((TCP_IP, TCP_PORT)) threads = []

while True: tcpServer.listen(4) print "Multithreaded Python server : Waiting for connections from TCP clients..." (conn, (ip,port)) = tcpServer.accept() newthread = ClientThread(ip,port) newthread.start() threads.append(newthread)

mpeuster commented 7 years ago

No, EXPOSE is not required for the interfaces of the emulated network, only for the Docker management interfaces.

I assume this code runs inside a container that is started in the emulation? How do you start this code, because it it blocking (while True)?

In any case it would help if you give more information about your setup. For example, paste the outputs of:

containernet> nodes
containernet> links
containernet> dump

and using the CLI:

son-emu-cli datacenter list
son-emu-cli compute list