I want to know that how these protocols can detect that an error has been occurred during the data transmission? thanks
Checksum is a simple error detection mechanism to determine the integrity of the data transmitted over a network. Communication protocols like TCP/IP/UDP implement this scheme in order to determine whether the received data is corrupted along the network.
Error detection and correction in TCP is achieved through the use of three simple tools: checksum, acknowledgment, and time-out. Checksum : Each segment includes a checksum field which is used to check for a corrupted segment.
No error checking,error correction, or acknowledgment is done by UDP. UDP is only concerned with speed. So when, the data sent over the Internet is affected by collisions, and errors will be present.
TCP provides reliable, ordered, and error-checked delivery of a stream of octets (bytes) between applications running on hosts communicating via an IP network.
There are different errors that can occur:
UDP only provides a mechanism to overcome the corruption of data (which is an optional feature in IPv4, mandatory in IPv6).
Corruption of Data
UDP is only resistant against the corruption of data inside packets, if the checksum field is used in the header of every packet. Basically it takes the header, the packet content and some more information (like IP addresses), interprets this as a long list of 16 bit words in ones-complement and sums them up UDP checksum.
TCP has a similar approach to tackle corruption of data.
All the other problems
TCP has so-called sequence numbers for every packet. The sequence number addresses bytes, so if the sender says "this is the packet with sequence number 102", he says, that the packet he sent starts with the byte 102 of the stream. The receiver then sends and acknowledgement to the receiver. For example, if the packet has a length of 10 bytes, the receiver will send and Ack with the sequence number 112, which means "i expect the next packet to be received to start with the sequence number 112". Every packet that has a different sequence number is either a duplicate (too low) or a packet got lost (received sequence number is too high) or it is a phantom (total mismatch of expected sequence number and received one). So in all cases of sequence-number mismatch, the receiver knows that something goes wrong and can react (differs from different TCP versions).
The sender waits for the acknowledgements of the receiver. If he does not receive an expected ack for a certain time, he will retransmit packets, because he assumes, that the packets got lost on their way.
This is only a very brief explanation. The topic is somewhat bigger than described here ;)
At the IP protocol level (on which both UDP and TDP are based), there is a checksum that confirms that the contents of the packet are valid. However, there are situations where certain errors are not detected by this checksum.
Usually at a higher level (such as when transferring a file), there is a more robust hash calculated on the contents of the file. This might be done on the complete file, or on individual blocks of the file of some size (usually much larger than a single IP packet).
If I recall from various classes, Greg was right with the checksum as one of a few sources of data verification. However, UDP (designed the way it is) is not always 100% reliable. This makes it perfect for streaming data (webcams, for example), as losing a frame is not that big a deal. While this would be considered an error in TCP (which would then have to resend the frame, delaying all following frames), UDP does not really care unless it is configured to.
Provided that all data is required to be received, the protocol in question on the requesting side makes sure to ask for each packet to be sent, typically in order. Checksum comes in to play here as each part is then checked to make sure it is correct (small problem when the data part errors an even number of times as the checksum can then throw a false positive, but this is pretty rare). Each time a part fails, it is re-requested until it is both received and checksum gives a thumbs up. As each part is received, the protocol at the receiver responds to the sender that everthing is cool. If the sender does not receive this response within some time limit, it resends the packet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With