Unable to Send raw UDP packets using mmap in bridge and overlay mode

I am trying to send raw udp packets from container 1 to container 2. I have tried using the bridge, Macvlan and the overlay networking mode. It works in the Macvlan networking mode. But in bridge mode and the overlay networking mode, the container 1(send application) shows that it successfully sends the packets, But the packets are not seen outside the container. I have used wireshark to capture the packets. The recv application(conatiner 2) logs no packets received. The same is the case is overlay networking. The application works in the following way :
\1. ping the destination IP.
2. from arp get mac address and fill the eth header.
3. After that, fill the IP and UDP header.
4. send the packets.


Docker info:

Containers: 87
Running: 0
Paused: 0
Stopped: 87
Images: 273
Server Version: 18.03.0-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: cfd04396dc68220d1cecbe686a6cc3aa5ce3667c
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
apparmor
seccomp
Profile: default
Kernel Version: 4.13.0-39-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.57GiB
Name:
ID:
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: satyasameer
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support


Docker version:

Client:
Version: 18.03.0-ce
API version: 1.37
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:10:01 2018
OS/Arch: linux/amd64
Experimental: false
Orchestrator: swarm

Server:
Engine:
Version: 18.03.0-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.4
Git commit: 0520e24
Built: Wed Mar 21 23:08:31 2018
OS/Arch: linux/amd64
Experimental: false

Steps to reproduce in docker bridge networking mode
\1. images are in the repository:
– send application: satyasameer/mmap:send
– recv application: satyasameer/mmap:recv

2. run the container in interactive mode:

recv: 
         docker run -it --rm --name recv satyasameer/mmap:recv /bin/bash

send: 
         docker run -it --rm  --name send satyasameer/mmap:send /bin/bash


3. to send packets from the send container run:

 ./send -a <IP address of the recv container> -p 9000 eth0


4. to run the receive application:

 ./recv eth0

Install iperf on both containers: apt-get install iperf
and try followings:

  • On receiver: iperf -s -u -p 9000
  • On sender: iperf -c <ip-of-receiver> -p 9000 -u

If they can transmit packets and shows some statistics on the reciever side, then you have problems with your code, not docker networking side.