EmbDev.net

Forum: ARM programming with GCC/GNU tools confused by various UDP checksum algorithms


von magnetron (Guest)


Rate this post
useful
not useful
hello forum,

I am trying to send an UDP packet (contains only "TEST" string)
from STM32 to VB6 winsock
I can see packets going with wireshark software

however winsock data_arrival subroutine never gets called
( if I send from laptop winsock to PC winsock or vice versa  UDP packet 
is received OK )

I am suspecting that I cannot calculate UDP checksum correct

in google every single example calculates the UDP checksum different way

my question ,

has anybody a correct algorithm for UDP checksum ?
( which he has tested to be true )

thank you

von (prx) A. K. (prx)


Rate this post
useful
not useful
In IPv4, the UDP checksum is optional. If you want to keep things 
simple, just set it to zero.

von (prx) A. K. (prx)


Rate this post
useful
not useful
For a working source code: There's plenty of public source code to look 
at. Perhaps the most simple (overall) is Adam Dunkels' uip stack for 
small µControllers.

von magnetron (Guest)


Rate this post
useful
not useful
I have run uIP demo supplied with the development board already - no 
problem

however uIP code is too complex to understand

besides I dont need TCP/IP
I only need send an receive a simple UDP packet to PC

coming to UDP checksum ; I have tried with checksum field zero
no success

von Gruene - Nein Danke (Guest)


Rate this post
useful
not useful
Please give a wireshark snapshot

von magnetron (Guest)


Attached files:

Rate this post
useful
not useful
hello thank you,

here is the wireshark printscreen
winsock cannot receive this packet

I have an USRobotics adsl router between PC and STM32F4

von Gruene - Nein Danke (Guest)


Rate this post
useful
not useful
Take a look at the first 6 bytes. Thats a broadcast adress.

von magnetron (Guest)


Rate this post
useful
not useful
hello thank you

I tried with the MAC adress of my PC still no success

by the way my original question still open

can you give me a working UDP checksum algorithm

von (prx) A. K. (prx)


Rate this post
useful
not useful
Packets which are invalid at the ethernet level won't arrive at 
Wireshark. Also, in my experience, Wireshark complains when it 
encounters a bad packet. Since Wireshark does not complain (in the 
screen shot shown above), it likely is formally correct at the UDP level 
as well.

Since you had a working packet sent via laptop: Is the checksum really 
the only difference between those frames? Doing a side by side 
comparison.

Concerning the checksum: You told, that you already found several code 
snippets for it. Likely most or all of them produce a correct result at 
least on the platform they were written for. So getting a few more 
slightly different snippets likely won't help a lot.

Anyway, there are authoritative sources: The RFCs for UDP (768) and for 
the IP checksum calculation (1071). RFC 1071 even includes sample code.

von (prx) A. K. (prx)


Rate this post
useful
not useful
And BTW: What sources of information did you use for your code? The UDP 
checksum isn't simply a checksum of all header and data bytes, but this 
should be mentioned in every detailed UDP description.

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.