TCP and IP Header, Window Size, Segment, Packet and Frame
TCP, IP and Ethernet Size Limits
Section titled βTCP, IP and Ethernet Size LimitsβApplication Data βTCP Segment βIP Packet βEthernet Frame βPhysical Link| Term | Layer | Meaning | Typical Value |
|---|---|---|---|
| MSS (Maximum Segment Size) | TCP | Maximum TCP Payload (Application Data only) | 1460 B |
| TCP Segment Size | TCP | TCP Header + MSS | 1480 B |
| MTU (Maximum Transmission Unit) | IP | Maximum IP Packet Size = IP Header + TCP Segment | 1500 B |
| PMTU (Path MTU) | IP | Minimum MTU along the path | β€ MTU |
| Maximum Ethernet Frame Size | Data Link | Ethernet Header + IP Packet + FCS | 1518 B |
| Minimum Ethernet Frame Size | Data Link | Smallest Ethernet Frame | 64 B |
Windows at TCP Layer (variable size)
cwnd- Congestion Windowrwnd- Receiver Window- Window Size -
min(cwnd, rwnd)
MSS (Maximum Segment Size)
Section titled βMSS (Maximum Segment Size)βMaximum amount of application data in one TCP segment.
MSS = MTU - IP Header - TCP HeaderFor Ethernet:
MTU = 1500 BIP Header = 20 BTCP Header = 20 B
MSS = 1500 - 20 - 20 = 1460 BMSS includes:
Application Data onlyMTU (Maximum Transmission Unit)
Section titled βMTU (Maximum Transmission Unit)βMaximum size of an IP packet that can be carried on a link.
Includes:
IP Header + TCP Header + TCP DataFor Ethernet:
MTU = 1500 BIf:
IP Packet Size > MTUThen:
- IPv4: Fragmentation may occur.
- IPv6: Sender must reduce packet size.
PMTU (Path MTU)
Section titled βPMTU (Path MTU)βSmallest MTU among all links on the path.
Example:
A ----1500---- Router ----1200---- B
PMTU = 1200 BSender must send packets:
Packet Size β€ PMTUEthernet Frame Size
Section titled βEthernet Frame SizeβEthernet Frame contains:
Ethernet Header = 14 BIP Packet = 1500 BFCS = 4 B-----------------------Total = 1518 BHence:
Maximum Ethernet Frame Size = 1518 BMinimum Ethernet Frame Size = 64 Brwnd (Receiver Window)
Section titled βrwnd (Receiver Window)βAmount of data receiver can accept without ACK.
Example:
rwnd = 32 KBSender cannot have more than:
32 KBof unacknowledged data.
Purpose:
Flow ControlPrevents receiver buffer overflow.
cwnd (Congestion Window)
Section titled βcwnd (Congestion Window)βAmount of data sender can send according to network congestion.
Example:
cwnd = 16 KBSender sends at most:
16 KBPurpose:
Congestion ControlPrevents network congestion.
Actual TCP Window
Section titled βActual TCP WindowβThe actual amount of data that can be in flight is:
Window Size
= min(cwnd, rwnd)Example:
rwnd = 32 KBcwnd = 16 KB
Window Size = 16 KBWhere is Window Size Used?
Section titled βWhere is Window Size Used?βWindow Size limits:
Maximum unacknowledged datathat can be travelling in the network.Suppose:
Window Size = 4 KBMSS = 1 KBSender can send:
Packet 1 : 1 KBPacket 2 : 1 KBPacket 3 : 1 KBPacket 4 : 1 KB-----------------Total : 4 KBNow sender must wait for ACK.
Window Size is:
NOT Packet Size
It is
Total Outstanding DataThroughput
Section titled βThroughputβMaximum throughput:
Throughput
= Window Size / RTT
= min(cwnd, rwnd) / RTTExample:
rwnd = 32 KBcwnd = 64 KB
Window Size = 32 KB
RTT = 40 ms
Throughput
= 32 KB / 0.04
β 6.4 MbpsComplete 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 BMSS = 1460 BMaximum Frame Size = 1518 BMinimum Frame Size = 64 BTCP Header vs IP Header
Section titled βTCP Header vs IP Headerβ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):
- Version (4 bits): Always 6
- Traffic Class (8 bits): Like IPv4 DSCP, for QoS
- Flow Label (20 bits): For special routing of flows
- Payload Length (16 bits): Length of data after header
- Next Header (8 bits): Indicates transport protocol (TCP=6, UDP=17)
- Hop Limit (8 bits): Replaces TTL, decremented at each hop
- Source Address (128 bits)
- 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
| Field | Size | Changes During Transit? | Why / Notes |
|---|---|---|---|
| Source Port | 16b | No | Application port of sender |
| Destination Port | 16b | No | Application port of receiver |
| Sequence Number | 32b | No | Assigned by sender, stays same |
| Acknowledgment Number | 32b | No | Set by receiver, does not change mid-transit |
| Data Offset | 4b | No | Header length, constant |
| Reserved | 3b | No | Always 0 |
| Flags | 9b | No | SYN, ACK, FIN, etc. are fixed per segment |
| Window Size | 16b | No | Flow control; fixed in segment |
| Checksum | 16b | Recomputed if any field changes | Usually unchanged; only if network modifies bits (rare) |
| Urgent Pointer | 16b | No | Only used if URG flag set |
| Options | 0β40B | No | Usually unchanged |
| Data | Variable | No | Payload 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
| Field | Size | Changes During Transit? | Why / Notes |
|---|---|---|---|
| Version | 4b | No | Always 4 for IPv4 |
| IHL (Header Length) | 4b | No | Constant per packet |
| Type of Service / DSCP | 8b | Sometimes | Routers may set QoS bits for priority |
| Total Length | 16b | No | Includes header + payload; does not change |
| Identification | 16b | No | Same for all fragments |
| Flags | 3b | Fragmentation may set MF (More Fragments) | If packet fragmented |
| Fragment Offset | 13b | Changes if fragmented | Indicates position of fragment |
| TTL (Time To Live) | 8b | Decrements at each hop | Prevents loops; drops at 0 |
| Protocol | 8b | No | Identifies transport layer protocol (TCP=6) |
| Header Checksum | 16b | Recomputed at each hop | Because TTL changes, checksum changes |
| Source IP | 32b | No | Original sender IP |
| Destination IP | 32b | No | Final receiver IP |
| Options | variable | Rarely | Usually unchanged |
- Only ==TTL and Header Checksum== always change at routers. β
- Fragmentation fields (Flags, Fragment Offset) change only ==if packet is fragmented.==
Key Differences
| Feature | TCP Header | IP Header |
|---|---|---|
| Layer | Transport | Network |
| Size | 20β60B | 20B |
| Purpose | Reliability, sequencing, flow control | Routing, addressing |
| Key Field | Sequence Number, Window Size, Flags | Source IP, Destination IP, TTL |
| Affects | TCP Segment size, in-flight data | Packet routing, total packet size |
Field Changes during Transit
- Network (IP) β TTL, Checksum, Fragmentation fields may change. β
- Transport (TCP) β Usually nothing changes.
TCP Window Size vs Segment vs Packet vs Frame
Section titled βTCP Window Size vs Segment vs Packet vs Frameβ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 header3. 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 wireComparison Table
| Term | Size | Includes | Role | Relation to Window Size |
|---|---|---|---|---|
| TCP Window Size | Bytes | Only TCP payload | Max in-flight data | Controls throughput |
| TCP Segment | TCP payload + TCP header (20β60B) | TCP header + data | Transport unit | Must fit in window |
| IP Packet | Segment + IP header (20B) | TCP + IP headers + data | Network unit | Size affects MSS |
| Frame | Packet + Link header + trailer | TCP/IP headers + data + Link headers | Physical transmission | MTU 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
- Bit β Smallest unit of data (0 or 1).
- Byte β 8 bits.
- Segment (TCP Layer)
- Contains TCP header + application data.
- TCP header: 20β60 bytes.
- TCP segment = piece of application data ready to send.
- Packet (Network/IP Layer)
- TCP segment is wrapped in IP header β becomes packet.
- IP header: 20 bytes.
- Packet = TCP segment + IP header.
- 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.
- 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 mediumTCP 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 / 8Why Window Size Matters
- If TCP window < BDP:
- Sender stops after sending window-sized data, waits for ACK.
- Link capacity is not fully used β throughput < max bandwidth.
- If TCP window β₯ BDP:
- Sender continuously sends data β link is full β max throughput achieved.
Visualization:
Link capacity = pipeBDP = pipe volumeWindow size = amount sender can push into pipe at once
Window < BDP β pipe not full β wasted capacityWindow β₯ BDP β pipe full β maximum data in-flightRelationship 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 < BandwidthIf Window β₯ BDP β Throughput β BandwidthSummary Table
| Layer | Unit | Header | Content | In-Flight Control |
|---|---|---|---|---|
| Application | Data | - | User info | - |
| Transport | Segment | 20β60B | TCP header + Data | TCP Window |
| Network | Packet | 20B | IP header + Segment | - |
| Link | Frame | 14B+4B | Packet + Header + Trailer | - |
| Physical | Bits | - | Frame bits | Controlled indirectly by Window & BDP |