uhppoted / uhppote-simulator

Go simulator for the UHPPOTE UT0311-L0x TCP/IP Wiegand access controller boards
MIT License
1 stars 2 forks source link

simulator in Docker container stops broadcasting events #9

Closed uhppoted closed 6 months ago

uhppoted commented 9 months ago

uhppote-simulator hosted in recent'ish versions of Docker containers stop broadcasting events "after a while" (running the simulator from the command line does not exhibit the behaviour).

twystd commented 6 months ago

Notes:

  1. https://superuser.com/questions/1579858/docker-bridge-network-sporadically-loosing-packets
  2. https://github.com/chipmk/docker-mac-net-connect
  3. https://blog.codavel.com/docker-network-on-macos-how-to-reach-gigabit
  4. https://forums.docker.com/t/docker-container-loses-network-connectivity-intermittently/120560/11
  5. https://github.com/docker/for-mac/issues/6654
  6. tcpdump
    
    sudo tcpdump -vv -k -i any udp port 60001

tcpdump: data link type PKTAP tcpdump: listening on any, link-type PKTAP (Apple DLT_PKTAP), capture size 262144 bytes 12:01:24.987898 IP (tos 0x0, ttl 64, id 64697, offset 0, flags [none], proto UDP (17), length 92, bad cksum 0 (->f9be)!) 192.168.1.100.57353 > 192.168.1.100.60001: [bad udp cksum 0x8472 -> 0x142d!] UDP, length 64 12:01:24.987910 IP (tos 0x0, ttl 64, id 64697, offset 0, flags [none], proto UDP (17), length 92, bad cksum 0 (->f9be)!) 192.168.1.100.57353 > 192.168.1.100.60001: [bad udp cksum 0x8472 -> 0x142d!] UDP, length 64


7. `watch -n 60 "echo "woot" | nc -u -w 1 192.168.1.100 60001"` works fine (_WireShark_/_tcpdump_ on the host see all _woot_ packets). 
8. `tcpdump -vv -i any udp port 60001` in the container shows the packet being sent but it never reaches WireShark.

_Something to do with the bridge network maybe ???_
twystd commented 6 months ago

Resolved - reworked the simulator event handling to use a new connected UDP socket rather than reusing the bound listen socket to send the event to the event listener. This is technically the correct way to do it but interestingly it's only a problem on Docker.