Transport Layer Notes
23.1 TRANSPORT LAYER
The transport layer is responsible for process-to-process delivery, using protocols like UDP, TCP, and SCTP.
Types of Data Deliveries
Node-to-Node: Data Link Layer
Host-to-Host: Network Layer
Process-to-Process: Transport Layer
Responsibilities of the Transport Layer
Port Addressing
Segmentation and Reassembly
Connection Control
Error Control
Flow Control
23.2 Port Addressing
Port numbers are used to identify specific processes on a host.
IP address selects the host.
Port number selects the process.
IANA Ranges for Port Numbers
Well-known ports: 0 to 1023. These are assigned to common services.
Registered ports: 1024 to 49,151. These can be used by applications.
Dynamic ports: 49,152 to 65,535. These are used for temporary or private ports.
Socket Address
A socket address is a combination of an IP address and a port number. For example, 200.23.56.8:69.
Multiplexing and Demultiplexing
The transport layer uses multiplexing to combine data from multiple processes into a single stream, and demultiplexing to separate the data back into individual streams at the destination.
23.3 Error Control
Error checking occurs at the data link layer for paths within a LAN. For WAN paths, error checking is not performed by the data link layer.
23.4 Protocols in TCP/IP Suite
Application Layer: SMTP, FTP, TFTP, DNS, SNMP, BOOTP
Transport Layer: SCTP, TCP, UDP
Network Layer: IGMP, ICMP, IP, ARP, RARP
Data Link Layer
Physical Layer
Underlying LAN or WAN technology.
23-2 USER DATAGRAM PROTOCOL (UDP)
UDP is a connectionless, unreliable transport protocol. It provides process-to-process communication, adding minimal overhead to IP.
Topics
Well-Known Ports for UDP
User Datagram Checksum
UDP Operation
Use of UDP
Well-Known Ports Used with UDP
Port | Protocol | Description |
|---|---|---|
7 | Echo | Echoes a received datagram back to the sender |
9 | Discard | Discards any datagram that is received |
11 | Users | Active users |
13 | Daytime | Returns the date and the time |
17 | Quote | Returns a quote of the day |
19 | Chargen | Returns a string of characters |
53 | Nameserver | Domain Name Service |
67 | BOOTPS | Server port to download bootstrap information |
68 | BOOTPC | Client port to download bootstrap information |
69 | TFTP | Trivial File Transfer Protocol |
111 | RPC | Remote Procedure Call |
123 | NTP | Network Time Protocol |
161 | SNMP | Simple Network Management Protocol |
162 | SNMP (trap) | Simple Network Management Protocol (trap) |
In UNIX, well-known ports are stored in /etc/services.
Example 23.1:
FTP can use port 21 with either UDP or TCP. SNMP uses ports 161 and 162 for different purposes.
User Datagram Format
Source Port Number: 16 bits
Destination Port Number: 16 bits
Total Length: 16 bits
Checksum: 16 bits
Data
UDP Length = IP Length - IP Header's Length
Pseudoheader for Checksum Calculation
The pseudoheader includes:
32-bit Source IP Address
32-bit Destination IP Address
8-bit Protocol (17 for UDP)
16-bit UDP Total Length
Padding is added to make the data a multiple of 16 bits.
Example 23.2: Checksum Calculation
Demonstrates checksum calculation for a small UDP datagram with 7 bytes of data. Padding is added for the calculation.
UDP Header Example
Given a UDP header in hexadecimal format: 0632000DOOlCE217
Source Port Number:
Destination Port Number:
Total Length:
Data Length: Total Length - 8 (UDP header) =
Client-to-server or vice versa can be determined by the port numbers. Well-known ports (e.g., 13) indicate a server.
Queues in UDP
UDP uses incoming and outgoing queues for both clients and servers.
23-3 TCP
TCP is a connection-oriented protocol that creates a virtual connection between two TCP endpoints for reliable data transfer. It uses flow and error control mechanisms.
Topics
TCP Services
TCP Features
Segment
A TCP Connection
Flow Control
Error Control
Well-Known Ports Used by TCP
Port | Protocol | Description |
|---|---|---|
7 | Echo | Echoes a received datagram back to the sender |
9 | Discard | Discards any datagram that is received |
11 | Users | Active users |
13 | Daytime | Returns the date and the time |
17 | Quote | Returns a quote of the day |
19 | Chargen | Returns a string of characters |
20 | FTP, Data | File Transfer Protocol (data connection) |
21 | FTP, Control | File Transfer Protocol (control connection) |
23 | TELNET | Terminal Network |
25 | SMTP | Simple Mail Transfer Protocol |
53 | DNS | Domain Name Server |
67 | BOOTP | Bootstrap Protocol |
79 | Finger | Finger |
80 | HTTP | Hypertext Transfer Protocol |
111 | RPC | Remote Procedure Call |
Stream Delivery
TCP provides stream delivery, where data is sent as a continuous stream of bytes.
Sending and Receiving Buffers
TCP uses buffers for sending and receiving data. These buffers manage the flow of data between processes.
TCP Segments
Data is transmitted in segments. Each byte is numbered by TCP, starting with a randomly generated number.
Example 23.3: Sequence Numbers
Segment 1: Sequence Number: 10,001 (range: 10,001 to 11,000)
Segment 2: Sequence Number: 11,001 (range: 11,001 to 12,000)
Segment 3: Sequence Number: 12,001 (range: 12,001 to 13,000)
Segment 4: Sequence Number: 13,001 (range: 13,001 to 14,000)
Segment 5: Sequence Number: 14,001 (range: 14,001 to 15,000)
The sequence number field defines the number of the first data byte in that segment. The acknowledgment field defines the number of the next byte a party expects to receive.
TCP Segment Format
Source Port Address: 16 bits
Destination Port Address: 16 bits
Sequence Number: 32 bits
Acknowledgment Number: 32 bits
HLEN: 4 bits
Reserved: 6 bits
Control Flags: 6 bits (URG, ACK, PSH, RST, SYN, FIN)
Window Size: 16 bits
Checksum: 16 bits
Urgent Pointer: 16 bits
Options and Padding
Control Field Flags
URG: Urgent pointer is valid
ACK: Acknowledgment is valid
PSH: Request for push
RST: Reset the connection
SYN: Synchronize sequence numbers
FIN: Terminate the connection
Flag Descriptions
Flag | Description |
|---|---|
URG | The value of the urgent pointer field is valid. |
ACK | The value of the acknowledgment field is valid. |
PSH | Push the data. |
RST | Reset the connection. |
SYN | Synchronize sequence numbers during connection. |
FIN | Terminate the connection. |
Connection Establishment (Three-Way Handshaking)
Client (Active open) sends SYN (seq: 8000)
Server (Passive open) sends SYN + ACK (seq: 15000, ack: 8001)
Client sends ACK (seq: 8000, ack: 15001)
Notes
A SYN segment cannot carry data but consumes one sequence number.
A SYN + ACK segment cannot carry data but consumes one sequence number.
An ACK segment, if carrying no data, consumes no sequence number.
Data Transfer
Client sends data with ACK and PSH flags. The server acknowledges the data, and they exchange data segments.
Connection Termination (Three-Way Handshaking)
Client sends FIN (seq: x, ack: y)
Server sends FIN + ACK (seq: y, ack: x + 1)
Client sends ACK (seq: x, ack: y + 1)
Notes
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.
Half-Close
One side terminates its sending ability while still receiving data.
Sliding Window
Used for efficient transmission and flow control.
Window Size = minimum (rwnd, cwnd)
Notes
TCP sliding windows are byte-oriented.
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.
ACK segments do not consume sequence numbers and are not acknowledged.
Examples
Example 23.4:
Host B has a buffer size of 5000 bytes and 1000 bytes of unprocessed data.
bytes.Example 23.5:
rwnd = 3000 bytes and cwnd = 3500 bytes. The window size is min(3000, 3500) = 3000 bytes.Example 23.6:
cwnd = 20, rwnd = 9. The size of the sender window is min(20, 9) = 9 bytes.
Retransmission
Retransmission occurs if the retransmission timer expires or three duplicate ACK segments have arrived.
Notes
No retransmission timer is set for an ACK segment.
Data may arrive out of order, but TCP guarantees that no out-of-order segment is delivered to the process.
Normal Operation
Segments are sent and acknowledged within a reasonable time frame (e.g., 500ms).
Lost Segment
If a segment is lost, the sender's retransmission timer expires, and the segment is resent.
Fast Retransmission
If the sender receives three duplicate ACKs, it resends the lost segment without waiting for the retransmission timer to expire.
Notes
The receiver TCP delivers only ordered data to the process.
23-4 SCTP
SCTP is a new reliable, message-oriented transport layer protocol designed for Internet applications requiring more sophisticated services than TCP can provide.
Topics
SCTP Services and Features
Packet Format
An SCTP Association
Flow Control and Error Control
Notes
SCTP is a message-oriented, reliable protocol that combines the best features of UDP and TCP.
SCTP Applications
Protocol | Port Number | Description |
|---|---|---|
IUA | 9990 | ISDN over IP |
M2UA | 2904 | SS7 telephony signaling |
M3UA | 2905 | SS7 telephony signaling |
H.248 | 2945 | Media gateway control |
H.323 | 1718, 1719, 1720, 11720 | IP telephony |
SIP | 5060 | IP telephony |
Multiple-Stream Concept
SCTP supports multiple streams within an association, allowing for ordered or unordered delivery of data chunks within each stream.
Notes
An association in SCTP can involve multiple streams.
Multihoming Concept
SCTP supports multihoming, where an association can use multiple IP addresses for each end, providing redundancy and fault tolerance.
Notes
SCTP association allows multiple IP addresses for each end.
Terminology
TSN: Transmission Sequence Number
SI: Stream Identifier
SSN: Stream Sequence Number
Notes
In SCTP, a data chunk is numbered using a TSN.
To distinguish between different streams, SCTP uses an SI.
To distinguish between different data chunks belonging to the same stream, SCTP uses SSNs.
TCP has segments; SCTP has packets.
SCTP Packet Format
Consists of:
Data Header and Options
Control Chunks
Data Chunks
A comparison with TCP:
TCP Segment: Source port, destination port, sequence number, acknowledgment number, control flags, window size, checksum, urgent pointer, options, and data.
SCTP Packet: Source port, destination port, verification tag, checksum, control chunks, and data chunks.
Notes
In SCTP, control information and data information are carried in separate chunks.
Data Chunk Identification
Data chunks are identified by TSN, SI, and SSN.
TSN: Cumulative number identifying the association.
SI: Defines the stream.
SSN: Defines the chunk in a stream.
Notes
Data chunks are identified by three items: TSN, SI, and SSN. TSN is a cumulative number identifying the association; SI defines the stream; SSN defines the chunk in a stream.
Acknowledgment
In SCTP, acknowledgment numbers are used to acknowledge only data chunks; control chunks are acknowledged by other control chunks if necessary.
SCTP Packet Format
General Header (12 bytes)
Chunk 1 (variable length)
Chunk N (variable length)
Notes
In an SCTP packet, control chunks come before data chunks.
General Header
Source Port Address: 16 bits
Destination Port Address: 16 bits
Verification Tag: 32 bits
Checksum: 32 bits
Chunks
Type | Chunk | Description |
|---|---|---|
0 | DATA | User data |
1 | INIT | Sets up an association |
2 | INIT ACK | Acknowledges INIT chunk |
3 | SACK | Selective acknowledgment |
4 | HEARTBEAT | Probes the peer for liveliness |
5 | HEARTBEAT ACK | Acknowledges HEARTBEAT chunk |
6 | ABORT | Aborts an association |
7 | SHUTDOWN | Terminates an association |
8 | SHUTDOWN ACK | Acknowledges SHUTDOWN chunk |
9 | ERROR | Reports errors without shutting down |
10 | COOKIE ECHO | Third packet in association establishment |
11 | COOKIE ACK | Acknowledges COOKIE ECHO chunk |
14 | SHUTDOWN COMPLETE | Third packet in association termination |
192 | FORWARD TSN | For adjusting cumulative TSN |
Notes
A connection in SCTP is called an association.
Association Establishment (Four-Way Handshaking)
Client sends INIT
Server sends INIT ACK with Cookie
Client sends COOKIE ECHO with Cookie
Server sends COOKIE ACK
Notes
No other chunk is allowed in a packet carrying an INIT or INIT ACK chunk. A COOKIE ECHO or a COOKIE ACK chunk can carry data chunks.
Notes
In SCTP, only DATA chunks consume TSNs; DATA chunks are the only chunks that are acknowledged.
Data Transfer
Data chunks are sent with TSNs. The receiver acknowledges with a SACK chunk containing the cumulative TSN.
Notes
The acknowledgment in SCTP defines the cumulative TSN, the TSN of the last data chunk received in order.
Association Termination
Client sends SHUTDOWN
Server sends SHUTDOWN ACK
Server sends SHUTDOWN COMPLETE
Flow Control
Managed through receiver-side and sender-side parameters.
Error Control
Involves retransmission of lost data chunks and handling out-of-order chunks.