0% found this document useful (0 votes)
9 views23 pages

Lecture 18-TCP Segment Structure

The lecture covers the structure and functionality of TCP segments, highlighting key features such as connection-oriented communication, reliable data transfer, and flow control. It explains concepts like Maximum Segment Size (MSS), sequence and acknowledgment numbers, and the handling of out-of-order segments. Additionally, it discusses the importance of round trip time (RTT) and timeout settings in TCP communication.

Uploaded by

i232109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views23 pages

Lecture 18-TCP Segment Structure

The lecture covers the structure and functionality of TCP segments, highlighting key features such as connection-oriented communication, reliable data transfer, and flow control. It explains concepts like Maximum Segment Size (MSS), sequence and acknowledgment numbers, and the handling of out-of-order segments. Additionally, it discusses the importance of round trip time (RTT) and timeout settings in TCP communication.

Uploaded by

i232109
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 23

Lecture 18:TCP Segment Structure

National University of
Computer & Emerging
Sciences

Lecture 18
TCP Segment Structure
Dr. Asim

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure
TCP: Overview RFCs: 793,1122,1323, 2018,
2581

• point-to-point: • full duplex data:


– between a single sender – bi-directional data flow
and a single receiver in same connection
– the transfer of data from – MSS: maximum segment
one sender to many size
receivers in a single • connection-oriented:
send operation—is not – Three way handshaking
possible (exchange of control
• reliable, in-order byte msgs) inits sender,
stream: receiver state before
data exchange
• pipelined:
• flow controlled:
– TCP congestion and flow
– sender will not
control set window size
overwhelm receiver
Transport Layer 3-2

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

MSS and MTU


• The maximum amount of data in a segment is limited by
the maximum segment size (MSS).
• The MSS is typically set by first determining (the so-
called maximum transmission unit, MTU)

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

MSS and MTU


MSS+ TCP/IP header when encapsulated in an IP datagram) will fit into a
single link-layer frame.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

MSS and MTU


• The MSS limits the maximum size of a segment’s data field
• It is more or less a physical limit
• It is specified for each link separately
• MTU reduction can occur elsewhere in the communication path

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

TCP Send/Receive buffers


• The client process passes a stream of data through the socket.
• Once the data passes through the Socket, the data is in the hands of TCP
running in the client.
• TCP directs this data to the connection’s send buffer, which is one of the
buffers that is set aside during the initial three-way handshake.
• From time to time, TCP will grab chunks of data from the send buffer and
pass the data to the network layer.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

TCP connection

• TCP connection consists of


– Buffers and variables
– a socket connection to a process in one host, and
another set of buffers, variables, and a socket
connection to a process in another host.

• Nothing is stored in the network elements


(routers, switches, and repeaters) between the
hosts.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure
TCP segment structure
32 bits
URG: urgent data counting
(generally not used) source port # dest port #
by bytes
sequence number of data
ACK: ACK #
valid acknowledgement number (not segments!)
head not U A P R S F
PSH: push data now len used
receive window
(generally not used) # bytes
checksum Urg data pointer
rcvr willing
RST, SYN, FIN: to accept
options (variable length)
connection estab
(setup, teardown
commands)
application
Internet data
checksum (variable length)
(as in UDP)

Transport Layer 3-8

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

TCP segment structure (Flags)


PUSH Flag
•The sending application informs TCP that data should be sent
immediately.
•The PSH flag in the TCP header informs the receiving host that
the data should be pushed up to the receiving application
immediately.

Urgent Data
– DEL or CTRL-C to break off a remote computation
– Use URGENT flag – Transmit everything right now
• Receiving application is interrupted

(see notes pane for details)


FAST, National University of Computer and Emerging Sciences, Islamabad
Lecture 18:TCP Segment Structure

Sequence Numbers

• TCP views data as an unstructured, but


ordered, stream of bytes.

• Sequence numbers are over the stream of


transmitted bytes and not over the series
of transmitted segments.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

TCP Sequence Numbers

• The sequence number for a segment is


therefore the byte-stream number of the
first byte in the segment.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

An example

• A process in Host A wants to send a stream of


data to a process in Host B.

• The TCP in Host A will implicitly number each


byte in the data stream.
– For a file consisting of 500,000 bytes,
– MSS being 1,000 bytes, and that the first byte of the
data stream is numbered 0.
– TCP constructs 500 segments out of the data stream.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

TCP Sequence Numbers

The first segment gets assigned sequence number 0, the second segment gets

assigned sequence number 1,000, the third segment gets assigned sequence

number 2,000, and so on.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

Full duplex

• TCP is full-duplex, so that Host A may be


receiving data from Host B while it sends data to
Host B (as part of the same TCP connection).

Data for B

A Data for A ACK B

ACK

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

Acknowledgment numbers

• A sends a segment to B, what would B put in the


Ack sequence number in the next segment it
sends to A?
– next byte Host B is expecting from Host A.

• A sends a segment to B, what would A put in the


Ack sequence number in the next segment it
sends to B?
– next byte Host A is expecting from Host B.

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

An example

• Host A has received all bytes numbered 0


through 535 from B.
• Host A is waiting for byte 536 and all the
subsequent bytes in Host B’s data stream.

• What does Host A put in the acknowledgment


number field of the next segment it sends to B?

Host A puts 536 in the acknowledgment number


field of the segment it sends to B
FAST, National University of Computer and Emerging Sciences, Islamabad
Lecture 18:TCP Segment Structure

Another example

• Host A has received all bytes numbered 0


through 535 from B.
• Host A has also received another segment
containing bytes 900 through 1,000
– For some reason Host A has not yet received bytes
536 through 899.

• What does Host A put in the acknowledgment


number field of the next segment it sends to B?
A’s next segment to B will contain 536 in the acknowledgment
number field
FAST, National University of Computer and Emerging Sciences, Islamabad
Lecture 18:TCP Segment Structure

Out of order segments

• TCP only acknowledges bytes up to the first


missing byte in the stream, TCP is said to
provide cumulative acknowledgments.

• For out of order segments it can either discard


them or buffer them (the approach actually taken
in practice)

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

The seg/ack numbers base

• we assumed that the initial sequence


number was zero.
• In truth, both sides of a TCP connection
randomly choose an initial sequence
number.

• Why?

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure
TCP seq. numbers, ACKs
Starting Sequence: 42
Host A Host B
Starting Sequence: 79

User
types
‘C’
Seq=42, ACK=79, data = ‘C’
host ACKs
receipt of
‘C’, echoes
Seq=79, ACK=43, data = ‘C’ back ‘C’
host ACKs
receipt
of echoed
‘C’ Seq=43, ACK=80

simple telnet scenario

Transport Layer 3-20

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

TCP round trip time, timeout

Q: how to set TCP Q: how to estimate RTT?


timeout value? • SampleRTT: measured time
from segment transmission
• longer than RTT
until ACK receipt
– but RTT varies
– ignore retransmissions
• too short: premature • SampleRTT will vary, want
timeout, unnecessary estimated RTT “smoother”
retransmissions – average several recent
• too long: slow reaction measurements, not just
to segment loss current SampleRTT

Transport Layer 3-21

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

TCP round trip time, timeout

• timeout interval: EstimatedRTT plus “safety margin”


– large variation in EstimatedRTT -> larger safety margin
• estimate SampleRTT deviation from EstimatedRTT:

DevRTT = (1-)*DevRTT +
*|SampleRTT-EstimatedRTT|
(typically,  = 0.25)

TimeoutInterval = EstimatedRTT + 4*DevRTT

estimated RTT “safety margin”

Transport Layer 3-22

FAST, National University of Computer and Emerging Sciences, Islamabad


Lecture 18:TCP Segment Structure

Computer Networking: A Top Down Approach


6th edition
Jim Kurose, Keith Ross
Addison-Wesley
March 2012

A note on the origin of these ppt slides:


These slides are freely provided by the book authors and it represents a lot of work on their part.
We would like to thank J.F Kurose and K.W. Ross.

FAST, National University of Computer and Emerging Sciences, Islamabad

You might also like