Skip to content

TCP and IP Header, Window Size, Segment, Packet and Frame

Application Data
↓
TCP Segment
↓
IP Packet
↓
Ethernet Frame
↓
Physical Link
TermLayerMeaningTypical Value
MSS (Maximum Segment Size)TCPMaximum TCP Payload (Application Data only)1460 B
TCP Segment SizeTCPTCP Header + MSS1480 B
MTU (Maximum Transmission Unit)IPMaximum IP Packet Size = IP Header + TCP Segment1500 B
PMTU (Path MTU)IPMinimum MTU along the path≀ MTU
Maximum Ethernet Frame SizeData LinkEthernet Header + IP Packet + FCS1518 B
Minimum Ethernet Frame SizeData LinkSmallest Ethernet Frame64 B

Windows at TCP Layer (variable size)

  • cwnd - Congestion Window
  • rwnd - Receiver Window
  • Window Size - min(cwnd, rwnd)

Maximum amount of application data in one TCP segment.

MSS = MTU - IP Header - TCP Header

For Ethernet:

MTU = 1500 B
IP Header = 20 B
TCP Header = 20 B
MSS = 1500 - 20 - 20
= 1460 B

MSS includes:

Application Data only

Maximum size of an IP packet that can be carried on a link.

Includes:

IP Header + TCP Header + TCP Data

For Ethernet:

MTU = 1500 B

If:

IP Packet Size > MTU

Then:

  • IPv4: Fragmentation may occur.
  • IPv6: Sender must reduce packet size.

Smallest MTU among all links on the path.

Example:

A ----1500---- Router ----1200---- B
PMTU = 1200 B

Sender must send packets:

Packet Size ≀ PMTU

Ethernet Frame contains:

Ethernet Header = 14 B
IP Packet = 1500 B
FCS = 4 B
-----------------------
Total = 1518 B

Hence:

Maximum Ethernet Frame Size = 1518 B
Minimum Ethernet Frame Size = 64 B

Amount of data receiver can accept without ACK.

Example:

rwnd = 32 KB

Sender cannot have more than:

32 KB

of unacknowledged data.

Purpose:

Flow Control

Prevents receiver buffer overflow.

Amount of data sender can send according to network congestion.

Example:

cwnd = 16 KB

Sender sends at most:

16 KB

Purpose:

Congestion Control

Prevents network congestion.

The actual amount of data that can be in flight is:

Window Size
= min(cwnd, rwnd)

Example:

rwnd = 32 KB
cwnd = 16 KB
Window Size = 16 KB

Window Size limits:

Maximum unacknowledged data
that can be travelling in the network.

Suppose:

Window Size = 4 KB
MSS = 1 KB

Sender can send:

Packet 1 : 1 KB
Packet 2 : 1 KB
Packet 3 : 1 KB
Packet 4 : 1 KB
-----------------
Total : 4 KB

Now sender must wait for ACK.

Window Size is:

NOT Packet Size
It is
Total Outstanding Data

Maximum throughput:

Throughput
= Window Size / RTT
= min(cwnd, rwnd) / RTT

Example:

rwnd = 32 KB
cwnd = 64 KB
Window Size = 32 KB
RTT = 40 ms
Throughput
= 32 KB / 0.04
β‰ˆ 6.4 Mbps

Complete Picture

Ethernet Frame (1518 B max)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Ethernet Header (14 B) β”‚
β”‚ β”‚
β”‚ IP Packet (MTU=1500 B) β”‚
β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚ β”‚ IP Header (20 B) β”‚ β”‚
β”‚ β”‚ β”‚ β”‚
β”‚ β”‚ TCP Segment β”‚ β”‚
β”‚ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ β”‚
β”‚ β”‚ β”‚ TCP Header β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ (20 B) β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ Data β”‚ β”‚ β”‚
β”‚ β”‚ β”‚ MSS = 1460 B β”‚ β”‚ β”‚
β”‚ β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”‚
β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚ β”‚
β”‚ FCS (4 B) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Important Formulas

MSS = MTU - IP Header - TCP Header
Window Size = min(cwnd, rwnd)
Throughput = Window Size / RTT
Ethernet:
MTU = 1500 B
MSS = 1460 B
Maximum Frame Size = 1518 B
Minimum Frame Size = 64 B

1. TCP Header (Transport Layer)

0 8 16 31 (bits)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Source Port β”‚ Destination Port β”‚ Sequence Number β”‚
β”‚ (16b) β”‚ (16b) β”‚ (32b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Acknowledgment Number (32b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Data Off (4b) β”‚ Reserved (3b) β”‚ Flags (9b) β”‚ Window Size (16b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Checksum (16b) β”‚ Urgent Pointe (16b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Options (0–40 bytes) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Data β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
  • Size:
    • 20 bytes (without options)
    • 20–60 bytes (with options).
  • Purpose:
    • Reliable delivery, flow control, and connection management.
  • Key Fields:
    • Source Port (16B), Destination Port (16B) – identifies sending/receiving apps
    • Sequence Number (32B) – order of bytes
    • Acknowledgment Number (32B) – confirms received bytes
    • Data Offset (4B) – TCP header length
    • Flags (9 bits) – SYN, ACK, FIN, RST, PSH, URG
    • Window Size (16B) – flow control / in-flight data limit
    • Checksum (16B) – error detection
    • Urgent Pointer (16B) – optional
    • Options (variable) – optional, max header 60B
  • Function: Ensures reliable, ordered, and flow-controlled delivery of data.

2. IP Header (Network Layer)

IPv4 Header ⭐

  • Size:
    • 20 bytes (without options)
    • 20–60 bytes (with options).
  • Purpose:
    • Routing data from source to destination across networks.
  • Key Fields:
    • Version (4B) – IPv4/IPv6
    • Header Length (4B) – length of IP header
    • Type of Service / DSCP (8B) – priority / QoS
    • Total Length (16B) – IP packet size (header + data)
    • Identification / Flags / Fragment Offset – fragmentation control
    • TTL (8B) – Time to Live, decremented at each hop
    • Protocol (8B) – indicates encapsulated protocol (TCP=6, UDP=17)
    • Header Checksum (16B) – error detection
    • Source IP / Destination IP (32B each) – identifies endpoints
    • Options (variable) – rarely used
  • Function: Routes the packet across networks, handles fragmentation, and identifies endpoints.

IPv6 Header

  • Size: 40 bytes (fixed)
    • Unlike IPv4, IPv6 header does not have variable length unless there are extension headers.
  • Purpose: Routing packets across networks, similar to IPv4, but simplified for faster processing and larger address space.
  • Key Fields (Fixed 40 bytes):
    1. Version (4 bits): Always 6
    2. Traffic Class (8 bits): Like IPv4 DSCP, for QoS
    3. Flow Label (20 bits): For special routing of flows
    4. Payload Length (16 bits): Length of data after header
    5. Next Header (8 bits): Indicates transport protocol (TCP=6, UDP=17)
    6. Hop Limit (8 bits): Replaces TTL, decremented at each hop
    7. Source Address (128 bits)
    8. Destination Address (128 bits)
  • Notes:
    • No Header Checksum β†’ routers don’t recompute, faster processing
    • No Fragmentation fields β†’ fragmentation handled by source host, not routers
    • Extension Headers: Optional, separate from main 40-byte header

IPv4 header diagram

0 8 13 31 (bits)
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Version β”‚ IHL β”‚ Type of Ser.β”‚ Total Length β”‚
β”‚ (4b) β”‚ (4b) β”‚ (8b) β”‚ (16b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Identification (16b) β”‚ Flags (3b) β”‚ Frag Offset (13b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Time To Live (8b) β”‚ Protocol (16b) β”‚ Header Checksum (8b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Source IP Address (32b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Destination IP Address (32b) β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚ Options (0–40 bytes) β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Changes in Transit

1. TCP Header Fields & Changes in Transit

FieldSizeChanges During Transit?Why / Notes
Source Port16bNoApplication port of sender
Destination Port16bNoApplication port of receiver
Sequence Number32bNoAssigned by sender, stays same
Acknowledgment Number32bNoSet by receiver, does not change mid-transit
Data Offset4bNoHeader length, constant
Reserved3bNoAlways 0
Flags9bNoSYN, ACK, FIN, etc. are fixed per segment
Window Size16bNoFlow control; fixed in segment
Checksum16bRecomputed if any field changesUsually unchanged; only if network modifies bits (rare)
Urgent Pointer16bNoOnly used if URG flag set
Options0–40BNoUsually unchanged
DataVariableNoPayload unchanged
  • TCP headers do not change during transit, except rarely for checksum if bits are corrupted and fixed.

2. IPv4 Header Fields & Changes in Transit

FieldSizeChanges During Transit?Why / Notes
Version4bNoAlways 4 for IPv4
IHL (Header Length)4bNoConstant per packet
Type of Service / DSCP8bSometimesRouters may set QoS bits for priority
Total Length16bNoIncludes header + payload; does not change
Identification16bNoSame for all fragments
Flags3bFragmentation may set MF (More Fragments)If packet fragmented
Fragment Offset13bChanges if fragmentedIndicates position of fragment
TTL (Time To Live)8bDecrements at each hopPrevents loops; drops at 0
Protocol8bNoIdentifies transport layer protocol (TCP=6)
Header Checksum16bRecomputed at each hopBecause TTL changes, checksum changes
Source IP32bNoOriginal sender IP
Destination IP32bNoFinal receiver IP
OptionsvariableRarelyUsually unchanged
  • Only ==TTL and Header Checksum== always change at routers. ⭐
  • Fragmentation fields (Flags, Fragment Offset) change only ==if packet is fragmented.==

Key Differences

FeatureTCP HeaderIP Header
LayerTransportNetwork
Size20–60B20B
PurposeReliability, sequencing, flow controlRouting, addressing
Key FieldSequence Number, Window Size, FlagsSource IP, Destination IP, TTL
AffectsTCP Segment size, in-flight dataPacket routing, total packet size

Field Changes during Transit

  • Network (IP) β†’ TTL, Checksum, Fragmentation fields may change. ⭐
  • Transport (TCP) β†’ Usually nothing changes.

1. TCP Window Size

  • Max application data sender can send without ACK.
  • Measured in bytes, controls in-flight data.
  • Does not include headers, only counts payload.
Throughput = min(Window size / RTT, Link bandwidth)

2. TCP Segment

  • TCP payload + ==TCP header (20–60B)==.
  • Carries application data for transport.
  • Segment size limited by MSS:
MSS = MTU – IP header – TCP header

3. IP Packet

  • Segment + IP header (20B).
  • IP packet = TCP segment + IP header.
  • Packet is what network layer transmits to next hop.

4. Frame (Data Link Layer)

  • Packet + Link header + trailer (Ethernet example: 14B + 4B).
  • Max frame size limited by MTU (typically 1500B Ethernet).
  • Physical layer transmits bits of frame.

Quick Comparison & Relation

Relationship / Flow

Application Data
↓
TCP Segment = TCP header + data
↓
IP Packet = IP header + TCP segment
↓
Frame = Link header + IP packet + trailer
↓
Bits on wire

Comparison Table

TermSizeIncludesRoleRelation to Window Size
TCP Window SizeBytesOnly TCP payloadMax in-flight dataControls throughput
TCP SegmentTCP payload + TCP header (20–60B)TCP header + dataTransport unitMust fit in window
IP PacketSegment + IP header (20B)TCP + IP headers + dataNetwork unitSize affects MSS
FramePacket + Link header + trailerTCP/IP headers + data + Link headersPhysical transmissionMTU limits max segment size

Key Points to Understand:

  • Window size β†’ logical, controls how many bytes can be β€œin-flight”.
  • Segment / Packet / Frame β†’ physical encapsulations, headers reduce actual data per unit.
  • Header sizes β†’ overhead, reduce payload per transmission.
  • Frame size / MTU β†’ limits maximum segment size (MSS).

TCP Data Units, Window Size, and Bandwidth–Delay Product (BDP)

Section titled β€œTCP Data Units, Window Size, and Bandwidth–Delay Product (BDP)”

Data Units in Networking

  1. Bit – Smallest unit of data (0 or 1).
  2. Byte – 8 bits.
  3. Segment (TCP Layer)
    • Contains TCP header + application data.
    • TCP header: 20–60 bytes.
    • TCP segment = piece of application data ready to send.
  4. Packet (Network/IP Layer)
    • TCP segment is wrapped in IP header β†’ becomes packet.
    • IP header: 20 bytes.
    • Packet = TCP segment + IP header.
  5. Frame (Data Link Layer)
    • Packet is wrapped in Link Layer header + trailer β†’ Frame.
    • Ethernet example: Header = 14 bytes, Trailer (FCS) = 4 bytes.
    • Frame = Packet + Link Layer header + trailer.
  6. On-the-Wire
    • Physical layer transmits frames as bits.

Flow Diagram (Layer-wise)

Application Data
↓
TCP Segment (TCP Header + Data)
↓
IP Packet (IP Header + TCP Segment)
↓
Ethernet Frame (Link Header + Packet + Trailer)
↓
Bits transmitted on physical medium

TCP Window Size

  • Definition: Maximum amount of data sender can send without receiving ACK from receiver.
  • Measured in bytes.
  • Purpose: Controls β€œin-flight” data to match network capacity.

Key Concept:

  • Link can hold only limited bits at a time β†’ called Bandwidth–Delay Product (BDP).
  • TCP window size must be β‰₯ BDP to fully utilize the link.

Equation:

BDP (bits) = Link bandwidth (bits/sec) Γ— Round Trip Time (sec)
TCP Window Size (bytes) β‰₯ BDP / 8

Why Window Size Matters

  1. If TCP window < BDP:
    • Sender stops after sending window-sized data, waits for ACK.
    • Link capacity is not fully used β†’ throughput < max bandwidth.
  2. If TCP window β‰₯ BDP:
    • Sender continuously sends data β†’ link is full β†’ max throughput achieved.

Visualization:

Link capacity = pipe
BDP = pipe volume
Window size = amount sender can push into pipe at once
Window < BDP β†’ pipe not full β†’ wasted capacity
Window β‰₯ BDP β†’ pipe full β†’ maximum data in-flight

Relationship Between Units, Window, and Throughput

  • Data flows as: Application β†’ TCP Segment β†’ IP Packet β†’ Frame β†’ Bits on wire.
  • Window size controls how many TCP segments are in-flight.
  • BDP tells ideal number of bits in-flight to fully utilize link.
  • Throughput = min (Link capacity, Window/RTT)

Throughput Equation:

Throughput = TCP Window Size / RTT (bytes/sec)
If Window < BDP β†’ Throughput < Bandwidth
If Window β‰₯ BDP β†’ Throughput β‰ˆ Bandwidth

Summary Table

LayerUnitHeaderContentIn-Flight Control
ApplicationData-User info-
TransportSegment20–60BTCP header + DataTCP Window
NetworkPacket20BIP header + Segment-
LinkFrame14B+4BPacket + Header + Trailer-
PhysicalBits-Frame bitsControlled indirectly by Window & BDP