Let’s say I am trying to send data using udp socket. If the data is big then I think the data is going to be divided into several packets and sent to the destination.
At the destination, if there is more than one incoming packets then how to I combined those separated packets into the original packet? Do I need to have a data structure that save all the incoming udp based on the sender ? Thanks in advance..
If you are simply sending the data in one datagram, using a single
send()call, then the fragmentation and reassembly will be done for you, by the transport layer. All you need to do is supply a large enough buffer torecv(), and if all the fragments have arrived, then they will be reassembled and presented to you as a single datagram.Basically, this is the service that UDP provides you (where a “datagram” is a single block of data sent by a single
send()call):However, if you are performing the division of the data into several UDP datagrams yourself, at the application layer, then you will of course be responsible for reassembling it too.
1. Correct with the probability implied by the UDP checksum, anyway.