OpENer icon indicating copy to clipboard operation
OpENer copied to clipboard

Multiple OpENer Instances

Open jpbedrock opened this issue 4 years ago • 5 comments

I have been using OpENer for a few weeks and I have a single instance in Linux communicating with a scanner on another PC. I now need to scale up and have a larger number (64-128) of OpENer instances running at the same time on the network in order to test simultaneous connections to the scanner. Looking at the source code, OpENer binds to the mac address of the ethernet interface, which would mean I would need a separate ethernet interface for each OpENer instance. After going down a few unsuccessfully paths such as aliased interfaces and multiple virtual interfaces in a VM (same subnet on multiple interfaces is bad) I would like to ask if there are any suggestions on how to get more than one instance working on a single PC or VM. Thank you for any help

jpbedrock avatar Dec 15 '21 22:12 jpbedrock

If anyone in the future is looking to do something similar, my workaround was to create a Docker image for OpENer and connect them to a Docker network in macvlan mode. Macvlan will generate a unique mac for each OpENer instance allowing one machine to host as many OpENers as you want through a single enet (I have gone up to 128 so far) .

jpbedrock avatar Mar 16 '22 14:03 jpbedrock

@jpbedrock the usual scenario for OpENer is one instance per device. Your solution with Docker containers is a very nice approach. Was it complicated to create a docker config for it? I am not a docker expert, but I think it would be a nice addition for the project.

MartinMelikMerkumians avatar Mar 23 '22 11:03 MartinMelikMerkumians

@CapXilinx Docker was pretty straight forward once I figured out the macvlan network. Here are some starting points and notes:

  1. Create a macvlan network for this purpose and tie it to the desired eth port. Specify the IP range and use aux address to exclude the addresses used by other devices in the subnet such as the IP of the EIP scanner PC, network bridge, etc.:

docker network create -d macvlan --subnet=192.168.135.253/24 --ip-range=192.168.135.100/24 --aux-address="PC1=192.168.135.250" --aux-address="VM=192.168.135.252" --aux-address="BR=192.168.135.253" -o parent=eth2 mac_vlan_network

Check the network you created with: docker network inspect mac_vlan_network

The network will assign IP's to the docker containers and an external scanner will be able to communicate with them. To access the containers from inside the docker host, you will have to create a bridge.

  1. Create a Dockerfile. This uses Ubuntu as the base image. It will copy OpENer to the image root and install the required packages. Lastly run OpENer on eth0 of the image:

#Filename: Dockerfile FROM ubuntu:20.04 ADD ./bin/posix/src/ports/POSIX/OpENer / RUN apt-get update && apt-get install -y --no-install-recommends libcap-dev nmap ENTRYPOINT ["./OpENer", "eth0"]

  1. Create a docker-compose.yml that will let you connect the macvlan network to the containers and easily build them and tear them down:

version: "3.3" services: dockerimagename: network_mode: mac_vlan_network image: dockeruser/dockerimagename

Note that to login to a running container, you have to expose a port in the dockerfile and dockercompose files and set up a network bridge.

  1. Docker commands to start and stop multiple instances of the OpENer containers:

Start up 128 docker image instances: docker-compose up --scale dockerimagename=128 -d Shut down all the instances: docker-compose down

jpbedrock avatar Mar 23 '22 16:03 jpbedrock

Thanks for the description. I'll add it as an additional document to the OpENer repository, if that's ok?

MartinMelikMerkumians avatar Jun 14 '22 11:06 MartinMelikMerkumians

Yes, that is fine by me. Thank you for asking.

jpbedrock avatar Jun 14 '22 13:06 jpbedrock