Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UDP packages appear in wireshark, but are not received by program

I am trying to read UDP packages sent by an FPGA with my computer. They are sent to port 21844 and to the IP 192.168.1.2 (which is my computer's IP). I can see the package in wireshark, they have no errors. When I run however this little python script, then only a very very small fraction of all packages are received by it, also depending if wireshark is running or not.

import socket
import sys


HOST, PORT = "192.168.1.2", 21844
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind((HOST,PORT)) 
received ,address= sock.recvfrom(2048)
print address

I use windows 7 with Norton Internet Security, where I allow all traffic in the firewall for the FPGA IP and also for python. The same program on a Windows XP computer does not receive anything either...

Thanks for any help!

like image 215
Michael Avatar asked May 28 '10 11:05

Michael


People also ask

Are UDP packets guaranteed to arrive?

UDP does not guarantee that your packets will arrive in order. (It does not even guarantee that your packets will arrive at all.) If you need that level of robustness you are better off with TCP.

Why are UDP packets lost?

The UDP packet loss is especially affected by TCP traffic and its flow control mechanism. This is because TCP flow control continues to increase its window size until packet loss occurs if the advertised window size is large enough.


1 Answers

The TCP/IP stack of your OS doesn't hold those packets for you for eternity. Your script looks like something that very much depends on when it is run. Try to recvfrom in a loop, and run the script in the background. Then, start sending packets from your FPGA.

For extra convenience, explore the SocketServer module from Python's stdlib.

like image 180
Eli Bendersky Avatar answered Sep 25 '22 13:09

Eli Bendersky