How anandk28/2a_stop_and_wait_protocol works
Project type and purpose
• This is a network protocol demo tool written in Python.
• It consists of two processes: one binds & listens (named “client” in the code) and one connects (named “server” in the code), exchanging data frames with acknowledgements.
Main components
a. Client process
• Python script that binds to localhost:8000, listens for incoming connections, reads user input frames, sends them, and waits for ACKs.
b. Server process
• Python script that connects to localhost:8000, receives frames, prints them, and replies with an acknowledgement message.
c. Network channel
• The underlying TCP socket on localhost (port 8000) conveying frames and ACKs.
Relationships and interactions
• Client → Network: “Frame” messages (user-entered data)
• Server ← Network: receives frames
• Server → Network: “Acknowledgement Received” messages
• Client ← Network: receives ACKs, then prompts for next frame
• Strict stop-and-wait pattern: client sends one frame, waits for its ACK before sending the next.
Architectural patterns & design principles
• Single-threaded, sequential I/O on each side
• Simple request–response loop (no parallelism or pipelining)
• Clear separation of concerns:
• Input handling (user frame creation)
• Network I/O (socket send/receive)
• Acknowledgement logic (stop and wait)
Elements
• Clear labels for each of the two Python scripts (names and roles).
• The TCP connection as an explicit link or channel between them.
• Annotations of the port number and socket operations.