More on TCP Acknowledgements
Sequence Number Field
Initial Sequence Number
Acknowledgement Number Field
TCP
• TCP is Reliable
– IP packets carrying TCP segments may arrive out of order
– TCP must put the TCP segments in order
3 4 2 15
TCP
• TCP is Reliable
– Each correct TCP segment is acknowledged by the receiver
SourceTransportProcess
SourceTransportProcess
DestinationTransportProcess
DestinationTransportProcess
TCP SegmentTCP Segment
ACKACK
TCP Segment• Each TCP segment sent by a side must
have a sequence number
– Simplest: 1,2,3,4,5,6,7
– To detect lost or out-of-sequence messages
– TCP uses a more complex approach
11 44 22 55
3?
TCP Sequence Numbers
• TCP header has a 32-bit sequence number field
Source Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len(4) Flags (6) Window Size (16)
Options (if any) PAD
Reserved (6)
TCP Checksum (16) Urgent Pointer (16)
Data Field
TCP Sequence Numbers
• Initial Sequence Number is randomly selected by the sender; Say, 79
• Sent in the sequence number field of the first TCP segment
79
TCP Data Field
TCP Header
Sequence Number Fieldwith Initial Sequence Number (79)
TCP Sequence Numbers• Data octets in data fields of all segments in a
connection are viewed as a long string
• TCP Segment 1 79• TCP Segment 2 80
8182
• TCP Segment 3 8384
3 Octets in Data Field
2 Octets in Data Field
ISN
TCP Sequence Numbers
• Supervisory segments, which contain a header but no data, are treated as carrying a single octet of data
• TCP seg 1 898899
• TCP seg 2 900• TCP seg 3 901
902…
Supervisory segment
Carries data
Carries data
TCP Sequence Numbers• Sequence number field gets the value of the
first octet in the data field• TCP 1 79• TCP 2 80
8182
• TCP 3 8384
80 is SeqNum Field Value
83 is SeqNum Field Value
79 is SeqNum Field Value
TCP Acknowledgements
• Acknowledgement must indicate which TCP segment is being acknowledged
SourceTCP
Process
SourceTCP
Process
DestinationTCP
Process
DestinationTCP
Process
TCP SegmentTCP Segment
ACKACK
TCP Acknowledgements
• TCP header contains a 32-bit Acknowledgement Number field to designate the TCP segment being acknowledgedSource Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len(4) Flags (6) Window Size (16)
Options (if any) PAD
Reserved (6)
TCP Checksum (16) Urgent Pointer (16)
Data Field
TCP Acknowledgment Numbers
• Acknowledgement Number field contains the next byte expected--the last byte of the segment being acknowledged, plus one
• TCP 1 79
• TCP 2 808182
• TCP 3 8384
83 is AckNum Field Value
85 is AckNum Field Value
80 is AckNum Field Value
TCP Acknowledgement Number
• Quiz: A TCP segment contains the following data octets– 567, 568, 569, 570, 571, 572, 573, 574
• What will be in the sequence number field of the TCP segment delivering the data?
• What will be in the acknowledgement number field of the TCP segment acknowledging the TCP segment that delivers these octets?
TCP Flow Control
• Flow Control– One TCP process transmits too fast– Other TCP process is overwhelmed– Receiver must control transmission rate– This is flow control
TCP Process TCP Process
Too MuchData
Flow Control Message
TCP Flow Control
• A TCP segment has a Window Size field– Used in acknowledgements
Source Port # (16) Destination Port # (16)
Sequence Number (32 bits)
Acknowledgement Number (32 bits)
Hdr Len(4) Flags (6) Window Size (16)
Options (if any) PAD
Reserved (6)
TCP Checksum (16) Urgent Pointer (16)
Data Field
TCP Flow Control
• A TCP segment has a Window Size field– Tell how many more octets the sender can send
beyond the segment being acknowledged
TCP Process TCP Process
Data
Acknowledgement with Window Size Field
TCP Flow Control
• Example– TCP segment contained octets 45-89– Acknowledgement number for TCP segment
acknowledging the segment is 90– If Window Size field value is 50, then– Sender may send through octet 140– Must then stop unless the window has been
extended in another acknowledgement
TCP Flow Control
• Each Acknowledgement extends the window of octets that may be sent– Called a sliding window protocol
1-44 45-79 80-419 420-630
400May send through 480
1-44 45-79 80-419 420-630
500May send through 920
TCP Fragmentation• TCP Segments have maximum data field
sizes– (Size limit details are discussed later)– What if an application layer message is too
large?
TCP HeaderTCP Data Field Max
Application Layer Message
TCP Fragmentation
• Application layer message must be fragmented– Broken into several pieces– Delivered in separate TCP segments
TCP HeaderTCP Data Field Max
App Frag 1 App Frag 2 App Frag 3
TCP Fragmentation
• Note that, in TCP fragmentation, the TCP segment is NOT fragmented– The application layer message is fragmented
TCP HeaderTCP Data Field Max
App Frag 1 App Frag 2 App Frag 3
TCP Fragmentation• Transport layer process on the source
host does the fragmentation– Application layer on the source host is not
involved– Transparent to the application layer
Application
Transport
Internet
Application Message
TCP Segment TCP Segment
TCP Fragmentation• Transport layer process on the
destination host does the reassembly– Application layer on the destination host is
not involved; Gets original application layer message
Application
Transport
Internet
Application Message
TCP Segment TCP Segment
TCP Fragmentation
• What is the maximum TCP data field size?– Complex
• Maximum Segment Size (MSS)– Maximum size of a TCP segment’s data field– NOT maximum size of the segment as its name
would suggest!!!
TCP Fragmentation• MSS Default is 536 octets
– Minimum IP packet size any network must support is 576 octets
• Larger IP packets MAY be fragmented
– IP and TCP headers are 20 octets each if there are no options
– This gives the default MSS of 536
– Smaller if there are options in the IP or TCP header
TCP Fragmentation• MSS Default is 536 octets
– Suppose the application layer process is 1,000 octets long
– Two TCP segments will be needed to send the data
– The first can send the first 536 octets
– The second can carry the remaining 464 octets of the application layer message
TCP Fragmentation
• Each side MAY announce a larger MSS
– An option usually used in the initial SYN message it sends to the other
– If announces MSS of 2,048, this many octets of data may be sent in each TCP segments
– 536 is only the default—the value to use if no other value is specified by the other side
Top Related