0% found this document useful (0 votes)
16 views

Mod5.Tcp & Udp

Uploaded by

rithualex
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Mod5.Tcp & Udp

Uploaded by

rithualex
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 114

Module 5-Transport Layer

Transport Layer

• It is the heart of the whole protocol hierarchy.

• Its task is to provide reliable, cost-effective data transport from the


source machine to the destination machine, independently of the
physical network or networks currently in use.

• The transport layer is responsible for process-to-process delivery


The Transport Service
• Defines what kind of service is provided to the application layer
• Provides Two types of transport services:

1. connection-oriented transport service using TCP


2. connectionless transport service using UDP
• Both are similar to Network layer services
• But difference is
• transport code runs entirely on the users' machines,
• but the network layer mostly runs on the routers, which are operated by the
carrier
Services Provided to the Upper Layers
• The ultimate goal of the transport layer is to provide efficient, reliable, and cost-
effective service to its users, normally processes in the application layer.

• To achieve this goal, the transport layer makes use of the services provided by the
network layer.

• The hardware and/or software within the transport layer that does the work is
called the transport entity.

• The transport entity can be located in the operating system kernel, in a separate
user process, in a library package bound into network applications, or conceivably
on the network interface card
Services Provided to the Upper Layers
• The connection-oriented transport service is similar to the connection-oriented
network service in many ways.
• In both cases, connections have three phases: establishment, data transfer, and
release.
• Addressing and flow control are also similar in both layers.
• Furthermore, the connectionless transport service is also very similar to the
connectionless network service.
• But, the users have no real control over the network layer, so they cannot solve
the problem of poor service
• In essence, the existence of the transport layer makes it possible for the
transport service to be more reliable than the underlying network service.
The (logical) relationship of the network, transport, and
application layers
TPDU (Transport Protocol Data Unit)
• TPDU (Transport Protocol Data Unit) –term used for messages sent from
transport entity to transport entity.
• Thus, TPDUs (exchanged by the transport layer) are contained in packets
(exchanged by the network layer).
• In turn, packets are contained in frames (exchanged by the data link
layer).
• When a frame arrives, the data link layer processes the frame header and
passes the contents of the frame payload field up to the network entity.
• The network entity processes the packet header and passes the contents
of the packet payload up to the transport entity(TE).
Nesting of TPDUs, packets, and frames
Transport Service Primitives
• Transport Service Primitives allow transport users (application programs) to
access the transport service.

• The following are the primitives for a simple transport service


Service primitive example
• Eg: Consider an application with a server and a number of remote clients.
1. The server executes a “LISTEN” primitive by calling a library procedure that
makes a System call to block the server until a client turns up.
2. When a client wants to talk to the server, it executes a “CONNECT” primitive,
with “CONNECTION REQUEST” TPDU sent to the server.
3. When it arrives, the TE unblocks the server and sends a “CONNECTION
ACCEPTED” TPDU back to the client.
4. When it arrives, the client is unblocked and the connection is established. Data
can now be exchanged using “SEND” and “RECEIVE” primitives.
Service primitive example
5. When a connection is no longer needed, it must be released to free up table
space within the 2 transport entries, which is done with “DISCONNECT” primitive
by sending “DISCONNECTION REQUEST” TPDU.

• This disconnection can be done either by asymmetric variant (connection is


released, depending on other one) or by symmetric variant (connection is
released, independent of other one).
Primitives are widely used for Internet programming
Addressing

• Whenever we need to deliver something to one specific destination among many,


we need an address.
• At the data link layer, we need a MAC address to choose one node among several
nodes if the connection is not point-to-point.
• At the network layer, we need an IP address to choose one host among millions.
• At the transport layer, we need a transport layer address, called a port number,
to choose among multiple processes running on the destination host
• In the TCP/IP protocol suite, the port numbers are integers between 0 and 65,535
(16 bits).
• TCP/IP has decided to use universal port numbers for servers; these are called
well-known port numbers.
• Every client process knows the well-known port number of the corresponding
server process
Types of ports
• Internet Corporation for Assigned Names and Numbers (ICANN) divided the port
numbers into three ranges

1. Well-known ports - The ports ranging from 0 to 1,023

2. Registered ports - The ports ranging from 1,024 to 49,151

3. Dynamic ports - The ports ranging from 49,152 to 65,535


Types of ports
• Well-known ports –
• The ports ranging from 0 to 1,023 are assigned and controlled by ICANN.
• These are the well-known ports.
• Registered ports –
• The ports ranging from 1,024 to 49,151 are not assigned or controlled by
ICANN.
• They can only be registered with ICANN to prevent duplication.
• Dynamic ports –
• The ports ranging from 49,152 to 65,535 are neither controlled nor
registered.
• They can be used as temporary or private port numbers.
Well-known ports used with UDP
Socket Addresses

• A transport-layer protocol in the TCP suite needs both the IP address and the port
number, at each end, to make a connection.
• The combination of an IP address and a port number is called a socket address.
• The client socket address defines the client process uniquely and server socket
address defines the server process uniquely.
Transport layer protocols
• The Internet has two main protocols in the transport layer, a connectionless

protocol and a connection-oriented one.

• The connectionless protocol is UDP.

• The connection-oriented protocol is TCP.


Position of TCP and UDP in TCP/IP Protocol Suite
UDP (User Datagram Protocol )
• The User Datagram Protocol (UDP) is a connectionless, unreliable transport protocol.
• UDP is a very simple protocol using a minimum of overhead.
• If a process wants to send a small message and does not care much about reliability, it
can use UDP.
• There is no flow control and hence no window mechanism.
• There is no error control mechanism in UDP except for the checksum
• Sending a small message using UDP takes much less interaction between the sender
and receiver than using TCP.
• UDP packets, called user datagrams
• To send a message from one process to another, the UDP protocol encapsulates and
decapsulates messages in an IP datagram
• In UDP, queues are associated with ports
• UDP doesn’t ensure orderly arrival of data
UDP advantages(Uses)
• Protocol with less overhead
• Sending a message using UDP requires less interaction between sender and
receiver
• UDP is suitable for a process that requires simple request-response
communication with little concern for flow and error control.
• UDP is suitable for a process with internal flow and error control mechanisms.
• Convenient protocol for multimedia and multicasting applications
• Used in some route updating protocols like RIP(routing information protocol)
• Used in SNMP(Simple Network Management Protocol)

21
UDP Format

• UDP transmits datagrams consisting of an 8-byte header followed by the payload


UDP Format
• Source port, destination port:

Source port-This is the port number used by the process running on the source
host. It is 16 bits long, which means that the port number can range from 0 to
65,535.

Destination port-This is the port number used by the process running on the
destination host. It is also 16 bits long. If the destination host is the server (a
client sending a request), the port number, in most cases, is a well-known port
number.
UDP Format
• UDP length:

• It is a 16-bit field that defines the total length of the user datagram, header
plus data.
• We can deduce the length of a UDP datagram that is encapsulated in an IP
datagram.

UDP length = IP length - IP header's length

• UDP checksum:

• It is an optional field used for error detection


Checksum
• Here the checksum includes three sections: a pseudoheader, the
UDP header, and the data coming from the application layer.
• The pseudo header is the part of the header of the IP packet in
which the user datagram is to be encapsulated with some fields
filled with Os
TRANSMISSION CONTROL PROTOCOL (TCP)
• TCP stands for Transmission Control Protocol.

• It is a transport layer protocol that facilitates the transmission of packets from


source to destination.

• It is a connection-oriented protocol that means it establishes the connection prior


to the communication that occurs between the computing devices in a network.

• This protocol is used with an IP protocol, so together, they are referred to as a


TCP/IP.
TCP Services
□ TCP provides services to the processes at the
application layer
■ Process-to-Process Communication
■ Stream Delivery Service
■ Full-Duplex Service
■ Connection-Oriented Service
■ Reliable Service
Process-to-Process Communication

□ Like UDP, TCP provides process-to-process


communication using port numbers
□ Client’s port number
■ Chosen randomly by the TCP software running on the
local host
■ Called ephemeral port number
□ Server’s port number
■ Define itself with a port number
■ Called well-known port numbers
Figure 12-3

Port Numbers

The McGraw-Hill Companies, Inc.,


2000
Well-Know Ports Used by TCP
Port Protocol Description
7 Echo Echoes a received datagram back to
the sender
9 Discard Discards any datagram that is received
11 Users Active users
13 Daytimes Return the data and the time
17 Quote Return a quote of the day
19 Chargen Return a string of characters
20 FTP, Data File Transfer Protocol (data connection)
21 FTP, Data File Transfer Protocol (control connection)
Well-Know Ports Used by TCP
Port Protocol Description
23 Telnet Terminal Network
25 SMTP Simple Mail Transfer Protocol
53 DNS Simple Mail Transfer Protocol
67 BOOTP Bootstrap
79 Finger Finger
80 HTTP Hypertext Transfer Protocol
111 RPC Remote Protocol Call
igure 12-4

Stream Delivery

The McGraw-Hill Companies, Inc.,


2000
Stream Delivery Service (Cont.)
□ However, the sending and receiving speed may
not be the same
■ TCP needs buffers for storage
□ Two buffers in TCP
■ Sending buffer and receiving buffer, one for each
connection
■ Also used in flow and error-control mechanisms
Figure 12-5

Sending and Receiving Buffers

The McGraw-Hill Companies, Inc.,


2000
Sending Buffers
□ The sending circular buffer has three types of sections
■ White section: empty location
□ Can be filled by the sending process
■ Gray section: hold bytes that have been sent but not yet
acknowledged
□ TCP keeps these bytes until it receives acknowledges
■ Color section: bytes to be sent by the sending TCP
□ TCP may be able to send only part of this colored section
■ The slowness of the receiving process
■ The congestion in the network
Receiving Buffer
□ The receiving circular buffer is divided into
two areas
■ White area:
□ Empty locations to be filled

■ Colored area:
□ Contain received bytes that can be consumed by the
receiving process
Segments
□ TCP groups a number of bytes together into a packet
called a segment
■ A TCP packet is called a segment
■ TCP adds a header to each segment
■ Then, the segments are encapsulated in an IP datagram
□ Note: terms
■ UDP Datagram, TCP Segment
■ IP Datagram
■ MAC Frame
Figure 12-6

TCP Segments

The McGraw-Hill Companies, Inc.,


2000
Full-Duplex Communication
□ TCP offers full-duplex service
■ Data can flow in both directions at the same time

■ Each TCP has a sending and receiving buffer and


segments are sent in both direction
Connection-Oriented Service
□ TCP is a connection-oriented protocol
■ However, the connection is virtual, not a physical
connection

■ Each TCP segment may use a different path to


reach the destination
Reliable Service
□ TCP uses an acknowledge mechanism to
check the safe and sound arrival of data
Features of TCP protocol

• Numbering System
• Flow Control
• Error Control
• Congestion Control
Features of TCP protocol

Numbering System
□ Although TCP use segments for transmission and reception
■ There is no field for a segment number in the segment header, i.e., TCP
header
□ TCP uses sequence number and acknowledgement number to keep
track of the segment being transmitted or received
■ Notably, these two fields refer to the byte number, not the
segment number
□ Byte Number-TCP numbers all data bytes that are transmitted in a
connection
□ The numbering does not necessarily start from 0
■ It starts randomly ie between 0 and 2^32 – 1 for the number of the first byte
■ Byte numbering is used for flow and error control
Features of TCP protocol

 Sequence Number

□ TCP assigns a sequence number to each segment that is being sent

□ The sequence number for each segment is the number of the first byte carried in
that segment
□ Eg.
•Suppose a TCP connection is transferring a file of 5000 bytes. The first byte is

numbered 10001. What are the sequence numbers for each segment if data is
sent in five segments, each carrying 1000 bytes?
Solution
• The following list shows the sequence
number for each segment:
Segment 1 ➡ Sequence Number: 10,001 (range: 10,001 to 11,000)
Segment 2 ➡ Sequence Number: 11,001 (range: 11,001 to 12,000)
Segment 3 ➡ Sequence Number: 12,001 (range: 12,001 to 13,000)
Segment 4 ➡ Sequence Number: 13,001 (range: 13,001 to 14,000)
Segment 5 ➡ Sequence Number: 14,001 (range: 14,001 to 15,000)
Example

□ Imagine a TCP connection is transferring a


file of 6000 bytes.
■ The first byte is numbered 10010

□ What are the sequence numbers for each


segment if data is sent in five segments with
■ The first four segments carrying 1,000 bytes
■ The last segment carrying 2,000 bytes?
Solution

The following shows the sequence


number for each segment:
Segment 1 🡺 10,010 (10,010 to 11,009)
Segment 2 🡺 11,010 (11,010 to 12,009)
Segment 3 🡺 12,010 (12,010 to 13,009)
Segment 4 🡺 13,010 (13,010 to 14,009)
Segment 5 🡺 14,010 (14,010 to 16,009)
The McGraw-Hill Companies, Inc.,
2000
Acknowledgment Number
□ Each party numbers the bytes, usually with a different starting byte
number
■ Sequence number: the number of the first byte carried by the
segment
■ Acknowledgment number: the number of the next byte that the party
expects to receive
□ Acknowledgment number is cumulative
□ For example, if a party uses 5,643 as an acknowledgment number
■ It has received all bytes from the beginning up to 5,642
■ Note that, this does not mean that the party has received 5642 bytes
□ The first byte number does not have to start from 0
Flow Control
□ The receiver controls how much data are to be sent by the
sender
■ Prevent the receiver from being overwhelmed with data

□ The numbering system allow TCP to use a


byte-oriented flow control
Error Control
□ TCP implements an error control mechanism
■ To provide reliable service

■ Also byte-oriented
Congestion Control
□ TCP takes into account congestion in the
network

□ Thus, the amount of data sent by a sender is


controlled both by
■ The receiver (flow control)
■ The level of congestion in the network
TCP Segment Format
• Every segment begins with a fixed-format, 20-byte
header.
• The fixed header may be followed by header options
• Segments without any data are legal and are commonly
used for Acknowledgements and control messages.

52
TCP segment format

53
The TCP Segment Header
• Source Port, Destination Port : Identify local end points of the connections
• Sequence number: Specifies the sequence number of the segment
• The first byte number in this segment
• In connection establishment, each party randomly generate an initial sequence
number (ISN)
• Acknowledgement Number: Specifies the next byte expected.
• TCP header length: Tells how many 32-bit words are contained in TCP header
■ Value of this field is between 5 and 15
□ TCP header is between 20-60 bytes
• Next comes a 6-bit field that is not used.
• Now comes six 1-bit flags
54
The TCP Segment Header
• URG: It is set to 1 if URGENT pointer is in use, which indicates start of
urgent data.

• ACK: It is set to 1 to indicate that the acknowledgement number is valid.

• PSH: Push the data(indicate that the receiving device should deliver the data
to receiving application a soon as possible, rather than buffering it)

• RST: It is used to reset a connection that has become confused due to reject
an invalid segment or refuse an attempt to open a connection.

• FIN: Used to release a connection.

• SYN: Used to establish connections. 55


The TCP Segment Header
• Window size - This field defines the window size of the sending TCP in bytes. Note that the length of this
field is 16 bits. This value is normally referred to as the receiving window ( rwnd) and is determined by
the receiver.

• Checksum - This 16-bit field contains the checksum. The calculation of the checksum for TCP follows
the same procedure as the one described for UDP.

• Urgent pointer - This 16-bit field, which is valid only if the urgent flag is set, is used when the segment
contains urgent data.

• It defines a value that must be added to the sequence number to obtain the number of the last
urgent byte in the data section of the segment.

• Options field -provides a way to add extra facilities not covered by the regular header. Size is 0-40 bytes

• Most important option is the one that allows each host to specify the maximum TCP payload it is
56
Comparison

57
58
TCP CONNECTIONS
• In TCP, connection-oriented transmission requires three phases:

1. Connection establishment

2. Data transfer

3. Connection termination.
TCP Connection Establishment
• TCP transmits data in full-duplex mode.
• When two TCPs in two machines are connected, they are able to send segments
to each other simultaneously.
• This implies that each party must initialize communication and get approval from
the other party before any data are transferred.
• The connection establishment in TCP is called threeway handshaking ,since it
requires 3 steps to complete the connection establishment process
• When a client wants to make a connection to a server
■ Server performs the passive open
□ Tell TCP that it is ready to accept a connection
■ Client performs the active open
□ Tell TCP that it needs to be connected to the server
Connection establishment

□ Active open
■ The side that sends the first SYN
□ Passive open
■ The side that receives this SYN and sends the next SYN
□ Simultaneous open
■ Both processes issue an active open
□ In this case, both TCPs transmit a SYN + ACK segment to each other,
and one single connection is established between them
Three-way handshaking

1. The client sends the first segment, a SYN segment


■ Set the SYN flag
■ The segment is used for synchronization of sequence number
□ Initialization sequence number (ISN)
■ If client wants to define MSS(Max Segment Size), add MSS option
■ Does not contain any acknowledgment number
■ Does not define the window size either
□ A window size makes sense only when a segment includes an
acknowledgment
■ Although a control segment and does not carry data
□ But consumes one sequence number
Note
:
A SYN segment cannot carry data, but
it consumes one sequence number.
Three-way handshaking (Cont.)
2. The server sends a second segment, a SYN + ACK
segment
■ Set the SYN and ACK flag
■ The server uses this segment to initialize a sequence number for
numbering the bytes sent from the server to the client.
■ Acknowledge the receipt of the first segment using the ACK
flag and acknowledgment number field
□ Acknowledgment number = client initialization sequence
number
+1
□ Must also define the receiver window size for flow control
Note:

A SYN + ACK segment cannot carry


data, but does consume one
sequence number.
Three-way handshaking (Cont.)
3. The client sends the third segment, ACK segment
■ Acknowledge the receipt of second segment
□ ACK flag is set
■ Acknowledgement number = server initialization sequence number
+1
□ Must also define the window size
□ The sequence number is the same as the one in the SYN segment
■ ACK segment does not consume any sequence number
■ However, in some implementation, data can be sent with the third packet
□ Must have a new sequence number showing the byte number of the first
byte in the data
Figure 12-28

Three-way Handshaking

8001

The McGraw-Hill Companies, Inc.,


2000
Note
:
An ACK segment, if carrying no data,
consumes no sequence number.
Connection establishment

SYN Flooding Attack


• The connection establishment procedure in TCP is susceptible to a serious security
problem called the SYN flooding attack.
• This happens when a malicious attacker sends a large number of SYN segments to a
server, pretending that each of them is corning from a different client by faking the source
IP addresses in the datagrams.
• The server, assuming that the clients are issuing an active open, allocates the necessary
resources.
• The TCP server then sends the SYN +ACK segments to the fake clients, which are lost.
• During this time, however, a lot of resources are occupied without being used. If, during
this short time, the number of SYN segments is large, the server eventually runs out of
resources and may crash.
• This SYN flooding attack belongs to a type of security attack known as a denial-of-
service attack, in which an attacker monopolizes a system with so many service requests
that the system collapses and denies service to every request
Connection establishment

□ Possible solutions of SYN attack


■ Impose a limit of connections requested during a period of time
■ Filter out datagrams coming from unwanted source
addresses
■ Postpone resource allocation until the entire connection is
set up
Data Transfer
□ Bidirectional data transfer takes place after
connection is established
■ Both parties can send data and acknowledgments
in both direction

■ The acknowledgment can be piggybacked with


the data
Example: a Data Transfer

10001
Pushing Data
□ In TCP, both sender and receiver have buffers
to hold data
■ In sender, application data to be sent is held
temporarily in the buffer
■ In receiver, receiving data is temporarily held
in the buffer
■ Thus, for applications, they may
encounter delayed transmission and
reception
Pushing Data (Cont.)
□ In some cases, delayed transmission and
reception may not be acceptable
□ TCP thus support PUSH operation
■ Sending TCP must create a segment and send the
data immediately
□ Must not wait for the window to be filled
■ Receiving TCP must deliver data to the application
immediately
□ Does not wait for more data to come
Urgent Data
□ TCP is a stream-oriented protocol
■ Data is presented as a stream of bytes

□ In some cases, an application needs to send urgent data


■ Sender wants a piece of data to be read our of order by the
receiving application
□ Solution: send a segment with URG bit set
■ Sender creates a segment, insert the urgent data at the beginning
of the segment and sends the segment with the URG bit set
■ The urgent pointer field defines the end of the urgent data and
the start of normal data
Connection Termination
□ Two options
■ Three-way handshaking

■ Four-way handshaking with a half-close option


Three-Way Handshaking
1. Client TCP sends the FIN segment
■ FIN flag is set

■ Two choices
□ FIN segment is only a control segment
■ Consume only one sequence number
□ FIN segment can include the last chunk of data sent by the
client
Three-Way Handshaking (Cont.)
2. The server TCP sends the FIN+ACK segment
■ ACK bit is set
□ Confirm the receipt of FIN segment
■ FIN bit is set
□ Announce the closing of the connection in the other direction
■ Two choices
□ FIN+ACK segment is only a control segment
■ Consume only one sequence number
□ FIN +ACK segment can include the last chunk of data sent by
the server
Three-Way Handshaking (Cont.)
□ Client TCP sends the last ACK segment
■ ACK bit is set
□ Confirm the receipt of the FIN+ACK segment for
the TCP server

■ This segment cannot carry data and consume


no sequence number
□ No further response!
Figure 12-29

Three-Way Handshaking

X+1

The McGraw-Hill Companies, Inc.,


2000
Four-Way Handshaking with
Half- Close
□ Host A sends a FIN segment announcing its wish
for connection termination
□ Host B sends a ACK segment acknowledging
the FIN segment from A
■ The connection is closed in one direction
■ But host B can continue sending data to A
□ Host B sends a FIN segment to close the
connection
□ Host A sends a ACK segment to acknowledges the
FIN segment from B
Half-Close
igure 12-29
TCP Connection Management Modeling
• The steps required to establish and release connections can be
represented in a finite state machine with the 11 states
• In each state, certain events are legal.
• When a legal event happens, some action may be taken.
• If some other event happens, an error is reported.
The states used in the TCP connection
management finite state machine
TCP connection management finite state machine
TCP Transmission Policy
• TCP Transmission Policy is not directly tied to acknowledgements as it
is in most data link protocols
• Acknowledgement doesn’t allow the sender to transmit more
• TCP uses the concept of window size for managing transmission of
data.
• Window field explicitly tells the sender how much it can transmit .
• Basically, the window size indicates the size of the receive buffer
TCP Transmission Policy

87
TCP Transmission Policy
1. In the above example, the receiver has 4096-byte buffer.
2. If the sender transmits a 2048-byte segment that is
correctly received, the receiver will acknowledge the
segment.
3. Now the receiver will advertise a window of 2048 as it has
only 2048 of buffer space, now.
4. Now the sender transmits another 2048 bytes which are
acknowledged, but the advertised window is’0’.
5. The sender must stop until the application process on the
receiving host has removed some data from the buffer, at
which time TCP can advertise a layer window.
88
Retransmission
□ When to retransmit a segment
■ When a retransmission timer expires
■ When the sender receives three duplicate ACK

□ No retransmission occurs for segments


■ If it does not consume sequence number
■ If it is an ACK segment
Retransmission After RTO
□ Sender TCP starts a retransmission time-out
(RTO) timer for each segment sent
□ If timer matures
■ Retransmit the segment
□ RTO value is dynamic
■ Updated based on the round trip time (RTT)
Retransmission After Three Duplicated
ACK Segments
□ A segment is lost but the receiver receives so
many out-of-order segments
■ Buffer may overflow
□ Solution: fast retransmission
■ Retransmit the missing segment immediately
if three duplicate ACK received
Silly Window Syndrome

• Silly Window Syndrome is a problem that arises due to the poor


implementation of TCP.
• It degrades the TCP performance and makes the data transmission
extremely inefficient.
• The problem is called so because-
• It causes the sender window size to shrink to a silly value.
• The window size shrinks to such an extent where the data being transmitted
is smaller than TCP Header
Causes of Silly Window Syndrome

• The syndrome may arise because of the following problems −

1. Sender windows transmit one byte of data repeatedly.

2. Receiver windows accept one byte of data repeatedly.


Silly Window Syndrome
• This problem occurs when data are passed to the sending TCP entity in
large blocks, but an interactive application on the receiving side reads data
1 byte at a time.
• Initially, the TCP buffer on the receiving side is full and the sender knows
this (i.e., has a window of size 0).
• Then the interactive application reads one character from the TCP stream.
• This action makes the receiving TCP happy, so it sends a window update
to the sender saying that it is all right to send 1 byte.
The sender obliges and sends 1 byte.
• The buffer is now full, so the receiver acknowledges the 1-byte segment
but sets the window to 0.
• This behavior can go on forever.
Silly Window Syndrome- Receiver window accepting one byte of data repeatedly

.
Silly Window Syndrome Solutions
• Nagle's algorithm and Clark's solution
• Nagle’s Algorithm tries to solve the problem caused by the sender
delivering 1 data byte at a time.

• Clark’s Solution tries to solve the problem caused by the receiver


sucking up one data byte at a time.
Nagle's algorithm

Nagle’s algorithm suggests-


• Sender should send only the first byte on receiving one byte data from the
application.
• Sender should buffer all the rest bytes until the outstanding byte gets
acknowledged.
• In other words, sender should wait for 1 RTT.
• After receiving the acknowledgement, sender should send the buffered data in one
TCP segment.
• Then, sender should buffer the data again until the previously sent data gets
acknowledged.
Clark’s solution
• Clark’s solution suggests-
• Receiver should not send a window update for 1 byte.
• Receiver should wait until it has a decent amount of space
available.
• Receiver should then advertise that window size to the
sender.
TCP congestion control
• Congestion occurs when the load on the network is greater
than the capacity of the network

• Congestion control refers to techniques and mechanisms that


can-
• Either prevent congestion before it happens
• Or remove congestion after it has happened
Congestion Control Mechanism
□ Congestion control
■ Prevent congestion before it happens
■ Remove congestion after it happens

□ Two categories
■ Open-loop congestion control
(prevention)
■ Closed-loop congestion control (removal)
Open-Loop Congestion Control
□ Prevent congestion before it happens
□ Possible policies
■ Retransmission policy
□ Retransmission policy and retransmission timer should be
designed to optimize efficiency
■ Acknowledgment policy
□ Does not ACK every packet it receives
□ Sending fewer acknowledgments means imposing less load
on the network
■ Discard policy
□ Router should adopt good discard policy
Closed-Loop Congestion Control
□ Try to alleviate congestion after it happens
□ Possible mechanisms
■ Back pressure
□ When a router is congested, it can inform the previous upstream router
to reduce it outgoing rate
□ The action can be recursive all the way to the router just prior to the
source
■ Choke Packet
□ A router sends a packet to the source to inform congestion
□ This packet is called chock packet, like ICMP’s source quench packet
■ Implicit signaling
□ Source can detect an implicit signal warning of congestion
■ For example, the delay in receiving an acknowledgment
■ Explicit signaling
□ Router can send an explicit signal to the sender or receiver of congestion
■ For example, set a bit in a packet
TCP congestion control.
• TCP uses a congestion window(cwnd) in the sender side to
do congestion avoidance
• The congestion window indicates the maximum amount of
data that can be sent out on a connection with out being
acknowledged.
• TCP detects congestion when it fails to receive an
acknowledgement with in the estimated time out.
• In such situation it decreases the congestion window to one
maximum segment size.
Congestion Control in TCP
• Congestion in TCP is handled by using these three phases:

1. Slow Start
2. Congestion Avoidance(Additive Increase )
3. Congestion Detection(Multiplicative Decrease)
Phase 2 & 3 combinedly known as AIMD technique Additive
Increase Multiplicative Decrease
Slow Start Phase : exponential increment
• At the beginning,
■ congestion window size = maximum segment size (MSS)

• In Slow-start phase, TCP increases the congestion window each time an


acknowledgement is received
• This strategy effectively doubles the TCP congestion window for every
round trip time (RTT)
• In this phase after every RTT the congestion window size increments
exponentially.
• This phase continues until the congestion window size reaches the slow
start threshold.
• Slow start Threshold (ssthresh) is the Maximum number of TCP segments
that receiver window can accommodate / 2
105
Slow Start Phase : exponential increment

106
Slow Start Phase
Congestion Avoidance
• After cwnd exceeds the ssthresh size, the TCP Congestion control
mechanism enters the congestion avoidance phase
• In this phase sender increases the congestion window size linearly to
avoid the congestion.
• On receiving each acknowledgement, sender increments the
congestion window size by 1 and the technique is known as Additive
increase.
• This phase continues until the congestion window size becomes equal
to the receiver window size.
Packets in transit during additive increase

109
Packets in transit during additive increase

110
Congestion Detection Phase
• In this phase, the sender identifies the segment loss
• When sender detects the loss of segments, it reacts in different ways
depending on how the loss is detected
• Case-01: Detection On Time Out
• In this, the timer time-out expires even before receiving acknowledgment for
a segment.
• In this case sender sets the slow start threshold to half of the current
congestion window size.
• Each time a timeout occurs, the source sets CongestionWindow to half of its
previous value.
• This halving of the CongestionWindow for each timeout corresponds to the
“multiplicative decrease” part of AIMD(Additive Increase /Multiplicative
Decrease)
• Slow start phase is resumed
Congestion Detection Phase
• Case-02: Detection On Receiving 3 Duplicate Acknowledgements-

• If three ACKs are received, there is a weaker possibility of congestion;


a segment may have been dropped, but some segments after that
may have arrived safely since three ACKs are received.
• This is called fast transmission and fast recovery.
• In this case, sender reacts by-
• Setting the slow start threshold to half of the current congestion window size.
• Decreasing the congestion window size to slow start threshold.
• Resuming the congestion avoidance phase.
113

You might also like