Commit 94caafce authored by Alan Marchiori's avatar Alan Marchiori

proj1 feedback

parent d2b8d806
4/4/19 - AMM
This is a stop and wait protocol with a sequence number and base64 copies of the data as a checksum. This will work fine with text data but won't work for binary files. The implementation is fairly clean and intuitive.
......@@ -82,7 +82,7 @@ startTime = datetime.now()
print('established connection with server, waiting to receive...')
while True:
data, addr = sock.recvfrom(1048)
data, addr = sock.recvfrom(1048) # why 1048? what if a line is longer than 1048 bytes?
#print("recv data: {}".format(data))
while data != b'####' and data != b'END':
......@@ -93,7 +93,7 @@ while True:
sock.sendto(b'NNNN', addr)
# print(get_decode_list(lineStr))
data, addr = sock.recvfrom(1048)
if data == b'####':
#print('Got line end!')
packetList = get_decode_list(lineStr)
......
......@@ -49,7 +49,7 @@ def build_packet(index, line):
def rdt_sendFile(network, dest, filename, size=65536):
# generate lines from file
file = open(filename)
lines = file.readlines()
lines = file.readlines() #will this work with binary files?
line_count = len(lines)
currentIndex = 0
while currentIndex < line_count:
......@@ -76,6 +76,9 @@ def rdt_sendFile(network, dest, filename, size=65536):
#current_line = build_packet(currentIndex, lines[currentIndex])
print('resending packet {},{}'.format(currentIndex, lines[currentIndex]))
send_line(network, dest, hashed_line, size)
except KeyboardInterrupt:
print('Ctrl-c, goodbye!')
exit()
except socket.timeout:
print('timeout!')
except:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment