Exemplo n.º 1
0
    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))
Exemplo n.º 2
0
    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))
Exemplo n.º 3
0
    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))
Exemplo n.º 4
0
    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))
Exemplo n.º 5
0
    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))
Exemplo n.º 6
0
    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))
Exemplo n.º 7
0
    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))
Exemplo n.º 8
0
    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))
Exemplo n.º 9
0
    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")
Exemplo n.º 10
0
    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))
Exemplo n.º 11
0
    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))