Commit 0511f92d authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Make evaluation script more sophisticated.

parent ef8b260e
Pipeline #55 passed with stage
......@@ -5,40 +5,53 @@ import time as time
import threading
class receiverThread(threading.Thread):
def __init__(self):
def __init__(self, seqnoDigits):
threading.Thread.__init__(self)
self.sock = prrt.PrrtSocket(5000, False)
self.stats = {}
self.received = set()
self.duplicates = 0
self.seqnoDigits = seqnoDigits
def run(self):
print("Receiving")
while(1):
print("Recv")
while(True):
len, data = self.sock.recv()
v = data[:len].decode('UTF-8')
print(len, v)
time.sleep(1)
seqno = v[:self.seqnoDigits]
if seqno in self.received:
self.duplicates = self.duplicates + 1
else:
self.received.update(set([seqno]))
time.sleep(0.000001)
print("Receiver Thread")
class senderThread(threading.Thread):
def __init__(self):
def __init__(self, seqnoDigits, packetCount):
threading.Thread.__init__(self)
self.sock = prrt.PrrtSocket(6000, True)
self.packetCount = packetCount
self.seqnoDigits = seqnoDigits
def run(self):
print("Connecting")
self.sock.connect("127.0.0.1", 5000)
print("Connected")
for i in range(10):
self.sock.send("Test")
for i in range(self.packetCount):
self.sock.send(str(i).zfill(self.seqnoDigits))
time.sleep(0.001)
self.sock.close();
if __name__ == "__main__":
recvThread = receiverThread()
sendThread = senderThread()
# Works: 2^15; Segfault at: 2^16
packetCount = 2**16
seqnoDigits = 10
recvThread = receiverThread(seqnoDigits)
recvThread.daemon = True
sendThread = senderThread(seqnoDigits, packetCount)
recvThread.start()
sendThread.start()
sendThread.run()
time.sleep(10)
count = len(recvThread.received)
print("Residual Loss:", 1 - (count / packetCount), "% (received", count, "of", packetCount,")")
print("Duplicates:", recvThread.duplicates)
Supports Markdown
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