7

I developed a C++ app to stream video from a webcam on an Odroid device over UDP. The client is an iPhone app using simple UDP sockets and it works perfectly over Wi-fi, but not over LTE. The sendto() call works okay, but the recvfrom() blocks forever. First I thought it has to do with iPhone blocking UDP traffic, but I also tried a client on my laptop connected in the iPhone's hotspot and thus over LTE. Do you think there is something with phone providers blocking UDP traffic? I preferred UDP instead of TCP for faster streaming. Any advice would be highly appreciated! Thanks!

UPDATE: I found the cause of the problem after some further inspection. It turns out that UDP over LTE sets the IP_MTU_DISCOVER flag and if the user's packet is larger than the device's MTU, it does not perform IP fragmentation but simply drops the packet. My application is sending packets larger than MTU, but in the case of Wi-fi they are fragmented in the IP layer. If you disable the IP_MTU_DISCOVER flag, the large packet is fragmented and arrives successfully in the destination. The other alternative would be to send packets smaller than MTU from the application. Both approaches do not perform that well, but at least the mystery is solved.

dimstamat
  • 135
  • 10
  • Traffic interception and delaying or blocking by mobile providers is not unheard of. But your question does not provide sufficient details if this is really the case here. It might also be a programming error or problems involving NAT done by the provider. Also, UDP is an unreliable protocol by definition so your application should be able to deal with loss, duplication and reordering of packets (although probably not with full blocking of all UDP traffic). It might be that the LTE just exhibits this kind of problems and your WiFi connection did not. – Steffen Ullrich Oct 13 '18 at 06:24
  • Thanks Steffen. Well, I do all kind of error checkings. The problem is that recvfrom() never returns. I examined the network traffic with wireshark and I see the UDP packet that client sends with sendto() to initiate the connection. After that, I do not see any more packets, even though I see that the server successfully got the message and started streaing. In addition, I did a simple test with VLC streaming over UDP, and I get the same behavior. It works over Wi-Fi but not LTE: https://sandilands.info/sgordon/live-webca-streaming-using-vlc-command-line – dimstamat Oct 13 '18 at 06:33
  • Do you bind your local UDP socket, send from this socket to the server and then try to receive on the same socket? Or do you try to receive on a different socket? The last case will have problems if NAT is involved (as is often the case within mobile networks) while in the first case there should be a NAT state created which will allow the response packets to come back to the sender. The example with vlc will likely not work through NAT since I don't think there is a state established by sending data from the client to the server first on the same socket where data get received. – Steffen Ullrich Oct 13 '18 at 06:44
  • I use the same socket for sending and receiving. Why wouldn't the VLC example work? I set the destination address of the client so it should know where to send the stream. The client uses my home's IP address and I made sure that the port is open from my router and forwarded to the local IP. – dimstamat Oct 13 '18 at 06:57
  • *"The client uses my home's IP address and I made sure that the port is open from my router and forwarded to the local IP"* - I'm confused. According to the question your client is on the iPhone using LTE. – Steffen Ullrich Oct 13 '18 at 07:59
  • Sorry, I meant to say that the client connects to the server via the home's IP address. In the first example with wi-fi, client's VLC was running this: udp://@:PORT_NUM, since client and server are at the same network. In the case of LTE, I don't think it would work if you just add udp://@:PORT_NUM, so I added my home's IP address instead of @. – dimstamat Oct 13 '18 at 16:58
  • Before you jump to the conclusion that UDP is blocked by the LTE provider I recommend that you try it from another WiFi, i.e. try to connect from some external WiFi to the VLC on your network at home. Many things work in the local network but break once NAT routers are involved. – Steffen Ullrich Oct 13 '18 at 17:11
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/181814/discussion-between-dimstamat-and-steffen-ullrich). – dimstamat Oct 13 '18 at 17:38

0 Answers0