Transport Layer

Independent of what application protocol is used between two systems, or how the data is encoded, compressed, encrypted or whether the application keeps track of a session or not, all data goes through the transport layer.

The transport layer is what allows multiple applications to use one network connection simultaneously. The most commonly used transport protocols are:

  • User Datagram Protocol (UDP)

  • Transmission Control Protocol (TCP)

Both TCP and UDP provide segmentation. Data is split into TCP segments or UDP datagrams, which are then send or received via the network layer.

../_images/segmentation.png

Ports

Segments are addressed from and to a port specified using a port number. TCP and UDP support up to 65535 ports per network connection.

The Internet Assigned Numbers Authority (IANA) maintains a public registry of reserved port numbers.

0 - 1023:

Reserved for privileged services and well-known services (see IANA)

Port

Protocol

20

File Transfer Protocol (FTP) Data Transfer

21

File Transfer Protocol (FTP) Command Control

22

Secure Shell (SSH) Secure Login

25

Simple Mail Transfer Protocol (SMTP) E-mail routing

53

Domain Name System (DNS) service

80

Hypertext Transfer Protocol (HTTP)

123

Network Time Protocol (NTP)

143

Internet Message Access Protocol (IMAP)

443

HTTP Secure (HTTPS) Encrypted HTTP

1024-49151:

User or registered ports

49152-65535:

Dynamic (ephemeral) or private ports

Sockets

Applications use a transport protocol by creating a socket that binds to a specific port with a given protocol. This is an operation provided by the operating system.

The source port number and destination port number do not have to match. Typically servers use a fixed port number, determined by what service they provide. Clients on the other hand may use any available port number.

Both source and destination port are part of the datagram/segment header. Each datagram/segment is then forwarded to the network layer.

../_images/sockets.png

Datagrams/segments received by the network layer from lower layers are forwarded to the transport layer. Based on the destination port and the transport protocol, the segments are reassembled and the data sent to a socket that is listening to that port.

Protocols