Question: Write two socket programs (server and client) in C, C++, Python, or Java that simulates the RDT3.0 stop-and-wait protocol that uses alternative bits to realize
Write two socket programs (server and client) in C, C++, Python, or Java that simulates the RDT3.0 stop-and-wait protocol that uses alternative bits to realize the reliable data transfer. Assume that the sender (client) will always have data to transmit, which can be defined as a set of phrases such as days of the week.
data = ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"]
Since RDT3.0 assumes an unreliable channel between the sender (client) and reciever (server), simulate the effect of unreliable packet transmission by randomly picking between sending an ACK with correct sequence number, sending a corrupted ACK, not sending an ACK, or sending an ACK with incorrect sequence number. Actual checksum is not needed in these programs since sending a corrupt ACK is one of four equal chance simulation options. Here is a diagram showing how the two client and server programs should interact with each other.

Client Output Text
Lets start
Connected by ('127.0.0.1', 57586)
Sender sent a message: Sunday 0
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Timeout. Send the message again
Sender sent a message: Sunday 0
Sender received a valid ACK for 0 , send next message
Sender sent a message: Monday 1
Sender received a corrupted ACK, keep waiting
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Timeout. Send the message again
Sender sent a message: Monday 1
Sender received a valid ACK for 1 , send next message
Sender sent a message: Tuesday 0
Sender received an ACK with wrong sequency number, keep waiting
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Timeout. Send the message again
Sender sent a message: Tuesday 0
Sender received a valid ACK for 0 , send next message
Sender sent a message: Wednesday 1
Sender received a valid ACK for 1 , send next message
Sender sent a message: Thursday 0
Sender received an ACK with wrong sequency number, keep waiting
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Continue waiting
Timeout. Send the message again
Server Output Text
Receiver just correctly received a message: Sunday 0
How do you respond?
(1) send a correct ACK; (2) send a corrupted ACK; (3) do not send ACK; (4)
send a wrong ACK
Receiver do not send ACK
Receiver just correctly received a duplicated message: Sunday 0
Receiver responds with ACK 0
Receiver just correctly received a message: Monday 1
How do you respond?
(1) send a correct ACK; (2) send a corrupted ACK; (3) do not send ACK; (4)
send a wrong ACK
A corrupted ACK is sent
Receiver just correctly received a duplicated message: Monday 1
Receiver responds with ACK 1
Receiver just correctly received a message: Tuesday 0
How do you respond?
(1) send a correct ACK; (2) send a corrupted ACK; (3) do not send ACK; (4)
send a wrong ACK
Receiver incorrectly responds with ACK 1
Receiver just correctly received a duplicated message: Tuesday 0
Receiver responds with ACK 0
Receiver just correctly received a message: Wednesday 1
How do you respond?
(1) send a correct ACK; (2) send a corrupted ACK; (3) do not send ACK; (4)
send a wrong ACK
Receiver correctly responds with ACK 1
Receiver just correctly received a message: Thursday 0
How do you respond?
(1) send a correct ACK; (2) send a corrupted ACK; (3) do not send ACK; (4)
send a wrong ACK
Receiver incorrectly responds with ACK 1
Receiver just correctly received a duplicated message: Thursday 0
Receiver responds with ACK 0
Receiver just correctly received a message: Friday 1
How do you respond?
(1) send a correct ACK; (2) send a corrupted ACK; (3) do not send ACK; (4)
send a wrong ACK
Receiver correctly responds with ACK 1
Receiver just correctly received a message: Saturday 0
How do you respond?
(1) send a correct ACK; (2) send a corrupted ACK; (3) do not send ACK; (4)
send a wrong ACK
A corrupted ACK is sent
Receiver just correctly received a duplicated message: Saturday 0
Receiver responds with ACK 0
udt rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seqo(rcvpkt) Naughty_Receiver) udt_rcv(rcvpkt) && (corrupt(rcvpkt) || ait fo 0 from below ait fo 1 from below udt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq0(rcvpkt)) has_seq1(rcvpkt) sndpkt = make-pkt(ACK! ) udt send(sndpkt) sndpkt = make-pkt(ACKO) udt send(sndpkt) udt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1 (rcvpkt) Naughty_Receiver() Figure 3: Receiver FSM Received a message with correct seq # andomly choose one of the options Send ACK with Send correct Seq # || corrupted ACK Do nothing SendACKwith incorrect Seq # udt rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seqo(rcvpkt) Naughty_Receiver) udt_rcv(rcvpkt) && (corrupt(rcvpkt) || ait fo 0 from below ait fo 1 from below udt_rcv(rcvpkt) && (corrupt(rcvpkt) || has_seq0(rcvpkt)) has_seq1(rcvpkt) sndpkt = make-pkt(ACK! ) udt send(sndpkt) sndpkt = make-pkt(ACKO) udt send(sndpkt) udt_rcv(rcvpkt) && notcorrupt(rcvpkt) && has_seq1 (rcvpkt) Naughty_Receiver() Figure 3: Receiver FSM Received a message with correct seq # andomly choose one of the options Send ACK with Send correct Seq # || corrupted ACK Do nothing SendACKwith incorrect Seq #
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
