Download as pdf or txt
Download as pdf or txt
You are on page 1of 42

Faculty of

Engineering

Computer Network
Transport Layer

Computer Network
Dr. Ahmed Abdel Halim @ Helwan University
Fall 2019
Dr. Ahmed M. Abd El-Haleem
Assistant Professor in
Communication and Electronic Department
Faculty of Engineering, Helwan University

E-mail: dr.ahmed.m.abd.elhaleem@gmail.com
Transport layer
3

 Process-to-process delivery
Transport layer
4

 The transport layer is responsible for establishing


a temporary communication session between two
applications (Processes) and delivering data
between them.
Transport layer
5

 Segmentation of data (packetizing)


 Multiplexing of upper layer application using port
numbers (addressing)
 Enables multiple applications to communicate over
the network at the same time on a single device
 provide efficient, reliable and cost-effective transport
from the source to destination.
 Employs error handling mechanisms
Data Segmentation
6

 Sender: breaks application messages into segments.


 Receiver: reassembles segments into messages, passes to
application layer.
 Header added to each segment to identify it.
 Segmenting the data enables many different
communications, from many different users, to be
interleaved (multiplexed) on the same network, at the
same time.
Port (Addressing) Numbers
7

 In order to pass data


streams to the proper
applications, the
Transport layer must
identify the target
application.
 Assigns an application
an identifier called
port number.
 Using port
numbers, can
multiplex
different layer-7
byte streams.
Port (Addressing) Numbers
8

 Transport layer use Port numbers identify sending and


receiving applications (processes).
 Each software process that needs to access the
network is assigned a port number unique in that host.
 A globally unique address at the transport layer is a tuple
<IP address, port number> which is called socket
address.
 (Source IP, Source port, Destination IP, Destination
port) uniquely identifies TCP connection.
Port (Addressing) Numbers
9

 Well Known (system) Ports (Numbers 0 to 1023) -


These numbers are reserved for services and
applications on server.
◼ ex: FTP(20,21), Telnet(23), SMTP(25), DNS(53),
HTTP(80)
 Registered (User) Ports (Numbers 1024 to 49151)
- These port numbers are assigned to user processes
or applications.
 used only for the active session.
 once it expires the port becomes available again.
Communication using Port Numbers
11

 The client applications choose a free port


number as a source port (A uses a port 4711 and
B uses a port 7312) as shown in figure below.
 The destination port is the well known port for
server applications [A runs Hyper Text Transfer
Protocol (HTTP) so the packet is sent to the
server with destination port of 80. B makes a
Mail-Check over POP3 so the packet is sent to
the server with destination port of 110.)
Communication using Port Numbers
13

 Server process multiplexes streams with same


source port numbers according source IP address
called Socket, which is the combination IP
address and port number. For example:
10.1.1.2:80 [IP-Address : Port-Number]
 Each stream ("flow") is uniquely identified by a
socket pair.
Transport layer protocols
15

 Different applications have different requirements


for their data, and therefore different Transport
protocols have been developed to meet these
requirements.
 TCP/IP model uses two protocols to achieve this:
 Transmission Control Protocol (TCP) →
Connection-oriented
 User Datagram Protocol (UDP) → Connectionless
 They are only implemented at the hosts.
Transport layer protocols
16

TCP-Transmission Control Protocol UDP - User Datagram Protocol


• Reliable, connection-oriented • Unreliable, connectionless
• Complex • Simple
• Ordered delivery • Unordered delivery
• Flow and Congestion Control • Unicast and multicast
• Only Unicast • Useful only for few applications,
• Used for most Internet e.g., multimedia applications
applications: • Used a lot for services
– web (HTTP), email (SMTP), file – network management
transfer (FTP), terminal (SNMP), routing (RIP),
(TELNET), etc. naming (DNS), etc.
Transmission Control Protocol (TCP)
17

 TCP is connection-oriented protocol which is carried within


IP payload.
 TCP Provides reliable delivery ensuring that all of the data
arrives at the destination using ACK.
 Application's data is regarded as continuous byte stream. TCP
ensures a reliable transmission of segments of this byte
stream.
TCP Reliable Communication
18

 A TCP protocol ensure reliable delivery of the data.


At the Transport layer the three basic operations of
reliability are:
a) tracking transmitted data
b) acknowledging received data
c) retransmitting any unacknowledged data
 These reliability processes place additional overhead
on the network resources due to the acknowledgement,
tracking, and retransmission, more control data is
exchanged between the sending and receiving hosts in
the Transport Layer header.
TCP Sequence Numbers
19

 Sequence number for the first byte in the segment.


 Sender and receiver agree on initial sequence number
(ISN) during the TCP connection establishment process.
 Sequence numbers are used to reassemble segments into
their original order.
TCP Sequence Numbers
20

 Sequence numbers are assigned in the header of each


packet to achieve this goal.
TCP Operation
21

 TCP is connection-oriented transport protocol establishes


a virtual path between the source and destination.
 All the segments belonging to a message are then sent over
this virtual path.
 Using a single virtual pathway for the entire message
facilitates the acknowledgment process as well as
retransmission of damaged or lost frames.
 TCP uses the services of IP to deliver individual segments
to the receiver, but it controls the connection itself. If a
segment is lost or corrupted, it is retransmitted.
 In TCP, connection-oriented transmission requires three
phases:
- Connection establishment.
- Data transfer.
- Connection termination.
TCP Operation
22

1. Connection Establishment
 TCP transmits data in full-duplex mode.
 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 three way
handshaking.
 In our example, an application program, called the client, wants to
make a connection with another application program, called the
server, using TCP as the transport layer protocol.
1) The server program tells its TCP that it is ready to accept a
connection. This is called a request for a passive open.
2) The client program issues a request for an active open. A
client that wishes to connect to an open server tells its TCP
that it needs to be connected to that particular server.
3) TCP can now start as shown in Fig.
1) A SYN segment
cannot carry
data, but it
consumes one
sequence
number.
2) A SYN + ACK
segment cannot
carry data, but
does consume
one
sequence
number.
3) An ACK
segment, if
carrying no
data, consumes
no sequence
number.
TCP Operation
24

1.Connection establishment:
Step#1 The client sends the 1st segment, a SYN segment, in which
only the SYN flag is set.
 This segment is for synchronization of sequence numbers. It
consumes one sequence number (containing 1 imaginary byte).
When the data transfer starts, the sequence number is
incremented by 1.
Step#2 The server sends the 2nd segment, a SYN +ACK segment,
with 2 flag bits set: SYN and ACK.
 SYN segment for communication in the other direction and
serves as the acknowledgment for the SYN segment.
Step#3 The client sends the 3rd segment. This is just an ACK
segment.
 It acknowledges the receipt of the second segment with the
ACK flag and acknowledgment number field.
 Note that the ACK segment does not consume any sequence numbers.
TCP Operation
25

2. Data Transfer
 After connection is established, bidirectional data
transfer can take place. The client and server can both
send data and acknowledgments.
 Data travels in the same direction as an acknowledgment

are carried on the same segment. The acknowledgment is


piggybacked with the data.
 The client sends 2000 bytes of data in two segments. The
server then sends 2000 bytes in one segment. The client
sends one more segment. The first three segments carry
both data and acknowledgment, but the last segment
carries only an acknowledgment because there are no
more data to be sent.
1) The bytes of data being
transferred in each
connection are numbered by
TCP.
2) The numbering starts with
a randomly generated
number.
3) The value in the sequence
number field of a segment
defines the number of the
first data byte contained
in that segment.
4) The value of the
acknowledgment field in a
segment defines the number
of the next byte a party
expects to receive.
5) The acknowledgment
number is cumulative.
TCP Operation
27

3.Connection Termination
 Any of the two parties involved in exchanging data

(client or server) can close the connection,


although it is usually initiated by the client.
 Most implementations today allow three-way
handshaking for connection termination as follows:
Step #1 In a normal situation, the client TCP, after
receiving a close command from the client process,
sends the first segment, a FIN segment in which
the FIN flag is set. Note that a FIN segment can
include the last chunk of data sent by the
client, or it can be just a control segment.
TCP Operation
28

Step #2 The server TCP, after receiving the FIN segment,


informs its process of the situation and sends the second
segment, a FIN +ACK segment, to confirm the receipt of
the FIN segment from the client and at the same time to
announce the closing of the connection in the other
direction. This segment can also contain the last chunk
of data from the server.
Step #3 The client TCP sends the last segment, an ACK
segment, to confirm the receipt of the FIN segment from
the TCP server. This segment contains the
acknowledgment number, which is 1 plus the sequence
number received in the FIN segment from the server.
This segment cannot carry data and consumes no sequence
numbers.
1) The FIN
segment
consumes one
sequence
number if it
does
not carry data.
2) The FIN + ACK
segment
consumes
one sequence
number if it
does not carry
data.
TCP Flow Control
30

 Flow control assists the reliability of TCP transmission by


adjusting the effective rate of data flow between the two
services in the session. When the source is informed that the
specified amount of data in the segments is received, it can
continue sending more data for this session.
 Window Size field in the TCP header specifies the amount of
data that can be transmitted before an acknowledgement must
be received. The initial window size is determined during the
session startup via the three-way handshake.
 TCP feedback mechanism adjusts the effective rate of data
transmission to the maximum flow that the network and
destination device can support without loss.
 TCP attempts to manage the rate of transmission so that all
data will be received and retransmissions will be minimized.
TCP Flow Control
31
TCP Flow Control
32

Reducing Window Size


 A way to control the data flow is to use dynamic

window sizes. When network resources are


constrained, TCP can reduce the window size to require
that received segments be acknowledged more
frequently. This effectively slows down the rate of
transmission because the source waits for data to be
acknowledged more frequently.
 If the destination needs to slow down the rate of

communication because of limited buffer memory, it


can send a smaller window size value to the source as
part of an acknowledgement.
TCP Flow Control
33

 Describe the mechanisms in TCP that manage the


interrelationship between window size, data loss and
congestion during a session
TCP Error Control
34

 TCP provides reliability using error control. Error control


includes mechanisms for detecting corrupted segments, lost
segments, out-of-order segments, and duplicated segments.
 Error control also includes a mechanism for correcting errors

after they are detected. Error detection and correction in TCP


is achieved through the use of three simple tools:
- Checksum - Acknowledgment - Time-out.
1. Checksum: Each segment includes a checksum field which is
used to check for a corrupted segment. If the segment is
corrupted, it is discarded by the destination TCP and is
considered as lost.
2. Acknowledgment:
 TCP uses acknowledgments to confirm the receipt of data

segments. ACK segments are never acknowledged.


TCP Error Control
35

Retransmission
 The heart of the error control mechanism is the
retransmission of segments. When a segment is
corrupted, lost, or delayed, it is retransmitted.
 Retransmission after Time-Out (RTO): A recent
implementation of TCP maintains one Retransmission Time-
Out (RTO) timer for all outstanding (sent, but not
acknowledged) segments.
 When the timer matures, the earliest outstanding
segment is retransmitted even though lack of a received
ACK can be due to a delayed segment, a delayed ACK, or a
lost acknowledgment.
TCP Error Control
36
TCP Segment and Header
37
Structure
TCP Segment and Header
38
Structure
 Source port: defines the port number of the application program
in the host that is sending the segment.
 Destination port: defines the port number of the application
program in the host that is receiving the segment
 Sequence number: defines the number assigned to the first byte
of data contained in this segment because TCP is a stream
transport protocol.
 Acknowledgment number (32 bits) byte number that the
receiver of the segment is expecting to receive.
 Header Length: specifies the size of the TCP header in 4 bytes
words
 Reserved: for future use and should be set to zero
 Window: the size of the receive window, which specifies the
number of bytes that the receiver is currently willing to receive.
 Checksum: The 16-bit checksum field is used for error-checking
of the header and data
User Datagram Protocol (UDP)
39

 Simple protocol that provides the basic transport layer function


 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 and performs very limited error checking.
 If UDP is so powerless, why would a process want to use it? With the
disadvantages come some advantages. 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. Sending a small message by
using UDP takes much less interaction between the sender and receiver than
using TCP.
 UDP is used, where the overhead of a connection oriented service is
undesirable or where the implementation has to be small:
 Less complex than TCP and easier to implement.

 Used by applications that can tolerate small loss of data (VoIP)


 Used by applications that cannot tolerate delay
User Datagram Protocol Operation
40

1. Connectionless Services
 This means that each user datagram sent by UDP is an

independent datagram. There is no relationship between the


different user datagrams even if they are coming from the
same source process and going to the same destination program.
 The user datagrams are not numbered. Also, there is no

connection establishment and no connection termination, as is


the case for TCP.
 Only those processes sending short messages (small enough to

fit into one user datagram) should use UDP.

2. No Flow and Error Control


 UDP is a very simple, unreliable transport protocol. There is no

flow control and hence no window mechanism. The receiver may


overflow with incoming messages. There is no error control
mechanism in UDP except for the checksum.
User Datagram Protocol
41
Operation
 This means that the sender does not know if a
message has been lost or duplicated. When the
receiver detects an error through the checksum,
the user datagram is silently discarded.
 The lack of flow control and error control means
that the process using UDP should provide these
mechanisms.
3. Encapsulation and Decapsulation
 To send a message from one process to another,

the UDP protocol encapsulates and decapsulates


messages in an IP datagram.
User Datagram Header Format
42

Checksum field: This field is used to detect errors


over the entire user datagram (header plus data).

You might also like