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

TCP Udp

The document discusses transport layer protocols including TCP and UDP. TCP is a connection-oriented protocol that provides reliable, ordered delivery of packets. UDP is a simpler connectionless protocol that does not guarantee delivery or order of packets.

Uploaded by

eesha
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)
17 views

TCP Udp

The document discusses transport layer protocols including TCP and UDP. TCP is a connection-oriented protocol that provides reliable, ordered delivery of packets. UDP is a simpler connectionless protocol that does not guarantee delivery or order of packets.

Uploaded by

eesha
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/ 35

8-1 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.

8.2
•Connection-oriented Requires a session connection (analogous to a phone
call) be established before any data can be sent. This method is often called a
"reliable" network service. It can guarantee that data will arrive in the same
order. Connection-oriented services set up virtual links between end systems
through a network.

•Connectionless Does not require a session connection between sender and


receiver. The sender simply starts sending packets (called datagrams) to the
destination. This service does not have the reliability of the connection-oriented
method, but it is useful for periodic burst transfers.

8.3
8-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.

8.4
Figure 8.9 User datagram format

8.5
Example 1 :The following is a dump of a UDP header in hexadecimal format.

CB84000D001C001C

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?

8.6
Solution:
a. The source port number is the first four hexadecimal digits (CB84), which
means that the source port number is 52100.
b. The destination port number is the second four hexadecimal digits (000D),
which means that the destination port number is 13.
c. The third four hexadecimal digits (001C) 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.

8.7
Note

UDP length
= IP length – IP header’s length

8.8
8-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.

8.9
Note

The bytes of data being transferred in


each connection are numbered by TCP.
The numbering starts with a randomly
generated number.

8.10
Example 2 :Suppose a TCP connection is transferring a file of 5,000 bytes. The first
byte is numbered 10,001. What are the sequence numbers for each segment if data are
sent in five segments, each carrying 1,000 bytes?

8.11
Note

The value in the sequence number field


of a segment defines the
number of the first data byte
contained in that segment.

8.12
Note

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.

8.13
Figure 8.16 TCP segment format

8.14
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
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
Sequence number. This 32-bit field defines the number assigned to the first byte of data
contained in this segment
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.

8.15
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
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.
Checksum. This 16-bit field contains the checksum
Urgent pointer. This 16-bit field, which is valid only if the urgent flag is set, is used
when the segment contains urgent data

8.16
Figure 8.18 Control field

8.17
Table 8.3 Description of flags in the control field

8.18
Flow Control
Flow control assists the reliability of TCP transmission by
adjusting the effective rate of data flow between the two services
in the session. Window Size field in the TCP header specifies the
amount of data that can be transmitted before an
acknowledgement must be received.

8.19
Figure 8.18 Connection establishment using three-way handshaking

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

An ACK segment, if carrying no data,


consumes no sequence number.

8.21
Figure 8.19 Data transfer

8.22
Figure 8.20 Connection termination using three-way handshaking

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

The FIN + ACK segment consumes


one sequence number if it
does not carry data.

8.24
Figure 8.22 Sliding window

rwnd = buffer size − number of waiting bytes to be pulled

8.25
Note

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.

8.26
Example 8.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.

8.27
Example 8.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.

8.28
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.

8.29
Note

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.

8.30
Figure 8.24 Normal operation

8.31
Figure 8.25 Lost segment

8.32
Note

The receiver TCP delivers only ordered


data to the process.

8.33
Figure 8.26 Fast retransmission

8.34
TCP UDP
TCP is a connection-oriented
Connection UDP is a connectionless protocol.
protocol.
UDP has no inherent order as all
Ordering of TCP rearranges data packets in
packets are independent of each
data packets the order specified.
other.
Speed of The speed for TCP is slower UDP is faster because there is no
transfer than UDP. error-checking for packets.
There is absolute guarantee
that the data transferred There is no guarantee that the
Reliability remains intact and arrives in messages or packets sent would
the same order in which it was reach at all.
sent.
Header Size TCP header size is 20 bytes UDP Header size is 8 bytes.

8.35
TCP UDP
Streaming
Data is read as a byte stream, Packets are sent individually
of data
TCP does Flow Control. TCP
Data Flow UDP does not have an option for
requires three packets to set up a
Control flow control
socket connection,

Acknowle
Acknowledgement segments No Acknowledgment
dgement

8.36

You might also like