Salta al contenuto
Note per Studenti Transport Layer - Ports and Multiplexing Report

Transport Layer - Ports and Multiplexing

In questa pagina 6

Role

The network layer (Network Layer and IPv4 AddressingThe network layer delivers datagrams host to host through routers (encapsulation, routing, forwarding); an IPv4 address is 32 bits split into a network prefix and a host suffix, and modern classless addressing (CIDR) gives a block of 2^(32-n) addresses from a.b.c.d/n, with network and broadcast addresses computed through the netmask.Network Layer and IPv4 Addressing →) brings a datagram to the right computer; many programs run on the same computer, and the datagram must reach the right program. That second step is done by transport.

Definition. The transport layer provides logical end-to-end communication between application processes on different hosts. The sender splits application messages into segments and passes them to the network layer; the receiver reassembles them into messages.

The communication is logical: the two application layers behave as if directly connected, whereas in reality many routers and links lie in between. Hence transport protocols are implemented in end systems and not in routers.

Analogy. Twelve children in Ann's house write letters to twelve children in Bill's house: houses are hosts, children processes, letters application messages, Ann and Bill the transport protocol, the postal service the network protocol. The postal service brings the envelope to the right house; Bill then needs the name on the envelope: the port number.

service what it does
process-to-process communication delivers to the destination process, not just the computer
addressing identifies processes by port numbers (client-server paradigm)
encapsulation / decapsulation adds and removes the transport header
multiplexing / demultiplexing many processes share one transport protocol on a host
error control only for reliable protocols (TCP)
flow control only for reliable protocols (TCP)
congestion control only for reliable protocols (TCP)

Port numbers

Hosts are identified by IP addresses, processes by port numbers.

Definition. A port number is a 16-bit integer, from 00 to 216−1=65 5352^{16}-1=65\,535. The destination IP chooses the host; the destination port chooses the process on it.

The server must be findable, so its port is a well-known port; the client picks a temporary ephemeral port (above 1023). Exceptions exist (the DHCP client uses 68: DHCP - Dynamic Host ConfigurationBOOTP (obsolete) statically maps MAC addresses to IP addresses, while DHCP assigns addresses dynamically on lease, even after the operating system has started; the client-server dialogue runs over UDP (server port 67, client port 68) with DHCPDISCOVER, DHCPOFFER, DHCPREQUEST and DHCPACK (plus DHCPRELEASE), and the ACK delivers IP address, netmask, default gateway and DNS server, with lease renewal at 50 percent and rebinding at 87.5 percent of the lease.DHCP - Dynamic Host Configuration →).

range name managed by
00 - 10231023 well-known assigned by ICANN
10241024 - 49 15149\,151 registered not controlled, can be registered
49 15249\,152 - 65 53565\,535 dynamic free temporary or private use

Counts: well-known 1024=2101024=2^{10}; registered 49 151−1024+1=48 12849\,151-1024+1=48\,128; dynamic 65 535−49 152+1=16 384=21465\,535-49\,152+1=16\,384=2^{14}. A browser might use ephemeral source port 51 23451\,234 and destination port 8080 (HTTP) or 443443 (HTTPS). On Unix well-known ports are listed in /etc/services, and only privileged processes can use them.

port application transport
7 Echo UDP, TCP
20, 21 FTP (data, control) TCP
22 SSH TCP
23 Telnet TCP
25 SMTP TCP
53 DNS UDP (TCP for large answers)
67, 68 DHCP (server, client) UDP
80 HTTP TCP
110 POP3 TCP
143 IMAP TCP
161 SNMP UDP
179 BGP TCP
443 HTTPS TCP
520 RIP UDP

Sockets and connection identification

Definition (socket). The pair ⟨IP,port⟩\langle\text{IP},\text{port}\rangle; it selects a host and a process on it.

Property. A connection is uniquely identified by the four-tuple (source port, destination port, source IP, destination IP).

Example. Students A=147.162.10.5A=147.162.10.5 and B=147.162.10.6B=147.162.10.6 open the same page on server S=93.184.216.34S=93.184.216.34: (51234,80,A,S)(51234,80,A,S) and (51234,80,B,S)(51234,80,B,S) are different connections (different IPs). A second tab of AA gets another ephemeral port, e.g. (51240,80,A,S)(51240,80,A,S). The server uses only port 80 for all of them; the four-tuple tells them apart.

Encapsulation: the transport header (PCI) is added to the message; transport packets are called user datagrams (UDP) or segments (TCP). The segment becomes the payload of an IP datagram, whose Protocol field says who gets it (66 TCP, 1717 UDP).

Multiplexing and demultiplexing

A host has one UDP and one TCP, used by many processes. Multiplexing (sender) gathers messages of many processes into one stream of segments, each with its source port; demultiplexing (receiver) delivers incoming segments to the right process by looking at ports.

  • UDP: socket identified by (destination IP, destination port); segments from different sources with the same destination end in the same socket.
  • TCP: socket identified by the whole four-tuple, so a server on one port can serve many clients, one socket per connection.

Example. On SS, port 80 has connections (51234,80,A,S)(51234,80,A,S), (51234,80,B,S)(51234,80,B,S), (51240,80,A,S)(51240,80,A,S). A TCP segment with source port 51234, destination port 80, source IP BB goes to the process of the second connection. NAT with port translation uses the same idea (NAT and Private AddressesPrivate networks (intranets) use TCP/IP with private address blocks (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) that may be reused by different intranets but are never routed in the public Internet; to reach the Internet an intranet needs an application proxy or NAT, a router that translates private to public addresses using a NAT table and per-session mappings: Basic NAT translates only the IP address one to one, NAPT also translates the port so many sessions share one public IP, and Twice NAT adds DNS support and static mappings so sessions can also start from outside.NAT and Private Addresses →).

Flow, error and congestion control

service depends on involves
error loss or corruption of packets only the transport layers of sender and receiver
flow capacity of the receiver (and sender) sender and receiver
congestion the channel and context (the network) the sender, according to the network

Flow. If the producer pushes items faster than the consumer consumes them the consumer is overwhelmed: buffers help (if the sender's buffer is full, transport tells the application to stop; if the receiver's is full it tells the sender to stop).

Error. IP is unreliable; a reliable transport detects and discards corrupted packets, tracks and resends lost ones, removes duplicates and keeps out-of-order packets until the missing one arrives, using a sequence number. With mm bits sequence numbers go from 00 to 2m−12^m-1 (3 bits: 0,…,70,\dots,7; TCP uses 32 bits). Numbers wrap around (modulo 2m2^m), so the ARQ window cannot cover all numbers; TCP uses a modification or combination of stop-and-wait, Go-Back-N and Selective Repeat (ARQ Protocols - Stop-and-Wait, Go-Back-N and Selective RepeatARQ (Automatic Repeat reQuest) makes an error-prone link reliable: the receiver acknowledges (ACK) frames received correctly and the sender retransmits when the timeout expires. Timeouts (against deadlock) and sequence numbers (against duplicates) are needed. With t_G = t_F + 2 tau_p + t_A and error probability p: Stop-and-Wait rho = t_F(1-p)/t_G; Go-Back-N with window N >= t_G/t_F rho = (1-p)/(1+(N-1)p); Selective Repeat rho = 1-p. Efficiency eta = rho I/F. The optimal window is the pipe capacity in packets. For Selective Repeat there is also an optimal frame length: with overhead o and bit error probability P_b, x_opt is about o/2 + sqrt(o/P_b) (shorter frames when the channel errs more).ARQ Protocols - Stop-and-Wait, Go-Back-N and Selective Repeat →).

Congestion. Congestion exists when load exceeds network capacity and router queues overflow: TCP Congestion ControlCongestion arises when fast links feed a slow one, router queues fill and packets are lost or delayed, possibly up to network collapse; TCP controls its congestion window cwnd using loss feedback (timeout or three duplicate ACKs): slow start doubles cwnd every RTT up to the threshold ssthresh, then congestion avoidance adds 1 MSS per RTT, and on a loss ssthresh becomes W/2; variants differ in reaction to three dupACKs: Tahoe restarts from cwnd=1, Reno uses fast recovery (ssthresh=cwnd/2, cwnd=ssthresh+3, +1 per further dupACK), NewReno handles partial ACKs and recovers several losses in one window, SACK acknowledges received blocks and resends only what is missing.TCP Congestion Control →.

Protocols

HTTP, SMTP, FTP, SSH and BGP use TCP; DNS, DHCP, RIP, SNMP and real-time interactive applications use UDP.

Versione ripasso

Teoria collegata