EX-2 IMPLEMENTATION OF STOP AND WAIT PROTOCOL
To write a python program to perform stop and wait protocol
2. Get the frame size from the user
3. To create the frame based on the user request.
4. To send frames to server from the client side.
5. If your frames reach the server it will send ACK signal to client otherwise it will sendNACK signal to client.
import socket
s=socket.socket()
s.connect(('localhost',8000))
while True:
print(s.recv(1024).decode())
s.send("Acknowledgement Recived".encode())
import socket
s=socket.socket()
s.bind(('localhost',8000))
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
![2s](https://private-user-images.githubusercontent.com/128116503/241622132-218b9528-8012-4d2d-a1ff-6990bc2bb5ef.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NDUzNDgsIm5iZiI6MTcyMzY0NTA0OCwicGF0aCI6Ii8xMjgxMTY1MDMvMjQxNjIyMTMyLTIxOGI5NTI4LTgwMTItNGQyZC1hMWZmLTY5OTBiYzJiYjVlZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxNFQxNDE3MjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1iZjkyZGRmNzdlMjcxOTA1M2FhNWYyZDAyNjMxNjgxNzdiNmEyMTQ0NmZlNzg5ZGYzYzQxNjE2MDVmMGIyZGQxJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.DpNRUwHjjTTk6XJ1nP7r_AEWmPOJG98GFPWeXuTmGyM)
![2c](https://private-user-images.githubusercontent.com/128116503/241622120-33c3f313-06cd-49eb-b4b8-6a3eac62113f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2NDUzNDgsIm5iZiI6MTcyMzY0NTA0OCwicGF0aCI6Ii8xMjgxMTY1MDMvMjQxNjIyMTIwLTMzYzNmMzEzLTA2Y2QtNDllYi1iNGI4LTZhM2VhYzYyMTEzZi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwODE0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDgxNFQxNDE3MjhaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT04MjcyZDlkYTU1MTY3YmM2NDVmY2M0YzBhNzFmYjc3MDUwMjg0MjdlZWQxNjQzZTZjZmU3Y2JmZjFiM2IzZDhjJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.UDyRqy9nGf0QYMXVLDrQyCzsOozjm9rZrAB9EC_pCUQ)
Thus, python program to perform stop and wait protocol was successfully executed.