Advertisement
prabhavms

goback

Nov 19th, 2024
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. def go_back_n(frames, window_size):
  2.     sent = 0
  3.     while sent < len(frames):
  4.         print(f"Sending Frames: {frames[sent:sent+window_size]}")
  5.         for i in range(sent, min(sent + window_size, len(frames))):
  6.             ack = input(f"ACK for Frame {i} (y/n): ").strip().lower()
  7.             if ack != 'y':
  8.                 print(f"Error in Frame {i}, resending window...")
  9.                 break
  10.         else:
  11.             sent += window_size
  12.             continue
  13.         sent = i
  14.     print("All frames sent successfully!")
  15.  
  16. frames = input("Enter frames to send (comma-separated): ").split(',')
  17. window_size = int(input("Enter window size: "))
  18. go_back_n(frames, window_size)
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement