This post briefly discusses about the layers that are processed at the end nodes (sending and receiving computers) and at the intermediate nodes (Layer1 Hubs/repeaters, Layer2 switches, Layer3 Routers) when a data unit (packet) is transferred between the end nodes.
The Hybrid layering model is used as the reference to illustrate the processing. To summarize, the layering process happens as follows:
At the end nodes, processing happens at all the layers. In a hybrid model, this means the application, transport, network, datalink and physical layers are all involved.
At the intermediate nodes,
- If the intermediate node is a physical layer device like repeater/hub, then the device confines its processing to the physical layer (bits). It does not try to interpret the rest of the higher layers information like datalink, network, transport and application headers.
- If the intermediate node is a Layer2 switch, then the L2 switch examines and processes only the datalink and physical layer headers/trailers of a data unit. It does not process the rest of the higher layers information like network, transport and application headers.
- If the intermediate node is a Layer3 router, then the L3 router examines and processes only the Network, datalink and physical layer headers/trailers of a data unit. It does not process the rest of the higher layers information like transport and application headers.
The diagram given below illustrates the layering processes at the end nodes and at the intermediate nodes:
As seen from the diagram above,
- at the sending node, the actual application data is processed and encapsulation happens first at the application layer (application protocol header is added to the actual data that is to be transmitted), then at the transport layer (transport header with L4 protocol, source port, destination port etc. are added), then at the network layer (IP header with source IP address, destination IP address etc. are added), then at the datalink layer (packet is converted into frames by adding a frame header with source and destination MAC address and a frame trailer with checksum) and then at the physical layer (where the frame is treated as a sequence of bits and transmitted through the wireless/wired media to an adjacent neighbor).
- at the L2 switches, the incoming data unit is processed by the physical and datalink layers. The data unit’s frame header would typically be changed based on the media type of the outgoing physical layer interface through which the data unit has to leave the L2 switch.
- at the L3 Router, the incoming data unit is processed by the bottom three layers, namely physical, datalink and network layers, so as to send out the packet via. an appropriate outgoing interface. The processing in a router would typically result in updating one or two fields in the network header and also in updating the frame header to match that of the outgoing physical interface.
- at the receiving end, all the layers are involved, with the decapsulation process happenning in the reverse order to that at the sending end. The physical layer assembles the bits of a data unit and hands it as a frame to the datalink layer. The datalink layer removes the frame header and trailer and hands the packet to the network layer. The network layer processes and removes the packet header and hands the data unit (segment) to the appropriate transport layer protocol (TCP/UDP). The transport layer reads the transport header and gives the segment to the appropriate application layer protocol after removing the tranport header. The application layer finally process the application data after examining and decapsulating the application header.