A One-Bit Sliding Window Protocol

The one-bit sliding window protocol, also known as the stop-and-wait protocol, is a fundamental data link layer protocol used for reliable communication between two nodes. In this protocol, the sender transmits a single frame and waits for an acknowledgment (ACK) from the receiver before sending the next frame. This ensures that frames are delivered reliably and in order.

Key Concepts

1.Window Size: The window size is set to 1, meaning that only one frame can be in transit at any given time. The sender must wait for an acknowledgment before sending the next frame.

2.Sequence Numbers: The protocol uses sequence numbers to differentiate between frames. In this case, the sequence numbers can only be 0 or 1.

3.Acknowledgment: The acknowledgment field in the frame indicates the last successfully received frame. If the sender receives an acknowledgment that matches the sequence number of the frame it sent, it can proceed to send the next frame.

Protocol Variables

  • next_frame_to_send: Indicates which frame the sender is trying to send (0 or 1).
  • frame_expected: Indicates which frame the receiver is expecting (0 or 1).
  • buffer: Temporarily holds the packet to be sent.
  • event: Represents the type of event that occurs (frame arrival, checksum error, timeout).

Protocol Operation

1.Initialization:The sender initializes next_frame_to_send and frame_expected to 0. It fetches a packet from the network layer and prepares to send the first frame.

2.Sending a Frame: The sender constructs a frame with the current sequence number and sends it to the physical layer. It also starts a timer for the frame.

3.Event Handling: The sender waits for an event:

 → Frame Arrival: If a frame arrives, the sender checks if it is the expected frame. If it is, the frame is passed to the network layer, and frame_expected is incremented. If the acknowledgment matches next_frame_to_send, the sender stops the timer and fetches the next packet from the network layer.

 → Timeout: If the timer expires, the sender retransmits the last frame.

4.Loop: The sender continues this process indefinitely, sending frames and handling acknowledgments.

Resilience to Errors

The one-bit sliding window protocol is designed to handle various error scenarios:

If a frame is lost or a timeout occurs, the sender will continue to retransmit the same frame until it receives the correct acknowledgment.

The protocol ensures that no duplicate packets are delivered to the network layer, and it prevents skipping packets or deadlocks.

Synchronization Issues

A potential issue arises when both nodes attempt to send frames simultaneously. If both nodes send their initial frames at the same time, the frames may cross, leading to duplicate frames being processed. This can waste bandwidth and cause inefficiencies, but the protocol is still robust enough to handle these situations without compromising data integrity.one bit sliding window protocol

illustrating the two scenarios for protocol 4. The image should show the normal case (a) and the abnormal case (b), with the notation (seq, ack, packet number) and asterisks indicating where the network layer accepts a packet.

Conclusion

The one-bit sliding window protocol is a simple yet effective method for reliable data transmission in a network. By using sequence numbers and acknowledgments, it ensures that frames are delivered correctly and in order, while also being resilient to various error conditions.