Page 1 of 1

udp test

Posted: Tue May 24, 2011 2:36 pm
by lama
Hello,
I have a situation:
My system is able to send UDP packet to remote IP. I'm using windump (it shows network traffic), so i'm 100 % sure, that these packets i'm sending, are definitly UDP, and their's local and remote IPs and ports are correct. To test if it really works, i have connected some other computer to my 'host' machine (this is the machine on which bochs with my system is running), on both computers is windump up and running. Then i have written a pretty simple UDP server, that can detect incoming connection, notice me about this fact, and then it will just print the incoming data on the screen.
I have tried it with UDP netcat, and it works perfectly. But when i try to send UDP packet from my system, server does nothing.
I can see (according to windump) how the packet left the host machine (bochs is configured to use real netcard) with correct source and destination IPs and ports - and then i can see that very packet coming to that other computer (again, according to windump), but the server (that crappy app i have written for testing purposes) does nothing.
So again: the packet get properly received by the other computer, but it does not go futher (to my app).
Any ideas, what could be wrong?

Re: udp test

Posted: Tue May 24, 2011 2:41 pm
by Combuster
Are you using the correct destination MAC address? Is your server listening on the correct interface (i.e. not from localhost only)?

Re: udp test

Posted: Tue May 24, 2011 2:57 pm
by lama
whoups, MACs are set to fake values...i'll try to set them right.

Re: udp test

Posted: Tue May 24, 2011 3:56 pm
by lama
MAC is correct, no effect.

Re: udp test

Posted: Wed May 25, 2011 4:37 am
by lama
So really no idea what can be wrong? I noticed that checksum field is zeroed, it could be it? But according to what i have read about udp - when ipv4 is used, no checksum have to be provided. Source MAC is also faked, but that does not matter i guess..am i right? Destination MAC is correct.
Any guesses? Seriously, anything.

Re: udp test

Posted: Wed May 25, 2011 5:53 am
by Owen
"Then i have written a pretty simple UDP server, that can detect incoming connection"

...UDP doesn't have connections...

Re: udp test

Posted: Wed May 25, 2011 6:05 am
by lama
..... I know that .. I guess that you know how i ment it, but ok, correction: 'it is able to detect if incoming data are available' ..

Re: udp test

Posted: Wed May 25, 2011 6:15 am
by Velko
Actually there are 2 checksum fields. One for IP header and another one for UDP. UDP's checksum is optional and can use all-zeros value. But what about IP's one?

Re: udp test

Posted: Wed May 25, 2011 7:15 am
by lama
I'm not sure, if IP checksum is mandatory or not. I'll try to cumpute that checksum and see if it helps.

Re: udp test

Posted: Wed May 25, 2011 1:55 pm
by lama
IP checksum corrected, no effect.

Re: udp test

Posted: Wed May 25, 2011 3:03 pm
by lama
Solved. For those that are interrested: for proper receive of UDP packet (from netcard memory to software layer) you must have correct IP's and UDP's checksumes (even if ipv4 is used - datasheet is wrong about this..), IP and UDP length field must also be correct.
Source ip/port and MAC can be any value i guess, but you have to always calculate checksumes properly - altough the netcard will receive it, but OS software layer will discard it. (which was subject of this topic).
You may lock this topic.