Week-10 Transport Service - TCP and UPD
Week-10 Transport Service - TCP and UPD
Slide
2
Slide
3
Client/Server Paradigm
The most common process-to-process communication is
though the Client/Server Paradigm.
Client : A process on the local host
Server : A process on the remote host to provide services.
Local process
Remote host
Remote process
5
Addressing
A frame in the data link layer needs a destination MAC
address.
At the network layer, we need an IP address.
At the transport layer, we need a transport layer address,
called a Port number to choose among multiple processes
running on the host.
In the Internet model
The port No. : 0~65,535 (16-bit integer)
Well-known port number
Universal port No. for server (fixed value, ranging : 0 ~1,023)
Ephemeral port number
A port No. chosen randomly by the transport layer SW running
on the client host.
6
Addressing
Port number
Addressing
IP addresses Versus Port numbers
Controlled by IANA.
Registered Port
Ranging : 1,024 ~ 49,151
Dynamic Port
Ranging : 49,152 ~ 65,535
Socket Addresses
The combination of an IP address and a port
number.
A transport layer protocol needs a pair of socket
addresses: the client socket address and the server
socket address.
10
Connection-Oriented Service
A connection is first established between the
sender and the receiver.
Data are transferred.
At the end, the connection is released.
TCP and SCTP are connection-Oriented protocols.
11
Reliable Service
If the application layer program needs reliability, we use a
reliable transport protocol such as TCP and SCTP.
This means a slower and more complex service.
Unreliable Service
If the application layer program does not need reliability
because it uses its own flow and error control mechanism or
it needs fast service or the nature of the service does not
demand flow and error control (real-time application), then
unreliable protocol such as UDP can be used.
Do we need reliability control at the transport layer, even the
data link layer is reliable and has flow and error control ?
The answer is yes.
The network layer in the Internet is unreliable (best-effort
delivery), we need to implement reliability at the transport
layer.
12
13
15
16
User Datagram
Including fixed 8 byte header
Connectionless Services
UDP provides a connectionless services that each
datagram sent by UDP is an independent datagram.
Flow and Error Control
There is no flow control and hence no window
mechanism.
There is no error control mechanism in UDP except for
the checksum.
Encapsulation and Decapsulation
The UDP protocol encapsulates and decapsulates
messages in an IP datagram.
19
20
22
23
24
Segments
At the transport layer, TCP groups a number of
bytes together into a packet called a segment.
TCP adds a header to each segment (for control
purposes) and delivers the segment to the IP layer
for transmission.
The segments are encapsulated in IP datagrams
and transmitted.
This entire operation is transparent to the
receiving process.
Segments received out of order, lost, or corrupted
may be resent.
25
TCP Segments
26
Full-Duplex Service
TCP offers full-duplex service
After two application programs are connected
to each other, they can both send and receive
data.
Piggybacking
When a packet is going from A to B, it can also
carry an acknowledgment of the packets
received from B
27
Connection-Oriented Services
1. A’s TCP informs B’s TCP and gets approval from
B’s TCP
2. A’s TCP and B’s TCP exchange data in both
directions
3. After both processes have no data left to send
and the buffers are empty, two TCPs destroy
their buffers
Reliable Service
TCP uses the acknowledgment mechanism to
check the safe and sound arrival of data
28
Byte numbers
There is no field for a segment number value.
Instead, there are two fields called the sequence
No. and the acknowledgment No. These two
fields refer to the byte No.
All data bytes being transferred in each
connection are numbered by TCP.
The numbering starts with a randomly generated
number.
Number range for first byte : 0 ~ 2 32 -1
Byte numbering is used for flow and error control.
29
Sequence number
After the bytes have been numbered, TCP assigns
a sequence number to each segment that is being
sent.
Segment number for each segment is number of
the first byte carried in that segment.
30
Note
31
Acknowledgment Number
32
33
34
35
Acknowledgment number
The byte number that the sender of the segment is expecting to
receive from the other party.
If the source of the segment has successfully received byte number
x from the other party, it defines x+1 as the acknowledgment
number
Header length
Indicating the number of 4-byte words in the TCP header
the value between 5 and 15 (20 and 60 bytes)
Reserved
For future use
36
Control
Enabling flow control, connection establishment and
termination, and mode of data transfer in TCP
37
38
Window size
defining the size of the window, in bytes, that the other
party must maintain.
maximum size of window : 65,535 bytes
Checksum : same as UDP
Urgent pointer
used when the segment contains urgent data
defining the number 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 : 40 bytes
39
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.
You may wonder how TCP, which uses the services of IP, a
connectionless protocol, can be connection-oriented.
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.
41
The client sends the 1st segment, a SYN segment, in which only the
SYN flag is set.
The server sends the 2nd segment, a SYN+ACK segment, with 2 flag
bits set: SYN and ACK.
The client sends the 3rd segment. This is just an ACK segment. 42
Simultaneous Open
Simultaneous Open may occur when 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.
SYN Flooding Attack
SYN Flooding Attack happens when a malicious attacker
sends a large number of SYN segments to a server,
pretending that each of them is coming from a different
client by faking the source IP addresses in the data-grams.
The 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.
43
44
Pushing Data
The application program at the sending site can request a push
operation that the sending TCP must not wait for the window to
be filled.
It must create a segment and send it immediately.
Urgent Data
When the sending application program wants a piece of data to be
read out of order by the receiving application program.
Sender can send a segment with the URG bit set.
When the receiving TCP receives a segment with the URG bit set, it
extracts the urgent data from the segment, using the value of the
pointer, and delivers them, out of order, to the receiving
application program.
45
The client TCP, after receiving a close command from the client process,
sends the 1st segment, a FIN segment in which the FIN flag is set.
The server TCP, after receiving the FIN segment, inform its process of the
situation and sends the 2nd 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. 46