Checksums
Definition
A checksum is an error detection method used by most TCP/IP protocols.
Purposes
-
Protects against corruption during packet transmission.
- Calculated at sender and sent with packet.
- Recipient host performs the same calculation and accepts the packet if it is correct.
Sender Process

- Packet is divided into k sections of n bits each.
- All data undergoes one’s compliment arithmetic, where the the data is summed and any overflow is wrapped.
- Added together using one’s complement arithmetic.
- Result is complemented(bits flipped) to form the checksum.
Recipient Process
- Received packet (k sections of n bits) undergoes the same process as the sender.
- result of arithmetic is added to checksum and complemented
- If the final result =
0, the packet is accepted.
One’s Complement Arithmetic
- Binary addition, but the carry out of the most significant bit is wrapped around and added back into the least significant bit.

IP Header and Checksum
-
IP checksum covers only the header, not the data.
-
Higher-level protocols encapsulated in IP packets have their own checksum fields that cover the entire packet.
-
Routers only need to recalculate the checksum for the header, not the data.
- If the data were included, routers would have to recalculate the checksum for the whole packet → less efficient.
Transport Layer
Definition
Ensures process-to-process delivery of messages between different applications on the host.
Purposes
-
Service point addressing – Port numbers direct data to the correct application.
-
Segmentation and reassembly –
- Messages split into smaller segments.
- Segments assigned sequence numbers.
- Destination transport layer reassembles in correct order.
- Missing segments are identified and retransmitted.
-
Connection control
- Connection-based (TCP) – Establishes and terminates session before and after transfer; ensures ordered delivery.
- Connectionless (UDP) – No setup; packets sent independently.
-
Flow control – Regulates transmission rate; prevents overload.
-
Error control – Detects and corrects errors using acknowledgements and retransmission.
User Datagram Protocol (UDP)
Faster method for transmitting small amounts of data.
- Connectionless – No handshake.
- Unreliable – No guarantee of delivery order or success.
- Minimal overhead – 8-byte header.
Checksum
- Covers: pseudo header + UDP header + data.
- Pseudo header comes from the IP packet header.
Applications of UDP
-
Real-time applications: video calls, online gaming.
-
Lightweight services:
- DNS (port 53).
- TFTP – Trivial File Transfer Protocol (port 69).
-
Broadcast / multicast services:
- mDNS (port 5353).
Transmission Control Protocol (TCP)
Definition
A connection-oriented protocol that provides reliable, ordered, and error-checked delivery of data between applications over a network.
- Slower transfer but reliable for large amounts of data.
- Connection-oriented – Handshake establishes reliable connection.
- Reliable delivery – Integrity ensured via acknowledgements + timeouts.
- Error checking – Checksum.
- Flow control – Prevents overwhelming the receiver.
- Congestion control – Manages load, prevents congestion.
- Ordered delivery – Segments are reassembled using sequence numbers.
- Fixed header size – 8 bytes.
TCP Mechanisms
Connection Establishment – Three-Way Handshake
- Sender and receiver agree on connection state.
- Three messages exchanged: SYN → SYN-ACK → ACK.
- Uses an initial sequence number (ISN) chosen randomly.
Connection Termination – Four-Way Handshake
- Supports half-close (one side stops sending but continues receiving).
- Either server or client can initiate termination.
- Ensures all data is delivered and acknowledged.
Sequence Numbers
-
Every byte has a sequence number.
-
Sequence number = the first byte of user data in a segment.
-
Used for:
- Reordering data.
- Detecting missing data.
Acknowledgements (ACK)
- Receiver sends ACK with the next expected byte number.
- ACK = sequence number of last byte received + 1.
- Both sender and receiver maintain ACKs for reliable delivery.
Retransmissions
- Each sent segment has a retransmission timer.
- If timer expires before ACK → segment is resent.
- Fast recovery – Segment is retransmitted immediately upon receiving 3 duplicate ACKs.
Checksum
- 16-bit checksum covers header + data.
- Detects corruption → corrupted segment discarded and retransmitted.
Flow Control – Sliding Window
-
Sender specifies window size = how much data can be sent before needing an ACK.
-
Sliding window mechanism:
-
Allows transmission of multiple packets before waiting for ACKs.
-
Operates at octet level.
-
Window size changes dynamically:
- ACK contains receiver’s buffer limit.
- If receiver buffer = 0 → sender stops transmitting.
-
-
Prevents buffer overflow at receiver.
Ordered Delivery
- Out-of-order segments are cached until missing ones arrive.
- Data is delivered to application only after reordering.
Port Numbers
- Well-Known Ports (0–1023): Used by standard services (HTTP, FTP, DNS, etc.).
- Registered Ports (1024–49151): Used by user applications.
- Dynamic/Ephemeral Ports (49152–65535): Assigned temporarily for client connections.
TCP Mechanisms
Connection Establishment – Three-Way Handshake
- Sender and receiver agree on connection state.
- Three messages exchanged: SYN → SYN-ACK → ACK.
- Uses an initial sequence number (ISN) chosen randomly.
Connection Termination – Four-Way Handshake
- Supports half-close (one side stops sending but continues receiving).
- Either server or client can initiate termination.
- Ensures all data is delivered and acknowledged.
Sequence Numbers
-
Every byte has a sequence number.
-
Sequence number = the first byte of user data in a segment.
-
Used for:
- Reordering data.
- Detecting missing data.
Acknowledgements (ACK)
- Receiver sends ACK with the next expected byte number.
- ACK = sequence number of last byte received + 1.
- Both sender and receiver maintain ACKs for reliable delivery.
Retransmissions
- Each sent segment has a retransmission timer.
- If timer expires before ACK → segment is resent.
- Fast recovery – Segment is retransmitted immediately upon receiving 3 duplicate ACKs.
Checksum
- 16-bit checksum covers header + data.
- Detects corruption → corrupted segment discarded and retransmitted.
Flow Control – Sliding Window
-
Sender specifies window size = how much data can be sent before needing an ACK.
-
Sliding window mechanism:
-
Allows transmission of multiple packets before waiting for ACKs.
-
Operates at octet level.
-
Window size changes dynamically:
- ACK contains receiver’s buffer limit.
- If receiver buffer = 0 → sender stops transmitting.
-
-
Prevents buffer overflow at receiver.
Ordered Delivery
- Out-of-order segments are cached until missing ones arrive.
- Data is delivered to application only after reordering.
Port Numbers
- Well-Known Ports (0–1023): Used by standard services (HTTP, FTP, DNS, etc.).
- Registered Ports (1024–49151): Used by user applications.
- Dynamic/Ephemeral Ports (49152–65535): Assigned temporarily for client connections.
TCP Mechanisms for Reliable Data Transmission
-
Sequence Numbers
- Every byte is assigned a sequence number.
- Allows reordering and detection of missing data.

-
Acknowledgements (ACKs)
- Receiver sends an ACK with the next expected byte number.
- ACK = last received byte + 1.
- Confirms correct, in-order delivery.

-
Retransmission
- Sender sets a retransmission timer for each segment.
- If ACK not received, the segment is resent.
- Fast recovery: sender retransmits after 3 duplicate ACKs.


-
Checksum
- 16-bit checksum covers header + data.
- Corrupted segments discarded and considered lost.
-
Flow Control
-
Receiver advertises a window size to limit sender.
-
Prevents buffer overflow.
-
Uses sliding window protocol:
- Multiple packets sent before waiting for ACKs.
- Operates at octet level.
- Window size dynamic (ACK updates).
0→ sender stops transmission.

-
-
Ordered Delivery
- Out-of-order segments cached.
- Delivered in sequence to the application.
Port Numbers


