List of ports


Transport Layer

Typically an API embedded in Operating System.
e.g. Berkeley UNIX sockets

First true end-to-end layer.
What defines boundary of Transport and Network layers is that Transport code runs only on user machines, not on routers.
Boundary of Network layer is boundary of what routers need to run.

Quality of service:

Transport layer has to manage:

API:

Transport Protocol Data Unit (TPDU)

What transport layers send to each other. Contains the "real" data of the communication.

Remember discussion of packet and frame.

TPDUs (exchanged by transport layer) are contained in packets (exchanged by network layer) which are contained in frames (exchanged by data link layer).



TCP

Internet protocol stack:
TCP - Transport layer for Internet.
IP is Network layer (does the routing). IP packets. IP is unreliable (may lose packets).

TCP provides reliable, connection-oriented service on top of IP.
Provides:

Applications that use TCP:

  1. HTTP
  2. FTP
  3. telnet, ssh
  4. SMTP, POP3


UDP

Internet protocol stack:
UDP - alternative Transport layer for Internet.
Unreliable, connectionless.
No acks and re-transmits.
Faster, but may lose packets, or get damaged packet, and packets may arrive out of order.
But much faster.

Applications that use UDP, not TCP:

  1. Streaming media, e.g. RealAudio and RealVideo.
    Often, streaming client uses its own error-checking to compensate for lost/damaged data.
    RTP can use TCP, but mostly uses UDP.

  2. VoIP
  3. Online multiplayer games
  4. DNS


Usage

As at c.2002, c.95% of all Internet packets were TCP, c.5% UDP, less than 1% other.
UDP use (video, audio streams, VoIP, online games) growing since,
but TCP use (TCP file sharing, TCP torrents, HTTP video streaming, YouTube) also growing since.



6.1.3 Sockets

Sockets are a service provided by transport layer.
Set of primitives to enable a bi-directional comms link between A and B.


Primitive socket commands in TCP.

  1. Server side: Server startup executes SOCKET, BIND, LISTEN.
    LISTEN - allocate queue for multiple simultaneous clients.

    ACCEPT - suspend server until request. When client request arrives: ACCEPT returns.
    Start new socket (thread or process) with same properties as original, this handles the request,
    server goes on waiting on original socket.
    If new request arrives while spawning thread for this one, it is queued.
    If queue full it is refused.

  2. Client side: SOCKET to create. Then CONNECT. When this returns the socket is open.

    Both sides can now SEND, RECEIVE.

    Connection not released until both sides do CLOSE. Typically client does it, server acks.



6.2.1 Ports (also 6.5.2)

Port - Logical (not physical) connection to computer (server).
One hardware link: Many ports.
One host (physical server) can run many services (listening processes) at different addresses.

IP address = Address of a host.
IP address + port = Address of a process (service) on a host.

List of ports.
1 to 65535 (16 bit no).
Ports 1 to 1023 set aside for "well-known" services, e.g.:

Full list:

Server machine may run multiple server processes, each contactable on different port.
Conversely, multiple clients may want to contact same port (e.g. Web server).
Client creates socket at its end. Sends request to server (at port no). Server creates socket at its end dedicated to that client.
One port: Many sockets to that port.



Server code in C

A simple file server in C, explained in 6.1.4:

Infinite loop. Can only be stopped by external kill (end process).
ACCEPT returns - client has connected.
Can both read from and write to the "socket address" sa.

Client sends the file name it wants.
Server writes the file to the socket and then closes the socket.
Back to infinite loop: ACCEPT - suspend waiting for next request.


Client code in C

The client for the file server:

Usage:

$ client host filename 
returns file contents to stdout.



6.2 Transport protocols

We saw previously algorithms for acks, re-transmits and flow control used on frames in Data Link layer (i.e. across a single physical link).
See here and here.

Similar algorithms may be used on higher-level objects to provide a reliable service in Transport layer (i.e. across entire network).
More difficult because instead of a single line (a) the entire network is now in the way (b):



6.5 TCP


TCP header.
See meaning.

Note port nos.
Uses sliding window protocol.
Initially go back n. More recently selective repeat.
Note seq and ack. These refer to next byte expected. Every byte is numbered 0 .. n (and then repeat) in the TCP byte-stream.
n = 232-1 = 4 billion.

TCP checksum (explained here) is quite weak (not CRC).
This is ok since CRC probably also used in Data Link layer (e.g. PPP and Ethernet).
Normal communication sessions will have error-checking in both Data Link and Transport layers.