EmbDev.net

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


Author: magnetron (Guest)
Posted on:

Rate this post
0 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

Author: A. K. (prx)
Posted on:

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

Author: A. K. (prx)
Posted on:

Rate this post
0 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.

Author: magnetron (Guest)
Posted on:

Rate this post
0 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

Author: Gruene - Nein Danke (Guest)
Posted on:

Rate this post
0 useful
not useful
Please give a wireshark snapshot

Author: magnetron (Guest)
Posted on:
Attached files:

Rate this post
0 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

Author: Gruene - Nein Danke (Guest)
Posted on:

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

Author: magnetron (Guest)
Posted on:

Rate this post
0 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

Author: A. K. (prx)
Posted on:

Rate this post
0 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.

Author: A. K. (prx)
Posted on:

Rate this post
0 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.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.