Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App

Related Articles

XMODEM File Transfer Protocol

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

XMODEM is a file transfer protocol which enables users to transmit files between different computers.

History :
XMODEM was developed by Ward Christensen in 1977 and since then the method of sharing files has changed. It became extremely popular in the early bulletin board system (BBS) market because of its simple implementation. However it became inefficient as the modem speeds increased. The solution to this led to the development of several modified versions of XMODEM to improve the performance and resolve other issues with the file sharing protocol. XMODEM is the most modified computer program in history.

Functioning :
XMODEM breaks up the original data into a series of “packets” which are sent to the receiver. It also contains additional information which allows the receiver to determine whether that packet was correctly received or not. The packet is resent after requested by the receiver if an error encounters. The transfer is aborted because of a string of bad packets.

Following table displays the various symbols used during transfer and their meaning –

SOHStart of Header
EOTEnd of Transmission
NAKNot Acknowledge
ETBEnd of Transmission Block

Packet Structure :
The original packet structure of XMODEM is given below –

Checksum is the sum of all bytes in the packet modulo 256. In other words it can be computed by discarding all but the eight least significant bits of the result of summation. In this way. For example, if this checksum method is used on a tiny data packet containing only two bytes carrying the values 130 and 130, the summation of these codes is 260, and the resulting checksum is 4. This ensures that the checksum is stored in 8 bits only.

Method of transfer :
Transfers are receiver-driven, i.e., the transmitter will not send any data until an initial NAK is sent by the receiver. The transmitter waits until the receiver sends a NAK byte. The NAK byte is the signal that the receiver is ready to start. This is the initial byte which displays that the file transfer is ready to begin.  If the receiver takes too long or an error occurs then the transmitter will stop waiting or “Time Out”.

The file transfer will restart if it gets timed out. A NAK is also sent if the receiver does not receive a valid packet within ten seconds while still expecting data due to the lack of a EOT character.

Receiver performs the following tasks and transfers one packet at a time –

  1. It checks that the packet number sent matches the actual packet number i.e., 2nd byte is checked in the packet. In case of any discrepancy it sends a CAN byte to cancel the transfer.
  2. It adds the 1’s compliment and the packet number that is the 3rd and the 2nd bit to check if they add up to 255. In case of any discrepancy it sends a CAN byte to cancel the transfer.
  3. Packet’s checksum is calculated after retrieval and is compared to the one received from the sender at the end of the packet. If the condition SUM = CHECKSUM is true then the receiver sends an ACK byte to the transmitter which is an indication to send the next packet in sequence. If the condition is not satisfied then a NAK byte is sent which indicates the transmitter to again send the byte.

Transfer completion :
If the transmitter sends an EOT byte instead of a SOH byte, the receiver sends a NAK byte.

If the transmitter sends another EOT immediately after that,the receiver sends an ACK byte and the transfer is complete. The receiver has the ability to can cancel the transfer at any time by sending a CAN byte whereas the transmitter can only cancel between blocks by sending a CAN byte.

My Personal Notes arrow_drop_up
Last Updated : 29 May, 2020
Like Article
Save Article
Similar Reads