A protocol is a set of rules and conventions agreed upon and followed by the communicating entities for data communication. A protocol outlines the what, how and when of a communication.
The three aspects of a protocol are −
Most networks are organized as a stack of layers, one on the top of another. The number of layers and their names vary from network to network. Each layer has a specified function and adheres to specified protocols. Thus we obtain a stack of protocols.
The following figure illustrates a four-layer network −
The above figure represents communication between Device A and Device B. The data stream from one device to the other is not sent directly but has to pass through a number of layers. The layers in the same levels are called peers and have a set of protocols for communication. Between each adjacent layer is an interface that defines the services that are being offered by a lower layer to the next higher layer. The dotted arrows depict virtual communication between peer layers, while the solid arrows represent the physical communications between the adjacent layers.
Let us consider a situation where Device A wants to send a message to Device B. Device A passes its information to the highest layer. As soon as a data stream reaches a layer, it performs some specified functions on it and passes it to the layer below. This continues until the data stream reaches the lowest layer. Layer 1 passes a bit stream of 0s and 1s to the physical medium that communicates it to the Layer 1 of the receiving end. Each layer in the receiving end performs certain functions on the data stream adhering to the protocol with its peer and passes it to the layer above. This continues until the information reaches the highest layer. The highest layer then conveys the message to Device B in the same format sent by Device A.