Protocols-N-Layers

Protocols and Layers

A network architecture is a layered graph of protocols.

Layers

First, we break up the complicated operation of sending data from one host to another into layers from low-level to high-level. E.g.

  1. host-to-host connectivity might be a low level layer, right above hardware, that abstracts away complex network topology between two hosts
  2. process-to-process channels might be built on top of this, abstracting away the fact that the network might lose messages

This layering

  • decomposes a complex network into manageable pieces
  • provides modularity

Protocols

Within each layer, however, is potentially multiple different protocols. For example in the process-to-process channels layer, we might desire two different protocols,

  1. request/reply channel for fetching static webpages
  2. message stream channel for streaming live video

A protocol provides a communication service that higher level objects (potentially other protocols) use to exchange messages. Each defines

  • a service interface to other objects on the same computer that want to use its communication services (i.e. its vertical interaction with other layers)
  • a peer interface to its counterpart on another machine. For example the peer interface of HTTP might define how the client peer formats a GET request, and how the server peer responds.
    Note that, aside from the very bottom hardware layer, the peer-to-peer interface isn't used directly. Instead, a protocol passes a message down to a lower-level protocol, and then that lower-level protocol peer-to-peer interface is used.

Headers

Peer-to-peer interaction requires protocol-specific communication, e.g. instructing the peer on how to handle the message once retrieved. This is accomplished by attaching a header to the message before it is passed to the lower level, upon which the next lower level protocl will attach its header, and so on, until ultimately the whole message looks like

H2H HeaderP2P HeaderHTTP HeaderPayload

when it goes across the network (the switches and routers). Those switches and routers can look at the top-most H2H header.

On the receiving peer node, the H2H protocol module inspects and interprets the H2H header, and then stripts it off before passing the P2P-prefixed message to the P2P protocol above, and so on.

The encapsulation is important to enforce! Different protocols should not depend on others, but rather adhere to their own protocol specification. So the HTTP protocol module should not be looking at the P2P headers, as introducing that dependency would break this whole layering and encapslation model.