Skip to content

turlapati/SimpleMulticast

Repository files navigation

Testing Multicast Client & Server

Step #1 Statically compile the binaries

Plan is to use a basic (or minimum size) docker image like scratch or alpine to run the client and server programs. Make sure that CMakeLists.txt has the following directives to build a static binary.

set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++ -static")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBS OFF)

Check the binary with ldd <binary_name> command to make sure it does not have dependencies on any shared libraries

Client

Client will send multicast messages and expects unicast response from all listeners. There can be zero, one or more than one listener out there in the local network.

To dockerized client executable, use Dockerfile_client:

FROM scratch
WORKDIR /app
ADD ./theClient /app
CMD ["/app/theClient"]

Step #2 Create docker image for client

sudo docker build -t the_client -f Dockerfile_client .

Server

The server will join a multicast group and wait for a message. Once it receives a multicast packet, it sends unicast reply to the sender.

To dockerized server executable, use Dockerfile_server:

FROM scratch
WORKDIR /app
ADD ./theServer /app
CMD ["/app/theServer"]

Step #3 Create docker image for the server

sudo docker build -t the_server -f Dockerfile_server .

Instructions for Docker

Step #4 Create a Docker Network

Note: Change enp3s0 below to match with your host-machine's interface name

sudo docker network create -d ipvlan \
                           --subnet=192.168.92.0/24 \
                           --gateway=192.168.92.1 \
                           -o ipvlan_mode=l2 \
                           -o parent=enp3s0 \
                           my_network

Step #5 Start one or more Server instance(s)

Make sure to assign a unique static IP address within the subnet for each instance and avoid IP address conflicts

sudo docker run -it \
                --network my_network \
                --ip 192.168.92.100 \
                --cap-add NET_ADMIN \
                the_server

Step #6 Start the Client to start sending multicasts

sudo docker run -it \
                --network my_network \
                --ip 10.255.30.200 \
                --cap-add NET_ADMIN \
                the_client

Step #7 Start the ListServers program on the client docker instance

Screenshot

References

https://www.cs.unc.edu/~jeffay/dirt/FAQ/comp249-001-F99/mcast-socket.html

Other useful commands

Stop-all docker processes

sudo docker stop $(sudo docker ps -q)

Remove all docker images

sudo docker rmi -f $sudo docker images -q)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published