0% found this document useful (0 votes)
24 views46 pages

ch12 TCP

Uploaded by

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

ch12 TCP

Uploaded by

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

Transmission Control Protocol

Outline:
Transmission Control Protocol (Part I)
• Connection-Oriented • Connections, Ports,
Transport and Endpoints
• Reliable Delivery Service • Passive and Active Opens
• Providing Reliability • Window Advertisement
• Retransmission Schemes • TCP Segment Format
• Sliding Window Protocols • Maximum Segment Size
– Sliding Window Control • TCP Header Checksum
• Transmission Control • TCP Pseudo-Header
Protocol • TCP Input and Output
Connection-Oriented Transport:

• Transmission Control Protocol (TCP):


– Is an independent, reliable-delivery, general
purpose transport protocol used in the TCP/IP
protocol suite or for use with other delivery
systems.
Reliable Delivery Service:

• Features of the interface between application


programs and the TCP/IP reliable delivery service
include:
– Stream Orientation - data is considered as a
bitstream divided into bytes.
– Buffered Transfer - transport mechanisms
buffer application data until it can fill a
reasonably large datagram, using PUSH for
immediate transfer.
Reliable Delivery Service:

– Virtual Circuit Connection - applications view


the delivery service as a dedicated hardware
circuit.
– Unstructured Stream - applications must
understand the streams content.
– Full-Duplex Connection - simultaneous
transmission in both directions; without
simultaneous connection release (half-duplex).
Providing Reliability:

• Sending positive acknowledgments (ACKs) with


retransmission is a fundamental technique used to
provide reliable transfer.
• A timer is started during each transmission and if
it expires, the message is then retransmitted.
• A combination of several timers are all used to
provide a reliable delivery system.
Events At Network Messages Events At
Sender Site Receiver Site

Send Packet 1
Receive Packet 1
Send ACK 1
Receive ACK 1
Send Packet 2
Receive Packet 2
Send ACK 2
Receive ACK 2
Providing Reliability:

• To avoid confusion over delayed or duplicate


ACKs, positive ACK protocols use sequence
numbers with ACK messages to correctly
associate acknowledgments with packets.
• These sequence numbers can be unique at each
side, and are established at connection setup time.
Events At Network Messages Events At
Sender Site Receiver Site
Send Packet 1 Packet lost
Start Timer
Packet should arrive
ACK would normally ACK should be sent
arrive at this time
Timer Expires
Retransmit Packet 1
Start Timer

Receive Packet 1
Send ACK 1
Receive ACK 1
Cancel Timer
Retransmission Schemes:
• There are three main classes of retransmission
schemes:
– Stop and Wait protocols (previous illustration)
which are not bandwidth efficient.
– Go-Back-N protocols which retransmit all
packets that follow a single erred packet.
– Selective Retransmission protocols which only
retransmit erred packets using ACKs and
NAKs (TCP).
Sliding Window Protocols:

• Sliding Window Protocols:


– Used in TCP to make the transmission stream
efficient
– Keep track of many acknowledged and un-
acknowledged packets, instead of one at a time.
Sliding Window Protocols:

• Sliding window protocols:


– Use network bandwidth better because they
allow the sender to transmit multiple packets
before waiting on each ACK.
– Transmit all packets in the window and slide it
forward for each ACK received.
Sliding Window Protocols:

• Unacknowledged packets are constrained by the


windows size (limited to a small fixed number).
• Sliding window performance depends upon the
window size and speed the destination processes
the packets.
• Well tuned sliding window protocols keep the
network saturated with packets (zero idle time).
Three sets of sequenced packets
in the sliding window:

Successfully Being Not Yet


Transmitted Transmitted Transmitted
(received and
acknowledged)
Events At Events At
Sender Site Network Messages Receiver Site
Send Packet 1
Receive Packet 1
Send Packet 2
Send ACK 1
Send Packet 3 Receive Packet 2
Send ACK 2
Receive ACK 1 Receive Packet 3
Send ACK 3
Receive ACK 2

Receive ACK 3
Transmission Control Protocol:

• Transmission Control Protocol - defines the


reliable stream service of the TCP/IP protocol
suite.
• TCP is a protocol, not a piece of software! An
implementation of TCP is not the standard.
Transmission Control Protocol:

• TCP defines:
– Format of the data and acknowledgments.
– Procedures for hosts to ensure reliable
transmission.
– Connection establishment and release.
– How to distinguish between multiple
destinations on a given machine.
Connections, Ports,
and Endpoints:
• Unlike UDP, TCP does not use a port number to
connect to a single object.
• TCP uses the connection in its entirety as it’s
fundamental abstraction.
Connections, Ports,
and Endpoints:
• Connections are identified by a pair of endpoints.
• Endpoints are a pair of integers (HOST, PORT),
where:
– HOST is the host’s IP address.
– PORT is the TCP protocol port on that host.
Connections, Ports,
and Endpoints:
• Ex:
– MIT (18.26.0.36, 1069) to
– Purdue (128.10.2.3, 25)
– CMU (128.2.254.139, 1184) to
– Purdue (128.10.2.3, 25)
• TCP port numbers can be shared by multiple
connections on the same machine because each
connection is identified by a pair of end points.
Passive and Active Opens:

• Passive Open - function performed by an


application program to inform the operating
system it can accept connections.
• Active Open - function performed by an
application program to inform the operating
system it want to initiate a connection.
Passive and Active Opens:

• A segment is TCP’s unit of transfer.


• Ideally, each segment travels in a single IP
datagram.
• TCP uses a special sliding window to ensure
efficient transmission and handle flow control.
• It operates at the octet level, using three pointers
for every connection.
Passive and Active Opens:
Sliding Window Control:

Sent and Sent & Not To be Sent Not Yet


ACKed Yet ACKed Generated
(waiting for
window slide)
Passive and Active Opens:

• A window for data being sent and data being


received exists at each end.
• Four windows exist in total for each connection.
• TCP allows the window size to vary over time.
Window Advertisement:

• Window Advertisement - included with each


ACK, specifies the number of additional octets the
receiver can accept and is prepared to do so.
• TCP uses the window advertisement feature to
handle end-to-end flow control, but it cannot
explicitly solve a congestion problem.
0 4 10 16 24 31
SOURCE PORT DESTINATION PORT

SEQUENCE NUMBER

ACKNOWLEDGEMENT NUMBER

HLEN RESERVED CODE BITS WINDOW

CHECKSUM URGENT POINTER

OPTIONS (IF ANY) PADDING

DATA

...
TCP Segment Format:

• SOURCE PORT (16-bits):


– Identify source application end-points.
• DESTINATION PORTS (16-bits):
– Identify destination application end-points.
• SEQUENCE NUMBER (32-bits):
– Order in the data stream of the first byte in the
data field.
• RESERVED (6-bits): - Self explanatory.
TCP Segment Format:

• ACKNOWLEDGEMENT NUMBER (32-bits):


– Specifies which octet the sender expects to
receive next.
• HLEN (4-bits):
– The length of segment header in 32-bit words.
• CODE BITS (6-bits):
– Determines how to interpret the other header
fields.
TCP Segment Format:

• Code-Bit Bit Position:


– URG - Urgent pointer field is valid.
– ACK - Acknowledgement field is valid.
– PSH - This segment requests a push action.
– RST - Reset the connection.
– SYN - Synchronize sequence numbers.
– FIN - Sender has reached the end of it’s byte
stream.
0 4 10 16 24 31
SOURCE PORT DESTINATION PORT

SEQUENCE NUMBER

ACKNOWLEDGEMENT NUMBER

HLEN RESERVED CODE BITS WINDOW

CHECKSUM URGENT POINTER

OPTIONS (IF ANY) PADDING

DATA

...
TCP Segment Format:

• WINDOW (16-bits):
– The number of bytes the receiver is willing to
accept (remote buffer size available).
• URGENT POINTER (16-bits):
– The offset to be added with the sequence
number field to yield the sequence number of
the last byte of urgent data (i.e. interrupts or
aborts).
TCP Segment Format:

• URGENT POINTER (continued):


– This accommodates out-of-band signaling.
• TCP goes into “urgent mode” when important data
arrives regardless of it’s position in the octet
stream.
• The URG code bit must be set to utilized the
urgent pointer and out-of-band signaling..
0 4 10 16 24 31
SOURCE PORT DESTINATION PORT

SEQUENCE NUMBER

ACKNOWLEDGEMENT NUMBER

HLEN RESERVED CODE BITS WINDOW

CHECKSUM URGENT POINTER

OPTIONS (IF ANY) PADDING

DATA

...
TCP Segment Format:

• OPTIONS (variable length):


– Each option field begins with an 8-bit (1 byte)
field KIND that specifies the option type.
• PADDING (variable length):
– Header area used to compensate for variable
length option fields.
• DATA (variable length):
– Data passed from application layer protocols.
Maximum Segment Size:

• Maximum Segment Size (MSS):


– Option is used to allow computers to limit the
segment sizes appropriate to the size of their
available buffer space.
– It is important to select a MSS that will fill
packets, making good use of available
bandwidth.
Maximum Segment Size:

• Standard MSS = 536


• IP datagram standard = 576
• This allows 20 bytes for the IP header and the
TCP header.
Optimum Segment Size:

• Optimum segment size is difficult to find because:


– TCP doesn’t include a mechanism for doing so.
– Gateways dynamically change routes which
usually have different MTU sizes.
– Size depends on lower-level protocol headers
and must be reduced accordingly.
TCP Header Checksum:

• Checksum - like UDP, TCP also uses a pseudo-


header when computing the checksum, verifying
data and the TCP header integrity.
• The checksum algorithm uses a 16-bit arithmetic
and takes the one’s complement of the one’s
complement sum.
TCP Header Checksum:

• When IP receives a datagram destined for TCP:


– It must pass to it the source and destination IP
addresses, so TCP can recompute the checksum
(pseudo-header fields).
– This scenario also violates our layered
abstraction concept and the independent
functionality of each layer.
TCP Pseudo-Header:

• TCP Pseudo-Header:
– Used to verify that the TCP segment has
reached it’s correct destination (since TCP
headers only use port numbers).
• A checksum is computed over the pseudo-header,
TCP-header, and the data area before sending each
segment.
TCP Pseudo-Header:

0 8 16 31
SOURCE IP ADDRESS
DESTINATION IP ADDRESS
PADDING PROTOCOL TCP LENGTH
TCP Pseudo-Header:

• The twelve octets of the pseudo-header include the


fields:
– Source IP address (4-octets).
– Destination IP address (4-octets).
– Padding field filled with zeros (1-octet).
– Protocol Type (1-octet), TCP = 6.
TCP Pseudo-Header:

– TCP Length (2-octets)


• Length of the TCP segment without the
pseudo-header.
• These values are extracted from the IP datagram
header, then the checksum is recomputed (using
this pseudo-header).
• TCP as well as UDP violates the protocol
boundary between it and the IP (Internet) Layer.
TCP Input and Output:
• TCP has complex input and output modules since
it is connection-oriented.
• TCP, similar to UDP, has separate modules to
handle the processing required for each I/O
operation, as well as input and output queues.
• There are two output sub-modules, TCP Process
and TCP Timer, which communicate using control
messages and provide a reliable communication
service.
TCP input

application programs
Ports operating system
for TCP
segments

TCP Input
Process
TCP output application programs UDP
operating system output

Control
messages

port for TCP output

TCP TCP
queue for datagrams
Timer Process sent to IP

You might also like