Skip to content

VrdyEngineered/Data_Link_Layer_Protocols

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Data Link Layer Protocols

This repository contains implementations and explanations of fundamental Data Link Layer (DLL) protocols used in computer networks for reliable data transmission.

📌 Protocols Covered

  1. Simplest Protocol

    • A basic protocol with no error control or flow control.
    • Packets are transmitted without acknowledgments.
    • Useful for understanding the foundation of ARQ mechanisms.
  2. Stop-and-Wait ARQ

    • Sender transmits one frame at a time and waits for acknowledgment (ACK).
    • Simple but inefficient for high-latency links.
    • Handles lost or corrupted frames by retransmitting after timeout.
  3. Go-Back-N ARQ

    • Sender can transmit multiple frames (window size N) before needing an ACK.
    • If a frame is lost/corrupted, the sender retransmits that frame and all subsequent frames.
    • More efficient than Stop-and-Wait but may waste bandwidth due to retransmissions.
  4. Selective Repeat ARQ

    • Sender also transmits multiple frames (window size N).
    • Only the erroneous/lost frames are retransmitted, not the entire sequence.
    • Efficient and widely used in real-world protocols (e.g., TCP with Selective Acknowledgments).

Understanding Data Framing in Computer Networks

This repository provides a clear explanation of data framing techniques used in the Data Link Layer (Layer 2) of the OSI model. Framing is the crucial process of breaking a raw bitstream from the Physical Layer into discrete units called frames.

The two primary methods discussed here are:

  1. Character-Oriented Framing
  2. Bit-Oriented Framing

What is Framing? 🤔

Imagine you're listening to someone speak a long, continuous sentence without any pauses. It would be incredibly difficult to understand. Framing is like adding pauses and punctuation to this stream of data. It provides a way for the receiver to know where a message starts, where it ends, and how to separate it from other messages. Each frame typically contains a header, the payload data, and a trailer.


## Character-Oriented Framing

In character-oriented framing, the data is interpreted as a sequence of characters (typically 8-bit ASCII characters). The frame boundary is identified using special control characters.

  • Mechanism: A frame starts with a STX (Start of Text) character and ends with an ETX (End of Text) character. Other control characters like ACK (Acknowledgment) and NAK (Negative Acknowledgment) can also be used.

  • Structure: [STX] [Header] [Payload Data] [Trailer] [ETX]

The Transparency Problem

A major issue arises if the actual data being sent contains the same bit pattern as the ETX or STX control characters. The receiver would mistakenly interpret this data as the end of the frame, leading to data corruption.

Solution: Character Stuffing (or Byte Stuffing)

To solve this, the sender's Data Link Layer "stuffs" an extra ESC (Escape) character into the data stream just before any character that mimics a control character (STX, ETX, or even ESC itself).

The receiver's Data Link Layer then removes the ESC character before passing the data up to the Network Layer, restoring the original data.

Example of Character Stuffing:

  • Original Data: A STX B ETX C
  • Data After Stuffing: A ESC STX B ESC ETX C
  • Frame Transmitted: STX A ESC STX B ESC ETX C ETX

## Bit-Oriented Framing

In bit-oriented framing, the data is treated as a sequence of individual bits, not characters. This makes it more versatile and efficient, as it doesn't depend on any specific character set.

  • Mechanism: A special bit pattern, called a flag, is used to mark both the start and the end of a frame. The most common flag is 01111110.

  • Structure: [Flag] [Header] [Payload Data] [Trailer] [Flag] 01111110 [Header] [Payload Data] [Trailer] 01111110

The Transparency Problem

Similar to character-oriented framing, the flag pattern 01111110 might appear inside the actual data (header, payload, or trailer). This would cause the receiver to detect a premature end to the frame.

Solution: Bit Stuffing

To prevent this, the sender's Data Link Layer inserts an extra 0 bit whenever five consecutive 1s appear in the data. This process is called bit stuffing.

When the frame arrives, the receiver inspects the bit stream. If it sees five consecutive 1s, it checks the next bit:

  • If the next bit is a 0, it is removed (destuffed).
  • If the next bit is a 1 (forming the 01111110 pattern), the receiver knows it has reached the end-of-frame flag.

Example of Bit Stuffing:

  • Original Data from Network Layer: 0110111111101111101
  • Data After Stuffing (Sender): 011011111011011111001
  • Frame Transmitted: 01111110 011011111011011111001 01111110
  • Data After Destuffing (Receiver): 0110111111101111101 (Original data is restored)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages