udp test

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

udp test

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: udp test

Post by Combuster »

Are you using the correct destination MAC address? Is your server listening on the correct interface (i.e. not from localhost only)?
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

Re: udp test

Post by lama »

whoups, MACs are set to fake values...i'll try to set them right.
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

Re: udp test

Post by lama »

MAC is correct, no effect.
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

Re: udp test

Post 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.
User avatar
Owen
Member
Member
Posts: 1700
Joined: Fri Jun 13, 2008 3:21 pm
Location: Cambridge, United Kingdom
Contact:

Re: udp test

Post by Owen »

"Then i have written a pretty simple UDP server, that can detect incoming connection"

...UDP doesn't have connections...
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

Re: udp test

Post 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' ..
User avatar
Velko
Member
Member
Posts: 153
Joined: Fri Oct 03, 2008 4:13 am
Location: Ogre, Latvia, EU

Re: udp test

Post 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?
If something looks overcomplicated, most likely it is.
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

Re: udp test

Post 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.
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

Re: udp test

Post by lama »

IP checksum corrected, no effect.
lama
Member
Member
Posts: 83
Joined: Thu Apr 16, 2009 8:41 am

Re: udp test

Post 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.
Post Reply