Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Week 10

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 39

Subject : CPEN6098 / Computer Networks

Year : 2021

Session 10
Transport Layer
Learning Outcomes

The students will be able to explain the protocol for


accessing applications.
Topics Discussed in the Section
 Process-to-Process Communication
 Addressing: Port Numbers
 Encapsulation and Decapsulation
 Multiplexing and Demultiplexing
 Flow Control
 Error Control
 Connectionless and Connection-Oriented Services
 UDP
 TCP

TCP/IP Protocol Suite 3


Process to Process Communication

TCP/IP Protocol Suite 4


Port numbers

TCP/IP Protocol Suite 5


IP addresses versus port numbers

13 Destination port number


selects the process
Data

TCP/IP Protocol Suite 6


ICANN ranges

TCP/IP Protocol Suite 7


Note

The well-known port numbers are


less than 1,024.

TCP/IP Protocol Suite 8


Socket address

TCP/IP Protocol Suite 9


Encapsulation and decapsulation

TCP/IP Protocol Suite 10


Multiplexing and demultiplexing

TCP/IP Protocol Suite 11


Pushing or pulling

TCP/IP Protocol Suite 12


Flow control at the transport layer

TCP/IP Protocol Suite 13


Error control at the transport layer

Packets

Error Control

TCP/IP Protocol Suite 14


Note

For error control, the sequence numbers


are modulo 2m, where m is the size of the
sequence number field in bits.

TCP/IP Protocol Suite 15


Sliding window in circular format

TCP/IP Protocol Suite 16


Sliding window in linear format

TCP/IP Protocol Suite 17


Connectionless service

TCP/IP Protocol Suite 18


Connection-oriented service

Client Client transport Server transport Server


process layer layer process

Time Time Time Time

TCP/IP Protocol Suite 19


Transport Layer Protocol

• Transmission Control Protocol


– Connection oriented
– RFC 793
– Provides: Unreliable, unordered delivery of segments.
• User Datagram Protocol (UDP)
– Connectionless
– RFC 768
– Provides: Reliable, in-order delivery of segments.
– TCP includes:
• Connection set-up (3-way handshake)
• Flow Control
• Congestion Control
Transport Layer Protocol
User Datagram Protocol
• UDP is:

– A “no frills,” “bare bones” Internet Transport protocol


– Provides “best effort” service
• UDP segments may be:

– Lost
– Delivered out of order to application
• Connectionless

– Has no handshaking between UDP sender, receive


– Each UDP segment handled independently of others
User Datagram Protocol
Since UDP provides so few services, why is there a UDP?

• UDP has no connection establishment =>


– So it has lower delay
– It is simple (no connection state is need at sender, receiver)
– It has a small segment header
• UDP has no congestion control =>
– UDP can blast away as fast as desired
•  Uses of UDP: 
– It is often used for streaming multimedia apps, because UDP is:
• loss tolerant
• rate sensitive
– UDP is also used in:
• DNS
• SNMP
UDP Segment Format

UDP segment format, called user datagrams, have a fixed-size header of 8 bytes. The
following figure shows the format of a user datagram.

TCP/IP Protocol Suite 24


UDP Segment Format
Source port number. 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. If the source host is the client (a client sending a request), the port
number, in most cases, is an ephemeral port number requested by the process and
chosen by the UDP software running on the source host. If the source host is the
server (a server sending a response), the port number, in most cases, is a well-
known port number.

Destination port number. 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. If the destination host is the client (a server sending a response), the port
number, in most cases, is an ephemeral port number. In this case, the server copies
the ephemeral port number it has received in the request packet.
UDP Segment Format
Length. This is a 16-bit field that defines the total length of the user datagram, header plus
data. The 16 bits can define a total length of 0 to 65,535 bytes. However, the total length
needs to be much less because a UDP user datagram is stored in an IP datagram with the total
length of 65,535 bytes. The length field in a UDP user datagram is actually not necessary. A
user datagram is encapsulated in an IP datagram. There is a field in the IP datagram that
defines the total length. There is another field in the IP datagram that defines the length of the
header. So, if we subtract the value of the second field from the first, we can deduce the length
of the UDP datagram that is encapsulated in an IP datagram.

UDP length = IP length - IP header’s length

However, the designers of the UDP protocol felt that it was more efficient for the
destination UDP to calculate the length of the data from the information provided in the UDP
user datagram rather than ask the IP software to supply this information. We should remember
that when the IP software delivers the UDP user datagram to the UDP layer, it has already
dropped the IP header.

Checksum. This field is used to detect errors over the entire user datagram (header plus data).
The checksum is discussed in the next section.
Checksum
The checksum includes three sections: a pseudoheader, the UDP header, and the
data coming from the application layer. The pseudoheader is the part of the header
of the IP packet in which the user datagram is to be encapsulated with some fields
filled with 0s.
Checksum
The following figure 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.

https://www.youtube.com/watch?v=AtVWnyDDaDI
Example 14.1
The following is a dump of a UDP header in hexadecimal format.

a. What is the source port number?


b. What is the destination port number?
c. What is the total length of the user datagram?
d. What is the length of the data?
e. Is the packet directed from a client to a server or vice versa?
f. What is the client process?

TCP/IP Protocol Suite 29


Example 14.1 Continued
Solution
a. The source port number is the first four hexadecimal digits (CB84)16
or 52100.
b. The destination port number is the second four hexadecimal digits
(000D)16 or 13.
c. The third four hexadecimal digits (001C)16 define the length of the
whole UDP packet as 28 bytes.
d. The length of the data is the length of the whole packet
minus the length of the header, or 28 – 8 = 20 bytes.
e. Since the destination port number is 13 (well-known port), the
packet is from the client to the server.
f. The client process is the Daytime (see Table 14.1).
TCP/IP Protocol Suite 30
UDP
Well Known Port
TCP
(Transmission Control Protocol)

TCP characteristics:
• Point-to-point connections
₋ one sender, one receiver
• Full duplex data:
₋ bi-directional data flow in same connection
• Reliable, in-order byte steam transmission
₋ with no “message boundaries” between bytes
• Pipelined transmission
₋ multiple segments are sent at the same time
₋ Maximum segments sent simultaneously = TCP congestion/flow control
window size
₋ send & receive buffers at sender and receiver
• Connection-oriented:
₋ handshaking occurs between the sender, receiver before data exchange
• Uses flow control:
₋ The sender will not overwhelm receiver’s buffer
TCP Segment Format
TCP Segment Format
Source port address. This is a 16-bit field that defines the port number of the application
program in the host that is sending the segment. This serves the same purpose as the source
port address in the UDP header

Destination port address. This is a 16-bit field that defines the port number of the
application program in the host that is receiving the segment. This serves the same purpose as
the destination port address in the UDP.

Sequence number. This 32-bit field defines the number assigned to the first byte of data
contained in this segment. As we said before, TCP is a stream transport protocol. To ensure
connectivity, each byte to be transmitted is numbered. The sequence number tells the
destination which byte in this sequence is the first byte in the segment. During connection
establishment (discussed later) each party uses a random number generator to create an initial
sequence number (ISN), which is usually different in each direction.

Acknowledgment number. This 32-bit field defines the byte number that the receiver of the
segment is expecting to receive from the other party. If the receiver of the segment has
successfully received byte number x from the other party, it returns x + 1 as the
acknowledgment number. Acknowledgment and data can be piggybacked together.
TCP Segment Format
Header length. This 4-bit field indicates the number of 4-byte words in the TCP
header. The length of the header can be between 20 and 60 bytes. Therefore, the
value of this field is always between 5 (5× 4 = 20) and 15 (15× 4 = 60).

Reserved. This is a 6-bit field reserved for future use.

Control. This field defines 6 different control bits or flags. One or more of these
bits can be set at a time. These bits enable flow control, connection establishment
and termination, connection abortion, and the mode of data transfer in TCP.

Window size. This field defines the window size of the sending TCP in bytes.
Note that the length of this field is 16 bits, which means that the maximum size of
the window is 65,535 bytes. This value is normally referred to as the receiving
window (rwnd) and is determined by the receiver. The sender must obey the
dictation of the receiver in this case.
TCP Segment Format
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.
However, the use of the checksum in the UDP datagram is optional, whereas
the use of the checksum for TCP is mandatory. The same pseudoheader, serving
the same purpose, is added to the segment. For the TCP pseudoheader, the
value for the protocol field is 6.

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. There can be up to 40 bytes of optional information in the TCP


header.
Control field

TCP/IP Protocol Suite 37


TCP
Well Known Port
References
Main Reference Session 10:

Forouzan, B.A., (2010).


TCP/IP Protocol Suite, 4th Edition,
Mc.Graw-Hill
Chapter 13, 14, 15

Forouzan, B.A., (2010).


Data Communications and Networking, 4th Edition,
Mc.Graw-Hill
Chapter 23

You might also like