The KingTut Protocol

The sender sends all file contents in packets.  Every packet is UDP.  Each packet will have the following format
 
Name Meaning Starting Offset
Version A signed int, normally the number '4' 4 bytes
Offset A signed int, the position of the NEXT byte to come AFTER this packet. 4 bytes
CRC A crc calculated by running ComputeChecksum over the whole packet including header.  When computing the CRC, it assumes there are zeros in this field. 4 bytes
Len A signed int, the length of the data portion of this packet 4 bytes
Data The actual data 'Len' bytes

Acks have the following format
 
Name Meaning Starting Offset
Version A signed int, normally '4' 0
nextPos A signed int, the next byte to send 4

The sender will begin by sending  data.  The first packet will consist of :
 
Name Start Position Value
Version 0 4
Offset 4 'len'
CRC 8 1212121212 (or some such thing)
Len 12 length of the data to follow
Data 16 "King Tut was a young boy ..." (or some such thing)

You have 0.5 seconds to reply.  If you fail to reply a new packet will be sent.
You should

If the packet is OK, you should The only legal values of nextPos are The maximum packet length including header is 1024 bytes.  The minimum packet length is 16 bytes.  Every ack packet is 8 bytes long.