Layering
The internet and POTS are complex and require vast amounts of software. Hence, structuring principals are used to achieve:
- Modularity, allowing software re-use
- Independence of network technologies (transparency)
- Separation of concerns
- Correctness
Networking software is layered - layer
- The SAP is a service access point - an interface through which layer
will provide a service to layer - Layer
can provide multiple SAPs - e.g. UDP: the SAP will be the socket API (and the associated port number)
- Layer
- Layer
’s protocol entity is the implementation of layer . The protocol entity cannot communicate with the other host’s protocol entity (at the same level) directly; instead, it must use the service provided by layer to communicate with the other host indirectly - However, the protocol entity can act as if this is the case
- Layer
must never make any assumptions about what layer is doing
General layout of Layer -PDU (Protocol Data Unit)
| N-protocol header | N + 1 data (N-SDU) | N trailer |
- The
-PDU/packet is constructed by the -protocol entity - It carries the data given by layer
for transmission; called the service data unit/payload/user data - The
-protocol entity adds a header containing control information relevant to the receiving layer - It may also add a trailer (usually a checksum)
Thus, going down the stack, each layer sandwiches the
| N-2 hdr | N-1 hdr | N hdr | N+1 data | N trl | N-1 trl | N-2 trl|
The receiver does the opposite, with each layer removing its header/trailer before handing the payload to the upper layer.
OSI Seven Layer Model
OSI: Open Systems Interconnection. A commercial failure, but the terminology and layering architecture/concepts are foundational to networking.
- Physical layer
- Link layer
- Network layer
- Transport Layer
- Session layer
- Presentation layer
- Application layer
If there are two end hosts, A and B, and a router in between:
- The lowest two layers, physical and link, are single-hop scope, exchanging PDUs only between two physically connected hosts
- The network layer uses hop-by-hop communication to achieve end-to-end communication
- Routers work only on the lowest three layers
- Routers are stupid; intelligence in the end hosts
- The upper four layers, network, transport, session and presentation, exchange PDUs between end hosts; purely concerned with end-to-end transmission
Physical (PHY)
Transmission of digital data over a physical medium using modulated waveforms/signals.
Often requires the specification of:
- Cable types/frequencies
- Connectors
- Electrical specifications
- Modulation/demodulation and signal specification
- Carrier or bit synchronization methods
Link layer
Responsible for reliable transfer of messages over a physical link. Messages at this layer are called frames.
Often requires the specification of:
- Framing: delineation of frame start/end, frame size, frame format
- Error control (coding or retransmission)
- Error-correction coding sometimes regarded as PHY functionality
- Medium access control
- Allocating the right to send on channels with multiple senders
- Flow control: avoiding overwhelming a slow receiver
Network layer
Provides link technology-independent abstraction of the entire network to other layers. Handles addressing and routing and end-to-end delivery of messages.
Messages at this layer and above are called packets.
Often requires the specification of:
- Addressing format
- Exchange of routing information and route computation
- Depending on technology: establishment, maintenance and teardown of connections
Transport Layer
Provides reliable, in-sequence and transparent end-to-end transfer; gives programming abstractions to higher layers.
Often requires the specification of:
- Error control procedures (again)
- Link layer protects against transmission error; the router can still lose the packet (e.g. if it has no resources available)
- Flow control procedures (again)
- Link layer does flow control for stations one hop apart; transport layer does end-to-end flow control
- Congestion control procedures (sometimes considered a network-layer issue)
- Protect network against overloading
Session & Presentation Layers
No one really knows what these are.
Session layer:
- Establishes communication sessions between applications
- Can involve several transport layer connections between the same two endpoints to increase data transfer rates. They may run either sequentially or in parallel
- May control the way two partners interact (e.g. alternatingly)
Presentation layer:
- translation between different representation of data types (endian conversion)
Application Layer
Application support functions (high-level APIs) used in many applications. Applications sit on top of this layer.
Examples include file transfer services, directory services, transaction processing support (e.g. two-phase commit)
TCP/IP Reference Model
Broadly equivalent to OSI model, but with the session and representation layers removed.
- Physical Layer
- Network Interface
- Internet
- Transport Layer
- Application
Once again, routers only implement the lowest three layers, which are kept simple. This allows many things to be implemented in hardware, allowing routers to keep up with the deluge of packets.
Application Layer
Protocols such as SMTP, HTTP, FTP.
Transport Layer
- Provides end-to-end communications to applications
- Offers its services through the socket interface (TCP, UDP, etc.)
- SAPs are called ports; used for application multiplexing:
- Several applications/processes can use the transport service
- Port bound to one application
- PDUs generated by TCP/UDP called segments
- TCP has mechanisms for:
- Error control (retransmission-based) and in-order delivery
- Flow control
- Congestion control
- Packet loss used as sign of congestion; sender will reduce rate
Internet Layer
IP:
- PDUs are called datagrams
- All higher-layer segments are encapsulated in datagrams
- Specifies an addressing scheme
- Provides end-to-end delivery of datagrams (forwarding)
- Does not specify how routing is done; left to dedicated protocols
- Has no mechanisms for error, flow or congestion control
- Simple, so IP datagrams can be sent over any network interface
- IP over everything
Physical and Network Interface Layer
Network interface layer:
- Similar to link layer
- Accepts IP datagrams and delivers them over a physical link
Service Providers and Service Users
An
The service user and provider:
- Talk to each other through service primitives
- Must obey rules in the usage of services (e.g. open file before reading from it)
There are standard service primitives for a service.
Confirmed Service
- Host A’s service user issues a
S.requestservice primitive to the service provider (possibly with some user data) - The service provider at host A generates one or more PDUs (packets) and sends them to host B
- The service provider at host B receives the PDU and generates a
S.indicationprimitive to the service user - The service user processes the request and prepares a response, passing it to the service provider through a
S.responseprimitive - The service provider generates a response PDU, sending it to host A’s service provider
- Host A’s service provider sends a
S.confirmprimitive to service user
Unconfirmed Service
The first three steps: S.request, PDU sent to B, then S.indication. Service user A does not know if their request has reached B’s service user.
Confirmed Delivery Service
Host B’s service provider simultaneously sends a S.indication to its service user and an acknowledgement packet to A’s service, which will generate a S.confirm packet to the service user.
Thus, A’s service user knows that B’s service provider received the request, but not if the service user successfully processed it.
Multiplexing
Allows several
To do this, the
The sending
Splitting
- Allows a single
protocol entity to transmit data over several SAPs - Thus, the
protocol entity must make scheduling decisions to decide which SAP to use for a given PDU - Mechanisms for sequencing may be necessary
Fragmentation and Reassembly
- PDUs may have a limited size: on lower layers, this is usually for physical reasons (e.g. Ethernet)
- To make PDU sizes transparent to higher layers, the SAP may accept large packets and partition the data into several
PDUs, called fragments (each with its own header/trailer), and transmit them separately - The fragments must be numbered so the receiver can reassemble them
- What happens if fragments are lost? IP does not have retransmission, so it must conclude after some time that a fragment will not arrive. Then, it can free the buffer (the buffer needs enough space for all the fragments, even if they have not arrived). Otherwise, malicious actor could cause DOS
Blocking and Deblocking
- Some higher level produce very small
-PDU - Thus, the transmitter may wait until several
-SDUs are present, blocking the requests, before putting them into a single SDU to save overhead - Receiver entity must deblock the
-PDU into several -SDUs using the markers placed into the PDU by the transmitter. - When should the sender stop collecting SDUs and start sending?
Sequence Numbers
- An
-entity can maintain a sequence number - For each new PDU the sequence number is written into the
-PDU, then incremented - Allows the receiver to:
- Detect duplicate PDUs
- Detect lost PDUs (and possibly request retransmission)
- Put
-PDUs back into the right order when reordered by the network
- Implementation issues:
- Overflowing
- Choice of initial sequence number