TCP (Transmission Control Protocol)
TCP and UDP (User Diagram Protocol) lives in layer 4 in OSI Layers.
TCP splits the data into small managable segment.
Each segment is marked as a sequence number. When the other device (Device B) receives these segments of data. It will sort these segments based on the sequence number:
TCP also provides error checking to make sure that the data is not corrupted.
Note:
TCP does not preseve packet boundaries. Which means by default, it automatically cut the packet into chunks no matters how big it is. For example:
ACK / SYNC
TCP needs ACK and SYNC. The steps are:
Packet Header
Source/Destination Port
: source and the destination port number (not the ip address)- A
socket = ip + port
- A
Sequence number
: 32 bits keep track of the order of the packetAcknowledgement number
: 32 bits of the next sequence number should expect- If the
Acknowledgement number != next sequence number
then the packet is marked as lost
- If the
HLEN (Header Length)
: 4 bits identify the length of the header. This is necessary because the length ofOptions
is undefined and can be varied.Reserved
: Always set to 0Flags
: 8 1 -bit flags are used for data flow and connection control- The flags are:
- Congestion Window Reduced (CWR)
- ECN (Echo ECE)
- Urgent (URG)
- Acknowledgement (ACK)
- Push (PSH)
- Reset (RST)
- Synchronize (SYN)
- Final (FIN)
- The flags are:
window size
: 16 bit field for flow control. How many bytes sender is allowed to transmit without receiving an acknowledgementChecksum
: 16 bits for errordetectionUrgent pointer
: only use whenURG
flag is set. This 16 bit is added to the end for urgent dataOptions
: options required by the senders process. Normally use to specify Maximum Segment Size — informs the receiver of the largest segment the sender is willing to accept