Sie sind auf Seite 1von 41

Lecture 8

Process-to-Process Delivery:
UDP and TCP
(Chapter 23)

23.1
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
23-1 PROCESS-TO-PROCESS DELIVERY

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

The transport layer is responsible for process-to-process


delivery—the delivery of a packet, part of a message, from
one process to another. Two processes communicate in a
client/server relationship, as we will see later.
Topics discussed in this section:
Client/Server Paradigm
Multiplexing and Demultiplexing
Connectionless Versus Connection-Oriented Service
Reliable Versus Unreliable
Three Protocols
23.2
Figure 23.1 Types of data deliveries

23.3
Client/ Server Paradigm - Addressing
• Most common way to achieve process-to-process delivery is through
client/ server paradigm

• At the transport layer, we need a transport layer address called a


port number to choose among multiple processes running n the
destination host. The destination port number is needed for delivery;
the source port number is needed for the reply.

• In the Internet model, the port numbers are 16-bit integers between 0
and 65,535. The client program defines itself with a port number,
chosen randomly by the transport layer software running on the client
host. This is the ephemeral (temporary) port number.

• Universal port numbers called well-known port numbers are used for
servers.

23.4
Client/ Server Paradigm - Addressing
• In Fig.23.2, the Daytime client process uses an ephemeral (temporary)
port number 52,000 and the Daytime server process uses the well-
known (permanent) port number13.

23.5 Figure 23.2 Port numbers


IP add:
Defines the host among
different hosts in the world

Port number:
Defines 1 of the processes on
this particular host

Figure 23.3 IP addresses versus port numbers

23.6
IANA ranges

Figure 23.4 IANA ranges

Range: 0 - 1023
Well-known ports
Assigned and controlled by IANA.
Range: 1024 - 49,151
Registered ports Not assigned/ controlled by IANA. They can
only be registered with IANA to prevent
duplication.
Range: 49,152 - 65,535
Dynamic port
(ephemeral ports) Not assigned/ controlled by IANA. They can be
used by any process.

23.7
Socket address
• Process-to-process delivery needs two identifiers:
• IP address and
• the port number at each end to make a connection.

• Socket address is the combination of IP address and port number

Figure 23.5 Socket address

23.8
Multiplexing and Demultiplexing

Sender’s site
1. Protocol accepts messages from
different processes
2. Adds header
3. Passes packet to network layer

Receiver’s site
1. Transport layer receives datagram from
network layer
2. Performs error checking
3. Drops header
4. Delivers each message to appropriate
process based on the port number

23.9
Connectionless vs. Connection-Oriented Service
Transport layer protocol can either be
• Connectionless: UDP
• the packets are sent from one party to another with
no need for connection establishment or connection
release. The packets are not numbered; they may be
delayed or lost or may arrive out of sequence.

• Connection-oriented: TCP
• a connection is first established between the sender
and receiver before data transfer. At the end, the
connection is released.

23.10
Reliable vs. Unreliable
• UDP: connectionless & unreliable
• TCP: connection-oriented & reliable

23.11 Figure 23.7 Error control


Three Protocols

Figure 23.8 Position of UDP, TCP, and SCTP in TCP/IP suite


23.12
23-2 USER DATAGRAM PROTOCOL (UDP)

The User Datagram Protocol (UDP) is called a


connectionless, unreliable transport protocol. It does
not add anything to the services of IP except to provide
process-to-process communication instead of host-to-
host communication.
Topics discussed in this section:
Well-Known Ports for UDP
User Datagram
Checksum
UDP Operation
Use of UDP
23.13
Well-known Ports for UDP

23.14
Table 23.1 Well-known ports used with UDP
User Datagram
UDP packet is called user datagram with a fixed size header of 8 bytes

Figure 23.9 User datagram format

port number used by the process running on the


source host
Source port number
if ephemeral port number client
if well-known port number server
port number used by the process running on the
Destination port number
destination host
length of user datagram header and data
Total length UDP length = IP length - IP length header
UDP length = IP length – IP header’s length

Checksum field used to detect errors


23.15
Checksum

Figure 23.10 Pseudoheader for checksum calculation

• UDP checksum calculation have 3 sections: pseudoheader, header


(UDP) & data (from the application layer)

• Pseudoheader: to ensure if IP header is corrupted the user


datagram is not delivered to the wrong host

• Protocol field: ensure packet belong to UDP and not other


transport layer protocol (protocol field for UDP is 17)
23.16
Example 23.2
Figure 23.11 shows the checksum calculation for a very small user
datagram with only 7 bytes of data. Because the number of bytes of
data is odd, padding is added for checksum calculation. The
pseudoheader as well as the padding will be dropped when the user
datagram is delivered to IP.

23.17 Figure 23.11 Checksum calculation of a simple UDP user datagram


UDP Operation
1. When client process starts
• Request port number
• Create incoming & outgoing queue/ incoming queue
2. Client process sends message to outgoing queue
3. UDP removes message 1 by 1
• Add UDP header
• Deliver to IP
4. At server side once its process starts running
• Create incoming & outgoing queue
5. When message arrives
• UDP sends to incoming queue of the port number specified

Figure 23.12 Queues in UDP


23.18
Use of UDP

1. Suitable for process that requires simple request-response


communication with little concern for flow & error control

2. Suitable for process with internal flow & error control


eg: trivial FTP (TFTP) process have flow & error control

3. Suitable for transport protocol for multicasting

4. Used for management processes such as SNMP

5. Used for some route updating protocol, eg. RIP

23.19
23-3 TCP

TCP is a connection-oriented protocol; it creates a


virtual connection between two TCPs to send data. In
addition, TCP uses flow and error control mechanisms
at the transport level.

Topics discussed in this section:


TCP Services
TCP Features
Segment
A TCP Connection
Flow Control
Error Control
23.20
TCP Services

23.21
Table 23.2 Well-known ports used by TCP
Stream Delivery Services
• In TCP, process delivers data as a stream of bytes and receiver
receives data in stream of bytes

• TCP creates an environment in which the two processes seem to


be connected by an imaginary “tube” that carries data across the
Internet

Figure 23.13 Stream delivery


23.22
Sending and receiving buffers
• Sending and receiving processes may not write/ read at the same speed
TCP needs buffer for storage

• Uses circular array of 1-byte locations

1. At sending site, buffer has 3 type of chambers


White: empty, can be filled by sending process
Pink: contains bytes to be sent
Gray: holds bytes that have been sent but not yet acknowledge

2. At receiver’s site, buffer is divided into 2 chambers


White: empty, to be filled by bytes received from network
Pink: holds bytes to be read by process

23.23 Figure 23.14 Sending and receiving buffers


Segments
• IP layer as service provider for TCP need to send data in packet,
not stream of bytes
1. TCP groups a number of bytes into a packet called segment,
then adds header and sends to IP
2. Segment are encapsulated in IP datagram and transmitted
• Segments are not necessarily the same size
• TCP offers full-duplex service and provide sending & receiving
buffer to allow segments move in both directions

Figure 23.15 TCP segments


23.24
TCP Features

The bytes of data being transferred in each connection are numbered


by TCP. The numbering starts with a randomly generated number.

The value in the sequence number field of a segment defines the


number of the first data byte contained in that segment.

The value of the acknowledgment field in a segment defines


the number of the next byte a party expects to receive.
The acknowledgment number is cumulative.

23.25
Example 23.3

The following shows the sequence number for each


segment:

23.26
Segment
In TCP packet is called segment which consists of 20 – 60 bytes header

port number used by the process running on the source host


Source port add if ephemeral port number client
if well-known port number server
Destination port add port number used by the process running on destination host
Sequence number Identifies the number of 1st bytes in segment
Acknowledgement number Defines byte number that it expects to receive
Between 20 – 60 bytes
HLEN (header length) Field value can be from: 5 5*4=20 bytes (no option)
to: 15 15*4=60 bytes (max option)
23.27
Reserved Reserved for future use
Defines 6 different control bits/ flags

Control fields

Window size Windows size determined by receiver that the sender must maintain
Checksum Used for error checking (Protocol field value for TCP is 6)
Urgent pointer Used when segment contains urgent data (only valid if urgent pointer is set)
Options/ Padding Can be up to 40 bytes of optional information
23.28
Table 23.3 Description of flags in the control field

23.
29
TCP Connection
3 phases
1st phase: Connection Establishment
a. Server request passive open
b. Client program request active open
c. 3 way handshaking starts
• SYN segment
A SYN segment cannot carry
data, but it consumes one
sequence number.

• SYN + ACK segment


A SYN + ACK segment cannot
carry data, but does consume
one sequence number.

• ACK segment
An ACK segment, if carrying no
data, consumes no sequence
Figure 23.18 Connection establishment using
number.
three-way handshaking
23.30
2nd phase: Data Transfer

Eg:
Client sends 2000 bytes in 2 segments
Server then sends 2000 bytes in 1
segment

Push flag: inform server’s TCP to


deliver data to process as
soon as they are received

Figure 23.19 Data transfer


23.31
3rd phase: Connection Termination
3 way handshaking
• FIN segment
The FIN segment consumes one
sequence number if it does
not carry data.

• FIN + ACK segment


The FIN + ACK segment consumes
one sequence number if it
does not carry data.

• ACK segment
Figure 23.20 Connection termination using
three-way handshaking

23.32
Flow Control

A sliding window is used to make transmission more efficient as well as


to control the flow of data so that the destination does not become
overwhelmed with data. TCP sliding windows are byte-oriented.

Open: allow new bytes in the buffer that are eligible for sending
Close: some bytes have been acknowledged
Shrink: revoke eligibility of some bytes for sending

Window size is determined by the lesser of 2 values


a. rwnd (receiver window)
• value advertised by opposite end
• tells how many bytes it can accept before its buffer overflows
b. cwnd (congestion window)
• value determined by network to avoid congestion
23.33
Example 23.4

What is the value of the receiver window (rwnd) for host


A if the receiver, host B, has a buffer size of 5000 bytes
and 1000 bytes of received and unprocessed data?

Solution
• The value of rwnd = 5000 − 1000 = 4000.
• Host B can receive only 4000 bytes of data before
overflowing its buffer.
• Host B advertises this value in its next segment to A.

23.34
Example 23.5

What is the size of the window for host A if the value of


rwnd is 3000 bytes and the value of cwnd is 3500 bytes?

Solution
The size of the window is the smaller of rwnd and cwnd,
which is 3000 bytes.

23.35
Example 23.6

An unrealistic example of a sliding window


• The sender has sent bytes up to 202 (bytes 200 to 202 are sent,
but not acknowledged)
• Assume that cwnd is 20
• The receiver has sent an acknowledgment number of 200 with an
rwnd of 9 bytes.
• The size of the sender window is the minimum of rwnd and cwnd,
or 9 bytes.
• Bytes 203 to 208 can be sent without worrying about
acknowledgment.
• Bytes 209 and above cannot be sent.
23.36
Note

Some points about TCP sliding windows:


❏ The size of the window is the lesser of rwnd and
cwnd.
❏ The source does not have to send a full window’s
worth of data.
❏ The window can be opened or closed by the
receiver, but should not be shrunk.
❏ The destination can send an acknowledgment at
any time as long as it does not result in a shrinking
window.
❏ The receiver can temporarily shut down the
window; the sender, however, can always send a
segment of 1 byte after the window is shut down.
23.37
Error Control
Error detection & correction in TCP is achieved through
a. Checksum
b. Acknowledgment
No retransmission timer is set for an ACK segment.
c. Time out/ Retransmission

In modern implementations, a retransmission occurs if the retransmission timer


expires or 3 duplicate ACK segments have arrived.
1. In retransmission time out (RTO), a RTO timer is set for all
outstanding segments
No retransmission timer is set for an ACK segment.

2. In 3 duplicate ACK segments, the missing segment is transmitted


immediately (fast retransmission)
Data may arrive out of order and be temporarily stored by the receiving TCP, but
TCP guarantees that no out-of-order segment is delivered to the process.
23.38
Scenarios

Normal operation
eg: A bidirectional data transfer
between 2 systems

• ACK is delayed 500ms to see if any


more segments arrive
• When timer matures
trigger ACK

Figure 23.24 Normal operation

23.39
Lost segment
The receiver TCP delivers only ordered data to the process.

Figure 23.25 Lost segment


23.40
Fast retransmission

Although timer for segment 3 has


not yet matured, fast retransmission
requires that segment 3 be resent
immediately after 3 duplicate of ACK
segments are received.

23.41 Figure 23.26 Fast retransmission

Das könnte Ihnen auch gefallen