Description
In this assignment, you need our given UDP socket class to implement RDT protocol.
Then implement an Echo Server and Client.
-
Requirement
-
-
Your protocol needs to ensure the reliability of data transfer. Packet loss and payload corruption might happen.
-
-
-
-
To deal with packet loss, using ack and retransmission according to GBN the textbook.
-
-
-
-
-
To deal with payload corruption, you need to design a checksum of your payload.
-
-
-
-
Payload Example
-
Your payload might be like this:
| SYN | FIN | ACK | SEQ | SEQ ACK | LEN | CHEKCSUM | Payload| | 1 bit|1 bit| 1 bit| 4 byte| 4 byte | 4 byte | 2 byte | LEN |
-
Checksum Calculation Example
def calc_checksum(payload): sum = 0
for byte in payload: sum += byte
sum = -(sum % 256) return (sum & 0xFF)
CS305 Computer Network Lab Tutorial
-
API reference: rdt code example:
from udp import UDPsocket # import provided class class socket(UDPsocket):
def __init__():
super(socket, self).__init__()
def recvfrom():
-
your code here pass
def sendto():
-
your code here pass
server code example:
from rdt import socket
server = socket()
server.bind((SERVER_ADDR, SERVER_PORT))
while True:
dara, addr = server.recvfrom()
server.sendto(data, addr)
client code example:
from rdt import socket
client = socket()
client.send(DATA, (SERVER_ADDR, SERVER_PORT))
data = client.recvfrom()
assert data = DATA
client.close()