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:
-
Often quality of service provided by Network layer
is out of our control
- because it involves Network layer on many routers
across the Internet, which we do not own
(the carriers own them).
These have errors, lose packets, crash, etc.
To deal with poor service, we can't change Network layer
- We don't own those machines.
Our only option is to put a further layer on top of
Network layer to try to improve quality of service.
-
Transport layer
tries to provide reliable service
to Application layer.
Transport service can be more reliable than
underlying Network service.
Unreliability of Network service is hidden from higher layer.
-
This is what we mean when we said previously that
error-recovery can be done in higher
(Transport) layer.
e.g. TCP.
Transport layer has to manage:
- acks (or lack of ack)
- timers
- re-transmits
- and hide this from higher layer
API:
-
Transport layer
provides API
for application programmers.
Library calls are independent of the underlying network.
Application-layer code should work on many different networks.
-
Transport is the real boundary of the layered model,
the first one that really hides the network from higher layers.
Layers 1-4 - "transport service provider"
Higher layers - "transport service user"
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).
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:
- acks of IP packets
- timers and timeouts
- re-transmits
- re-ordering of packets into correct sequence at receiver
before passed to higher layer
(have to wait for missing packet before send all up to higher layer
- we may not want this wait - e.g. media stream)
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 fast since, though.
Applications that use TCP:
- HTTP
- FTP
- telnet, ssh
- 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:
- Streaming media, e.g.
RealAudio and RealVideo.
Often, streaming client uses its own error-checking
to compensate for lost/damaged data.
- VoIP
- Online multiplayer games
- DNS
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.
- 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.
- 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.
1 to 65535 (16 bit no).
Ports 1 to 1023 set aside for
"well-known"
services, e.g.:
- 20 - ftp data
- 21 - ftp commands
- 22 - ssh
- 23 - telnet
- 25 - SMTP
- standard for email transmission from node to node
- 80 - http
- 110 - POP3
- retrieve email to local client
- 8080 - http alternate
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.