def test_ideal_network(self): """reliability over an ideal framework""" stopServer = threading.Event() server = threading.Thread(target=server_app.main, args=(False, stopServer, winsize, timeout, outputfile)) server.start() client_app.main(False, timeout=100, input=inputfile) stopServer.set() self.assertTrue(filecmp.cmp(inputfile, outputfile))
def test_duplicates_network(self): """reliability over network with duplicate packets""" # setup environment run_command(netem_change.format("duplicate 10%")) # launch localhost client connecting to server client_app.main() time.sleep(1) # client sends content to server if os.path.isfile(self.inputfile) and os.path.isfile(self.outputfile): self.assertTrue(filecmp.cmp(self.inputfile, self.outputfile))
def test_ideal_network(self): """reliability over an ideal framework""" # setup environment (nothing to set) # launch localhost client connecting to server client_app.main() time.sleep(1) # client sends content to server if os.path.isfile(self.inputfile) and os.path.isfile(self.outputfile): self.assertTrue(filecmp.cmp(self.inputfile, self.outputfile))
def test_reordering_network(self): """reliability over network with packet reordering""" run_command(netem_change.format("delay 200ms reorder 50% 50%")) stopServer = threading.Event() server = threading.Thread(target=server_app.main, args=(False, stopServer, winsize, timeout, outputfile)) server.start() client_app.main(False, timeout=100, input=inputfile) stopServer.set() self.assertTrue(filecmp.cmp(inputfile, outputfile))
def test_flipping_network(self): """reliability over network with bit flips (which sometimes results in lower layer packet loss)""" # setup environment run_command(netem_change.format("corrupt 1%")) # launch localhost client connecting to server client_app.main() time.sleep(1) # client sends content to server if os.path.isfile(self.inputfile) and os.path.isfile(self.outputfile): self.assertTrue(filecmp.cmp(self.inputfile, self.outputfile))
def test_flipping_network(self): """reliability over network with bit flips (which sometimes results in lower layer packet loss)""" run_command(netem_change.format("corrupt 1%")) stopServer = threading.Event() server = threading.Thread(target=server_app.main, args=(False, stopServer, winsize, timeout, outputfile)) server.start() client_app.main(False, timeout=100, input=inputfile) stopServer.set() self.assertTrue(filecmp.cmp(inputfile, outputfile))
def test_delayed_network(self): """reliability over network with delay relative to the timeout value""" run_command( netem_change.format("delay " + str(0.5 * timeout) + "ms 20ms")) stopServer = threading.Event() server = threading.Thread(target=server_app.main, args=(False, stopServer, winsize, timeout, outputfile)) server.start() client_app.main(False, timeout=100, input=inputfile) stopServer.set() self.assertTrue(filecmp.cmp(inputfile, outputfile))
def test_delayed_network(self): """reliability over network with delay relative to the timeout value""" # setup environment run_command(netem_change.format("delay " + str(timeout) + "ms 20ms")) # launch localhost client connecting to server client_app.main() time.sleep(1) # client sends content to server # server receives content from client if os.path.isfile(self.inputfile) and os.path.isfile(self.outputfile): self.assertTrue(filecmp.cmp(self.inputfile, self.outputfile))
def test_reordering_network(self): """reliability over network with packet reordering""" # setup environment run_command(netem_change.format("delay 20ms reorder 25% 50%")) # launch localhost client connecting to server client_app.main() time.sleep(1) # client sends content to server # server receives content from client if os.path.isfile(self.inputfile) and os.path.isfile(self.outputfile): self.assertTrue(filecmp.cmp(self.inputfile, self.outputfile)) # content received by server matches the content sent by client print("hallo")
def test_allbad_network(self): """reliability over network with all of the above problems""" #run_command(netem_change.format("corrupt 1% duplicate 10% loss 10% 25% delay 20ms reorder 25% 50%")) run_command( netem_change.format( "corrupt 1% duplicate 10% loss 10% 25% delay 1ms reorder 25% 50%" )) stopServer = threading.Event() server = threading.Thread(target=server_app.main, args=(False, stopServer, winsize, timeout, outputfile)) server.start() client_app.main(False, timeout=100, input=inputfile) stopServer.set() self.assertTrue(filecmp.cmp(inputfile, outputfile))
def test_allbad_network(self): """reliability over network with all of the above problems""" # setup environment run_command( netem_change.format( "corrupt 1% duplicate 10% loss 10% 25% delay 20ms reorder 25% 50%" )) # launch localhost client connecting to server # client sends content to server client_app.main() time.sleep(1) # server receives content from client if os.path.isfile(self.inputfile) and os.path.isfile(self.outputfile): self.assertTrue(filecmp.cmp(self.inputfile, self.outputfile))