To write a python program to perform stop and wait protocol
1 Start the program.
-
Get the frame size from the user
-
To create the frame based on the user request.
-
To send frames to server from the client side.
-
If your frames reach the server it will send ACK signal to client otherwise it will sendNACK signal to client.
-
Stop the program
import socket
s=socket.socket()
s.bind(('localhost',8080))
s.listen(5)
c,addr=s.accept()
while True:
i=input("ENter a data:")
c.send(i.encode())
ack=c.recv(1024).decode()
if ack:
print(ack)
continue
else:
c.close()
break
import socket
s=socket.socket()
s.connect(('localhost',8080))
while True:
print(s.recv(1024).decode())
s.send("Recieved".encode())
Thus, python program to perform stop and wait protocol was successfully executed.