Commit a518cfeb authored by Andreas Schmidt's avatar Andreas Schmidt
Browse files

Handle NAN.

parent 3cb08d1f
......@@ -46,7 +46,7 @@ class SenderThread(threading.Thread):
# TODO: create proper arrays
def run(self):
self.sock.connect("127.0.0.1", 7000)
self.sock.connect("127.244.0.1", 7000)
for i in range(self.packetCount):
d = str(i).zfill(self.seqnoDigits)
self.sentPackets[i] = datetime.datetime.now()
......@@ -64,10 +64,11 @@ class TestResults(object):
self.delays = None
def __str__(self):
delayValues = self.delays[~np.isnan(self.delays)]
plr = 1 - (self.packetsReceived / self.packetsSent)
loss = "Residual Loss: %f%% (received %d of %d)" % (plr, self.packetsReceived, self.packetsSent)
duplicates = "Duplicates: %d" % (self.duplicates)
delays = "Delay Profile [s]: %f+-%f [%f - %f]" % (np.mean(self.delays), np.std(self.delays), np.min(self.delays), np.max(self.delays))
delays = "Delay Profile [s]: %f+-%f [%f - %f]" % (np.mean(delayValues), np.std(delayValues), np.min(delayValues), np.max(delayValues))
return "%s\n%s\n%s" % (loss, duplicates, delays)
class TestSetup(object):
......@@ -81,7 +82,7 @@ class TestSetup(object):
self.duplicate = duplicate
self.reorder = reorder
self.reorder_correlation = reorder_correlation
self.processing_delay = 0.001 # 1ms
self.processing_delay = 0.005 # in ms
def netem_config(self):
# http://www.linuxfoundation.org/collaborate/workgroups/networking/netem
......@@ -90,7 +91,7 @@ class TestSetup(object):
self.duplicate, self.reorder, self.reorder_correlation)
def run(self):
# TODO: create and apply to custom loopback interface
# TODO: create and apply only to specific traffic
subprocess.run("tc qdisc add dev lo root netem " + self.netem_config(), shell=True)
seqnoDigits = math.ceil(math.log10(self.packets))
......@@ -101,12 +102,13 @@ class TestSetup(object):
recvThread.start()
sendThread.run()
time.sleep(self.packets * (self.delay + self.processing_delay))
time.sleep(1 + self.packets * (self.delay / 1000 + self.processing_delay))
count = len(recvThread.received)
delays = np.ndarray((self.packets),dtype="float")
for i in range(self.packets):
delays[i] = (recvThread.receivedPackets[i] - sendThread.sentPackets[i]).item().total_seconds()
item = (recvThread.receivedPackets[i] - sendThread.sentPackets[i]).item()
delays[i] = item.total_seconds() if item is not None else np.NAN
subprocess.run("tc qdisc del dev lo root", shell=True, check=True)
......
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