I need to program a basic network stack in c, but have some questions regarding proper practices. Let's assume that I only need to support UDP at L4 and IP at L3.
When I want to sent a big message that needs to be fragmented. What is the proper order in which to handle this?
1) Initialize the udp header and calculating the checksum over the whole data field (plus udp and pseudo header) Then fragment the data field, build the IP header for each fragment, then send out the fragments.
2) Fragment the data field, then build a udp header with a different checksum tacked on the front of each fragment. Then build an IP header to tack in fron of that for each fragment. Then send our the fragments.
My confusions stems from whether the udp checksum should encompass the entire assembled datagram, or just the individual fragment. I greatly appreciate any help you can provide.