Unit 5B TL - TCP, SCTP
Unit 5B TL - TCP, SCTP
Unit 5B TL - TCP, SCTP
Chapter 23
Process-to-Process Delivery:
UDP, TCP
23.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
23-3 TCP
23.2
Table 23.2 Well-known ports used by TCP
23.3
TCP Services
◼ Process-to-Process Communication –
TCP provides process to process communication, i.e, the transfer of data takes
place between individual processes executing on end systems. This is done
using port numbers or port addresses. Port numbers are 16 bit long that help
identify which process is sending or receiving data on a host.
◼ Stream oriented –
This means that the data is sent and received as a stream of bytes(unlike UDP
or IP that divides the bits into datagrams or packets). However, the network
layer, that provides service for the TCP, sends packets of information not
streams of bytes. Hence, TCP groups a number of bytes together into
a segment and adds a header to each of these segments and then delivers
these segments to the network layer.
◼ At the network layer, each of these segments are encapsulated in an IP packet
for transmission.
◼ The TCP header has information that is required for control purpose which will
be discussed along with the segment structure.
◼ Reliability –
TCP is reliable as it uses checksum for error detection
◼ It attempts to recover lost or corrupted packets by re-transmission,
acknowledgement policy and timers.
◼ It uses features like byte number and sequence number and
acknowledgement number so as to ensure reliability.
◼ Also, it uses congestion control mechanisms.
23.5
TCP Services
◼ Multiplexing –
TCP does multiplexing and de-multiplexing at the sender and receiver
ends respectively as a number of logical connections can be established
between port numbers over a physical connection.
23.6
Figure 23.13 Stream delivery
23.7
Figure 23.14 Sending and receiving buffers
23.8
Figure 23.15 TCP segments
23.9
Note
23.10
Example 23.3
23.11
TCP Features
◼ TCP is reliable protocol. That is, the receiver always sends either positive
or negative acknowledgement about the data packet to the sender, so
that the sender always has bright clue about whether the data packet is
reached the destination or it needs to resend it.
◼ TCP ensures that the data reaches intended destination in the same
order it was sent.
◼ TCP is connection oriented. TCP requires that connection between two
remote points be established before sending actual data.
◼ TCP provides error-checking and recovery mechanism.
◼ TCP provides end-to-end communication.
◼ TCP provides flow control and quality of service.
◼ TCP operates in Client/Server point-to-point mode.
◼ TCP provides full duplex server, i.e. it can perform roles of both receiver
and sender.
23.12
Note
23.13
Note
23.14
Figure 23.16 TCP segment format
23.15
TCP Segment Format
◼ Source Port (16-bits) - It identifies source port of the application
process on the sending device.
◼ Destination Port (16-bits) - It identifies destination port of the
application process on the receiving device.
◼ Sequence Number (32-bits) - Sequence number of data bytes of a
segment in a session.
◼ Acknowledgement Number (32-bits) - When ACK flag is set, this
number contains the next sequence number of the data byte expected
and works as acknowledgement of the previous data received.
◼ Header length (4-bits) - This field implies both, the size of TCP
header (32-bit words) and the offset of data in current packet in the
whole TCP segment.
◼ Reserved (6-bits) - Reserved for future use and all are set zero by
default.
23.16
TCP Segment Format
◼ Flags (1-bit each)
◼ URG - It indicates that Urgent Pointer field has significant data and should
be processed.
◼ ACK - It indicates that Acknowledgement field has significance. If ACK is
cleared to 0, it indicates that packet does not contain any
acknowledgement.
◼ PSH - When set, it is a request to the receiving station to PUSH data (as
soon as it comes) to the receiving application without buffering it.
◼ RST - Reset flag has the following features:
◼ It is used to refuse an incoming connection.
23.17
Figure 23.17 Control field
23.18
Table 23.3 Description of flags in the control field
23.19
TCP Segment Format
◼ Windows Size - This field is used for flow control between two
stations and indicates the amount of buffer (in bytes) the receiver
has allocated for a segment, i.e. how much data is the receiver
expecting.
◼ Checksum - This field contains the checksum of Header, Data
and Pseudo Headers.
◼ Urgent Pointer - It points to the urgent data byte if URG flag is
set to 1.
◼ Options - It facilitates additional options which are not covered
by the regular header. Option field is always described in 32-bit
words. If this field contains data less than 32-bit, padding is used
to cover the remaining bits to reach 32-bit boundary.
23.20
A TCP Connection
◼ A 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.
◼ Unlike TCP, IP is unaware of this retransmission. If a segment
arrives out of order, TCP holds it until the missing segments
arrive; IP is unaware of this reordering.
23.21
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.
◼ Three-Way Handshaking
◼ The connection establishment in TCP is called three way
handshaking.
◼ The process starts with the server. The server program tells its TCP that
it is ready to accept a connection. This is called a request for a passive
open. Although the server TCP is ready to accept any connection from
any machine in the world, it cannot make the connection itself.
◼ 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.
23.22
Figure 23.18 Connection establishment using three-way handshaking
• An ACK segment, if
carrying no data,
consumes no sequence
number.
23.23
Data transfer
◼ After connection is established, bidirectional data transfer can take
place. The client and server can both send data and acknowledgments.
◼ The acknowledgment is piggybacked with the data.
◼ Example:
◼ 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.
◼ Note the values of the sequence and acknowledgment numbers. The data
segments sent by the client have the PSH (push) flag set so that the server
TCP knows to deliver data to the server process as soon as they are
received.
◼ The segment from the server, on the other hand, does not set the push flag.
◼ Most TCP implementations have the option to set or not set this flag.
23.24
Figure 23.19 Data transfer
23.25
◼ Pushing Data
◼ The sending TCP uses a buffer to store the stream of data coming from the
sending application program.
◼ The sending TCP can select the segment size.
◼ The receiving TCP also buffers the data when they arrive and delivers them to
the application program when the application program is ready or when it is
convenient for the receiving TCP. This type of flexibility increases the efficiency
of TCP.
◼ Delayed transmission and delayed delivery of data may not be acceptable
by the application program. TCP can handle such a situation.
◼ The application program at the sending site can request a push operation. This
means that the sending TCP must not wait for the window to be filled. It must
create a segment and send it immediately. The sending TCP must also set the
push bit (PSH) to let the receiving TCP know that the segment includes data that
must be delivered to the receiving application program as soon as possible and
not to wait for more data to come.
◼ Although the push operation can be requested by the application program, most
current implementations ignore such requests. TCP can choose whether or not to
use this feature.
23.26
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.
23.27
Figure 23.20 Connection termination using three-way handshaking
23.28
GO TO 37
Note
23.29
Note
23.30
Note
In modern implementations, a
retransmission occurs if the
retransmission timer expires or three
duplicate ACK segments have arrived.
23.31
Note
23.32
Note
23.33
Figure 23.24 Normal operation
23.34
Figure 23.25 Lost segment
23.35
Note
23.36
Compare TCP and UDP
23.37
23-4 SCTP
23.38
Note
23.39
Services of SCTP
◼ Services offered by SCTP to the application layer
processes.
◼ Process-to-Process Communication
◼ Multiple Streams
◼ Multihoming
◼ Full-Duplex Communication
◼ Connection-Oriented Service
◼ Reliable Service
23.40
Services of SCTP
◼ Services offered by SCTP to the application layer processes.
Process-to-Process Communication
SCTP uses all well-known ports in the TCP space. Table 23.4 lists some
extra port numbers used by SCTP.
23.41
Services of SCTP
◼ Services offered by SCTP to the application layer processes.
Multiple Streams
◼ Each connection between a TCP client and a TCP server involves one single
stream.
◼ Problem with this approach is that a loss at any point in the stream blocks
the delivery of the rest of the data.
◼ This can be acceptable when we are transferring text; it is not when we are
sending real-time data such as audio or video.
◼ SCTP allows multistream service in each connection, which is called
association in SCTP terminology.
◼ If one of the streams is blocked, the other streams can still deliver their
data.
◼ The idea is similar to multiple lanes on a highway. Each lane can be used
for a different type of traffic.
◼ For example, one lane can be used for regular traffic, another for car pools.
If the traffic is blocked for regular vehicles, car pool vehicles can still reach
their destinations. Figure 23.27 shows the idea of multiple-stream delivery.
23.42
Figure 23.27 Multiple-stream concept
23.43
Note
23.44
Services of SCTP
Multihoming
◼ A TCP connection involves one source and one destination IP address.
◼ This means that even if the sender or receiver is a multihomed host
(connected to more than one physical address with multiple IP addresses),
only one of these IP addresses per end can be utilized during the
connection.
◼ An SCTP association, on the other hand, supports multihoming service.
◼ The sending and receiving host can define multiple IP addresses in each
end for an association.
◼ In this fault-tolerant approach, when one path fails, another interface can
be used for data delivery without interruption.
◼ This fault-tolerant feature is very helpful when we are sending and
receiving a real-time payload such as Internet telephony.
◼ Figure 23.28 shows the idea of multihoming.
23.45
Services of SCTP
Multihoming
◼ In Fig 23.28, the client is connected to two local networks with two IP addresses
◼ The server is also connected to two networks with two IP addresses.
◼ The client and the server can make an association, using four different pairs of IP
addresses.
◼ However, in the current implementations of SCTP, only one pair of IP addresses can
be chosen for normal communication;
◼ Alternative is used if the main choice fails.
◼ In other words, at present, SCTP does not allow load sharing between different
paths.
23.46
Note
23.47
Services of SCTP
Full-Duplex Communication
◼ Like TCP, SCTP offers full-duplex service, in which data can flow in both directions at
the same time.
◼ Each SCTP then has a sending and receiving buffer, and packets are sent in both
directions.
Connection-Oriented Service
◼ Like TCP, SCTP is a connection-oriented protocol.
◼ When a process at site A wants to send and receive data from another process at site B,
the following occurs:
◼ 1. The two SCTPs establish an association between each other.
◼ 2. Data are exchanged in both directions.
◼ 3. The association is terminated.
Reliable Service
◼ SCTP, like TCP, is a reliable transport protocol.
◼ It uses an acknowledgment mechanism to check the safe and sound arrival of data.
23.48
Note
23.49
Note
23.50
Figure 23.29 Comparison between a TCP segment and an SCTP packet
23.51
Figure 23.30 Packet, data chunks, and streams
23.52
Note
23.53
Note
23.54
Figure 23.31 SCTP packet format
23.55
Note
23.56
Figure 23.32 General header
23.57
Table 23.5 Chunks
23.58
An SCTP Association
◼ SCTP, like TCP, is a connection-oriented protocol.
◼ However, a connection in SCTP is called an association to emphasize multihoming.
◼ Association Establishment
◼ Association establishment in SCTP requires a four-way handshake.
◼ A process, normally a client, wants to establish an association with another
process, normally a server, using SCTP as the transport layer protocol.
◼ SCTP server needs to be prepared to receive any association (passive open).
◼ Association establishment, however, is initiated by the client (active open).
◼ SCTP association establishment is shown in Figure 23.33. The steps, in a normal
situation, are as follows:
◼ 1) Client sends the first packet, which contains an INIT chunk.
◼ 2) Server sends the second packet, which contains an INIT ACK chunk.
◼ 3) Client sends the third packet, which includes a COOKIE ECHO chunk. This
◼ is a very simple chunk that echoes, without change, the cookie sent by the server.
◼ SCTP allows the inclusion of data chunks in this packet.
◼ 4) Server sends the fourth packet, which includes the COOKIE ACK chunk that
◼ acknowledges the receipt of the COOKIE ECHO chunk. SCTP allows the inclusion
◼ of data chunks with this packet.
23.59
Figure 23.33 Four-way handshaking
23.60
Note
23.61
Note
23.62
Note
23.63
Figure 23.34 Simple data transfer
23.64
An SCTP Association
◼ Data Transfer
◼ The whole purpose of an association is to transfer data between two ends.
◼ After the association is established, bidirectional data transfer can take place.
◼ The client and server can both send data. Like TCP, SCTP supports piggybacking.
◼ Association Termination
◼ In SCTP, like TCP, either of the two parties involved in exchanging data (client or
◼ server) can close the connection.
◼ If one end closes the association, the other end must stop sending new
◼ data.
◼ If any data are left over in the queue of the recipient of the termination request,
◼ they are sent and the association is closed.
◼ Association termination uses three packets, as shown in Figure 23.35.
◼ Although the figure shows the case in which termination is initiated by the client, it
can also be initiated by the server.
23.65
Note
23.66
Figure 23.35 Association termination
23.67
Congestion Control in SCTP
SCTP uses the same strategies for congestion control as TCP. SCTP uses slow
start, congestion avoidance, and congestion detection phases. SCTP also uses
fast retransmission and fast recovery.
23.68