Elementary Data Link Protocols Dr. Sudhanshu Janwadkar, Asst Professor, ITNU
Implementation of the physical, data link, and network layers.
Assumption-1  We assume that the physical layer, data link layer, and network layer are independent processes that communicate by passing messages back and forth.  The physical layer process and some of the data link layer process run on dedicate hardware called a NIC (Network Interface Card).  The rest of the link layer process and the network layer process run on the main CPU as part of the operating system, with the software for the link layer process often taking the form of a device driver.  However, other implementations are also possible (e.g., three processes offloaded to dedicated hardware called a network accelerator, or three processes running on the main CPU on a software-defined ratio).  Actually, the preferred implementation changes with technology trade- offs.
Assumption-2  Another key assumption is that machine A wants to send a long stream of data to machine B, using a reliable, connection-oriented service.  A is assumed to have an infinite supply of data ready to send and never has to wait for data to be produced.  Instead, when A’s data link layer asks for data, the network layer is always able to comply immediately.
Assumption-3  Machines do not crash.  That is, these protocols deal with communication errors, but not the problems caused by computers crashing and rebooting.
Assumption-4  As far as the data link layer is concerned, the packet passed across the interface to it from the network layer is pure data, whose every bit is to be delivered to the destination’s network layer.  The fact that the destination’s network layer may interpret part of the packet as a header is of no concern to the data link layer.
Procedure 1. When the data link layer accepts a packet, it encapsulates the packet in a frame by adding a data link header and trailer to it. Thus, a frame consists of an embedded packet, some control information (in the header), and a checksum (in the trailer). 2. The frame is then transmitted to the data link layer on the other machine.  There exist suitable library procedures to_physical_layer to send a frame and from_physical_layer to receive a frame.  These procedures compute and append or check the checksum (which is usually done in hardware).
3. Initially, the receiver has nothing to do. It just sits around waiting for something to happen.  The data link layer is waiting for something to happen is indicated by the procedure call wait_for_event(&event).  This procedure only returns when something has happened (e.g., a frame has arrived). Upon return, the variable event tells what happened.  The set of possible events differs for the various protocols to be described and will be defined separately for each protocol.
 In a more realistic situation, the data link layer will not sit in a tight loop waiting for an event, but will receive an interrupt, which will cause it to stop whatever it was doing and go handle the incoming frame.  Nevertheless, for simplicity we ignore all the details of parallel activity within the data link layer and assume that it is dedicated full time to handling just one channel.
4. When a frame arrives at the receiver, the checksum is recomputed.  If the checksum in the frame is incorrect (i.e., there was a transmission error), the data link layer is so informed (event = cksum_err).  If the inbound frame arrived undamaged, the data link layer is also informed (event = frame_arrival ) so that it can acquire the frame for inspection using from physical layer. 5. As soon as the receiving data link layer has acquired an undamaged frame, it checks the control information in the header, and, if everything is all right, passes the packet portion to the network layer.  Under no circumstances is a frame header ever given to a network layer.
Data Structures  Five data structures are defined there: boolean, seq_nr, packet, frame_kind, and frame.
 A boolean is an enumerated type and can take on the values true and false.  A seq_nr is a small integer used to number the frames so that we can tell them apart.  These sequence numbers run from 0 up to and including MAX_SEQ, which is defined in each protocol needing it.  A packet is the unit of information exchanged between the network layer and the data link layer on the same machine, or between network layer peers.  In our model it always contains MAX_PKT bytes, but more realistically it would be of variable length.
 A frame is composed of four fields: kind, seq, ack, and info.  The first three of which contain control information and the last of which may contain actual data to be transferred.  These control fields are collectively called the frame header.  The kind field tells whether there are any data in the frame, because some of the protocols distinguish frames containing only control information from those containing data as well.  The seq and ack fields are used for sequence numbers and acknowledgements, respectively;  The info field of a data frame contains a single packet .  The info field of a control frame is not used.
Relationship between a packet and a frame.  The network layer builds a packet by taking a message from the transport layer and adding the network layer header to it.  This packet is passed to the data link layer for inclusion in the info field of an outgoing frame.  When the frame arrives at the destination, the data link layer extracts the packet from the frame and passes the packet to the network layer.  Network Layer: Packet  Data Link Layer: Frame
Library Routines  The procedure wait_for_event sits in a tight loop waiting for something to happen.
 The procedures to_network_layer and from_network_layer are used by the data link layer to pass packets to the network layer and accept packets from the network layer, respectively.  Note that from_physical_layer and to_physical_layer pass frames between the data link layer and the physical layer.  In other words, to_network_layer and from_network_layer deal with the interface between layers 2 and 3, whereas from_physical_layer and to_physical_layer deal with the interface between layers 1 and 2.
 In most of the protocols, we assume that the channel is unreliable and loses entire frames upon occasion.  To be able to recover from such calamities, the sending data link layer must start an internal timer or clock whenever it sends a frame.  If no reply has been received within a certain predetermined time interval, the clock times out and the data link layer receives an interrupt signal.  In our protocols this is handled by allowing the procedure wait_for_event to return_event = timeout.
 The procedures start_timer and stop_timer turn the timer on and off, respectively.  Timeout events are possible only when the timer is running and before stop_timer is called.  It is explicitly permitted to call start_timer while the timer is running; such a call simply resets the clock to cause the next timeout after a full timer interval has elapsed (unless it is reset or turned off).
 The procedures start_ack_timer and stop_ack_timer control an auxiliary timer used to generate acknowledgements under certain conditions.
 The procedures enable_network_layer and disable_network_layer are used in the more sophisticated protocols, where we no longer assume that the network layer always has packets to send.  When the data link layer enables the network layer, the network layer is then permitted to interrupt when it has a packet to be sent. We indicate this with event = network_layer_ready.  When the network layer is disabled, it may not cause such events.  By being careful about when it enables and disables its network layer, the data link layer can prevent the network layer from swamping it with packets for which it has no buffer space.
 Frame sequence numbers are always in the range 0 to MAX_SEQ (inclusive), where MAX_SEQ is different for the different protocols

Presentation on Elementary Data Link Protocols

  • 1.
    Elementary Data LinkProtocols Dr. Sudhanshu Janwadkar, Asst Professor, ITNU
  • 2.
    Implementation of thephysical, data link, and network layers.
  • 3.
    Assumption-1  We assumethat the physical layer, data link layer, and network layer are independent processes that communicate by passing messages back and forth.  The physical layer process and some of the data link layer process run on dedicate hardware called a NIC (Network Interface Card).  The rest of the link layer process and the network layer process run on the main CPU as part of the operating system, with the software for the link layer process often taking the form of a device driver.  However, other implementations are also possible (e.g., three processes offloaded to dedicated hardware called a network accelerator, or three processes running on the main CPU on a software-defined ratio).  Actually, the preferred implementation changes with technology trade- offs.
  • 4.
    Assumption-2  Another keyassumption is that machine A wants to send a long stream of data to machine B, using a reliable, connection-oriented service.  A is assumed to have an infinite supply of data ready to send and never has to wait for data to be produced.  Instead, when A’s data link layer asks for data, the network layer is always able to comply immediately.
  • 5.
    Assumption-3  Machines donot crash.  That is, these protocols deal with communication errors, but not the problems caused by computers crashing and rebooting.
  • 6.
    Assumption-4  As faras the data link layer is concerned, the packet passed across the interface to it from the network layer is pure data, whose every bit is to be delivered to the destination’s network layer.  The fact that the destination’s network layer may interpret part of the packet as a header is of no concern to the data link layer.
  • 7.
    Procedure 1. When thedata link layer accepts a packet, it encapsulates the packet in a frame by adding a data link header and trailer to it. Thus, a frame consists of an embedded packet, some control information (in the header), and a checksum (in the trailer). 2. The frame is then transmitted to the data link layer on the other machine.  There exist suitable library procedures to_physical_layer to send a frame and from_physical_layer to receive a frame.  These procedures compute and append or check the checksum (which is usually done in hardware).
  • 8.
    3. Initially, thereceiver has nothing to do. It just sits around waiting for something to happen.  The data link layer is waiting for something to happen is indicated by the procedure call wait_for_event(&event).  This procedure only returns when something has happened (e.g., a frame has arrived). Upon return, the variable event tells what happened.  The set of possible events differs for the various protocols to be described and will be defined separately for each protocol.
  • 9.
     In amore realistic situation, the data link layer will not sit in a tight loop waiting for an event, but will receive an interrupt, which will cause it to stop whatever it was doing and go handle the incoming frame.  Nevertheless, for simplicity we ignore all the details of parallel activity within the data link layer and assume that it is dedicated full time to handling just one channel.
  • 10.
    4. When aframe arrives at the receiver, the checksum is recomputed.  If the checksum in the frame is incorrect (i.e., there was a transmission error), the data link layer is so informed (event = cksum_err).  If the inbound frame arrived undamaged, the data link layer is also informed (event = frame_arrival ) so that it can acquire the frame for inspection using from physical layer. 5. As soon as the receiving data link layer has acquired an undamaged frame, it checks the control information in the header, and, if everything is all right, passes the packet portion to the network layer.  Under no circumstances is a frame header ever given to a network layer.
  • 11.
    Data Structures  Fivedata structures are defined there: boolean, seq_nr, packet, frame_kind, and frame.
  • 12.
     A booleanis an enumerated type and can take on the values true and false.  A seq_nr is a small integer used to number the frames so that we can tell them apart.  These sequence numbers run from 0 up to and including MAX_SEQ, which is defined in each protocol needing it.  A packet is the unit of information exchanged between the network layer and the data link layer on the same machine, or between network layer peers.  In our model it always contains MAX_PKT bytes, but more realistically it would be of variable length.
  • 13.
     A frameis composed of four fields: kind, seq, ack, and info.  The first three of which contain control information and the last of which may contain actual data to be transferred.  These control fields are collectively called the frame header.  The kind field tells whether there are any data in the frame, because some of the protocols distinguish frames containing only control information from those containing data as well.  The seq and ack fields are used for sequence numbers and acknowledgements, respectively;  The info field of a data frame contains a single packet .  The info field of a control frame is not used.
  • 14.
    Relationship between apacket and a frame.  The network layer builds a packet by taking a message from the transport layer and adding the network layer header to it.  This packet is passed to the data link layer for inclusion in the info field of an outgoing frame.  When the frame arrives at the destination, the data link layer extracts the packet from the frame and passes the packet to the network layer.  Network Layer: Packet  Data Link Layer: Frame
  • 15.
    Library Routines  Theprocedure wait_for_event sits in a tight loop waiting for something to happen.
  • 16.
     The proceduresto_network_layer and from_network_layer are used by the data link layer to pass packets to the network layer and accept packets from the network layer, respectively.  Note that from_physical_layer and to_physical_layer pass frames between the data link layer and the physical layer.  In other words, to_network_layer and from_network_layer deal with the interface between layers 2 and 3, whereas from_physical_layer and to_physical_layer deal with the interface between layers 1 and 2.
  • 17.
     In mostof the protocols, we assume that the channel is unreliable and loses entire frames upon occasion.  To be able to recover from such calamities, the sending data link layer must start an internal timer or clock whenever it sends a frame.  If no reply has been received within a certain predetermined time interval, the clock times out and the data link layer receives an interrupt signal.  In our protocols this is handled by allowing the procedure wait_for_event to return_event = timeout.
  • 18.
     The proceduresstart_timer and stop_timer turn the timer on and off, respectively.  Timeout events are possible only when the timer is running and before stop_timer is called.  It is explicitly permitted to call start_timer while the timer is running; such a call simply resets the clock to cause the next timeout after a full timer interval has elapsed (unless it is reset or turned off).
  • 19.
     The proceduresstart_ack_timer and stop_ack_timer control an auxiliary timer used to generate acknowledgements under certain conditions.
  • 20.
     The proceduresenable_network_layer and disable_network_layer are used in the more sophisticated protocols, where we no longer assume that the network layer always has packets to send.  When the data link layer enables the network layer, the network layer is then permitted to interrupt when it has a packet to be sent. We indicate this with event = network_layer_ready.  When the network layer is disabled, it may not cause such events.  By being careful about when it enables and disables its network layer, the data link layer can prevent the network layer from swamping it with packets for which it has no buffer space.
  • 21.
     Frame sequencenumbers are always in the range 0 to MAX_SEQ (inclusive), where MAX_SEQ is different for the different protocols