Beispiel #1
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')
        Sim.set_debug('Plot')

        # setup network
        net = Network('./networks/one-hop.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a,
                 window=self.window,
                 drop=self.drops)
        c2 = TCP(t2,
                 n2.get_address('n1'),
                 1,
                 n1.get_address('n2'),
                 1,
                 a,
                 window=self.window,
                 drop=self.drops)

        # setup fast retransmit
        if self.fast_retransmit:
            c1.set_fast_retransmit_enabled(True)
            c2.set_fast_retransmit_enabled(True)

        # send a file
        with open(self.filename, 'rb') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()
Beispiel #2
0
    def run(self):
        # parameters
        Sim.scheduler.reset()

        # setup network
        net = Network('experiment.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a,
                 window=self.window,
                 fast_retransmit=self.fast_retransmit,
                 measure=True)
        TCP(t2,
            n2.get_address('n1'),
            1,
            n1.get_address('n2'),
            1,
            a,
            window=self.window,
            fast_retransmit=self.fast_retransmit,
            measure=True)

        # send a file
        with open(self.filename, 'rb') as f:
            while True:
                data = f.read()
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        Sim.scheduler.run()
        result_file = open("results.txt", "r")
        results = result_file.read()
        result_file.close()
        f = open("experiment.csv", "a")
        f.write(str(self.window) + "," + results + "\n")
Beispiel #3
0
    def run(self, janela, perda, fila, fast):

        self.filename = fila
        loss = perda
        Sim.trace('Trans', "It is %s that I am using fast transmit." % (fast))

        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')
        Sim.set_debug('Trans')

        # setup network
        net = Network('./network.txt')
        net.loss(loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        net.set_queue(n1.links[0], "100")
        net.set_queue(n2.links[0], "100")

        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1, n1.get_address('n2'), 1, n2.get_address('n1'), 1, a,
                 janela, fast)
        c2 = TCP(t2, n2.get_address('n1'), 1, n1.get_address('n2'), 1, a,
                 janela, fast)

        # send a file
        with open(self.filename, 'rb') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()

        self.diff()

        self.filename = None

        return Sim.scheduler.current_time()
Beispiel #4
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')

        # setup network
        net = Network('network.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a,
                 window=self.window,
                 fast_retransmit=self.fast_retransmit)
        c2 = TCP(t2,
                 n2.get_address('n1'),
                 1,
                 n1.get_address('n2'),
                 1,
                 a,
                 window=self.window,
                 fast_retransmit=self.fast_retransmit)

        # send a file
        with open(self.filename, 'rb') as f:
            while True:
                data = f.read(10000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()
        if self.print_queueing_delay:
            print('average queueing delay: {}'.format(
                c2.total_queueing_delay / c2.total_packets_received))
Beispiel #5
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')
        Sim.set_debug('Plot')

        # setup network
        net = Network('basic.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a,
                 window=self.window)
        TCP(t2,
            n2.get_address('n1'),
            1,
            n1.get_address('n2'),
            1,
            a,
            window=self.window)

        # send a file
        with open(self.filename, 'rb') as f:
            while True:
                data = f.read()
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        Sim.scheduler.run()
Beispiel #6
0
    def run(self):
        # parameters
        Sim.scheduler.reset()

        if "a" in self.debug:
            Sim.set_debug('AppHandler')
        if "t" in self.debug:
            Sim.set_debug('TCP')

        # setup network
        net = Network('networks/one-hop.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.inputfile)

        # setup connection
        c1 = TCP(t1,n1.get_address('n2'),1,n2.get_address('n1'),1,a,window=self.window,type=self.type)
        c2 = TCP(t2,n2.get_address('n1'),1,n1.get_address('n2'),1,a,window=self.window,type=self.type)

        global original_size
        f = open(self.inputfile, "rb")
        try:
            data = f.read(1000)
            while data != "":
                original_size += len(data)
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)
                data = f.read(1000)
        finally:
            f.close()

        # run the simulation
        Sim.scheduler.run()

        plotter.plot(self.sequencefile);
Beispiel #7
0
    def run(self):
        # parameters
        Sim.scheduler.reset()

        if hasattr(self, 'debug') and "a" in self.debug:
            Sim.set_debug('AppHandler')
        if hasattr(self, 'debug') and "t" in self.debug:
            Sim.set_debug('TCP')

        # setup network
        net = Network('networks/one-hop.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,n1.get_address('n2'),1,n2.get_address('n1'),1,a,dynamic_rto=self.dynamic_rto)
        c2 = TCP(t2,n2.get_address('n1'),1,n1.get_address('n2'),1,a,dynamic_rto=self.dynamic_rto)

        f = open(self.filename, "rb")
        try:
            data = f.read(1000)
            while data != "":
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)
                data = f.read(1000)
        finally:
            f.close()

        # run the simulation
        Sim.scheduler.run()
Beispiel #8
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')

        # setup network
        net = Network('../networks/one-hop.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')

        n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])  # n1 -> n2
        n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])  # n1 <- n2

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        tcp_flows = 1
        a1 = AppHandler(self.filename, 1)

        # setup connection
        c1a = TCP(t1, n1.get_address('n2'), 1, n2.get_address('n1'), 1, 3000, a1)
        c2a = TCP(t2, n2.get_address('n1'), 1, n1.get_address('n2'), 1, 3000, a1)

        # send a file
        with open(self.filename,'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1a.send)

        # run the simulation
        Sim.scheduler.run()
        return tcp_flows
Beispiel #9
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')

        # setup network
        # net = Network('../networks/one-hop.txt')
        net = Network('../networks/four-nodes.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n3 = net.get_node('n3')
        n4 = net.get_node('n4')

        n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])  # n1 -> n2
        n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])  # n1 <- n2

        n2.add_forwarding_entry(address=n3.get_address('n2'),link=n2.links[1])  # n2 -> n3
        n3.add_forwarding_entry(address=n2.get_address('n3'),link=n3.links[0])  # n2 <- n3

        n2.add_forwarding_entry(address=n4.get_address('n2'),link=n2.links[2])  # n2 -> n4
        n4.add_forwarding_entry(address=n2.get_address('n4'),link=n4.links[0])  # n2 <- n4

        n1.add_forwarding_entry(address=n4.get_address('n2'),link=n1.links[0])  # n1 -> n2 -> n4
        n3.add_forwarding_entry(address=n4.get_address('n2'),link=n3.links[0])  # n3 -> n2 -> n4
        n4.add_forwarding_entry(address=n1.get_address('n2'),link=n4.links[0])  # n4 -> n2 -> n1
        n4.add_forwarding_entry(address=n3.get_address('n2'),link=n4.links[0])  # n4 -> n2 -> n1

        # setup transport
        t1 = Transport(n1)
        t3 = Transport(n3)
        t4 = Transport(n4)

        # setup application
        tcp_flows = 2
        a1 = AppHandler(self.filename,1)
        a2 = AppHandler(self.filename,2)
        # a3 = AppHandler(self.filename, 3)
        # a4 = AppHandler(self.filename, 4)
        # a5 = AppHandler(self.filename, 5)

        # setup connection
        # c1a = TCP(t1, n1.get_address('n2'), 1, n2.get_address('n1'), 1, a1)
        # c2a = TCP(t2, n2.get_address('n1'), 1, n1.get_address('n2'), 1, a1)

        ### 4-node configuration
        c1a = TCP(t1, n1.get_address('n2'), 1, n4.get_address('n2'), 1, a1)
        c2a = TCP(t4, n4.get_address('n2'), 1, n1.get_address('n2'), 1, a1)

        c1b = TCP(t3, n3.get_address('n2'), 2, n4.get_address('n2'), 2, a2)
        c2b = TCP(t4, n4.get_address('n2'), 2, n3.get_address('n2'), 2, a2)

        # c1b = TCP(t1, n1.get_address('n2'), 2, n2.get_address('n1'), 2, a2)
        # c2b = TCP(t2, n2.get_address('n1'), 2, n1.get_address('n2'), 2, a2)

        # c1c = TCP(t1, n1.get_address('n2'), 3, n2.get_address('n1'), 3, a3)
        # c2c = TCP(t2, n2.get_address('n1'), 3, n1.get_address('n2'), 3, a3)
        #
        # c1d = TCP(t1, n1.get_address('n2'), 4, n2.get_address('n1'), 4, a4)
        # c2d = TCP(t2, n2.get_address('n1'), 4, n1.get_address('n2'), 4, a4)
        #
        # c1e = TCP(t1, n1.get_address('n2'), 5, n2.get_address('n1'), 5, a5)
        # c2e = TCP(t2, n2.get_address('n1'), 5, n1.get_address('n2'), 5, a5)

        # send a file
        with open(self.filename,'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1a.send)
                Sim.scheduler.add(delay=0, event=data, handler=c1b.send)
                # Sim.scheduler.add(delay=0, event=data, handler=c1a.send)
                # Sim.scheduler.add(delay=0.1, event=data, handler=c1b.send)
                # Sim.scheduler.add(delay=0.2, event=data, handler=c1c.send)
                # Sim.scheduler.add(delay=0.3, event=data, handler=c1d.send)
                # Sim.scheduler.add(delay=0.4, event=data, handler=c1e.send)


        # run the simulation
        Sim.scheduler.run()
        return tcp_flows
Beispiel #10
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        #Sim.set_debug('AppHandler')
        #Sim.set_debug('TCP')
        Sim.set_debug('Link')

        net = Network('networks/one.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a1 = AppHandler('test.txt')

        # setup connection
        c1 = TCP(t1,n1.get_address('n2'),1,n2.get_address('n1'),1,a1,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery,aiad=True)
        c2 = TCP(t2,n2.get_address('n1'),1,n1.get_address('n2'),1,a1,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery,aiad=True)

        # send a file
        with open('test.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        plotter = Plotter()
        print "Saving the sequence plot"
        plotter.create_sequence_plot(c1.x, c1.y, c1.dropX, c1.dropY, c1.ackX, c1.ackY, chart_name='advanced/aiad/sequence.png')

        plotter.clear()
        plotter.rateTimePlot(c2.packets_received, Sim.scheduler.current_time(), 'advanced/aiad/rateTime1.png')

        linkab = n1.links[0]
        self.linkab = linkab
        plotter.clear()
        plotter.queueSizePlot(linkab.queue_log_x, linkab.queue_log_y, linkab.dropped_packets_x, linkab.dropped_packets_y, chart_name='advanced/aiad/queueSize.png')

        plotter.clear()
        plotter.windowSizePlot(c1.window_x, c1.window_y, chart_name="advanced/aiad/windowSize1.png")
Beispiel #11
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        #Sim.set_debug('TCP')
        Sim.set_debug('Link')

        net = Network('networks/one-hop-queue.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)
        c2 = TCP(t2,
                 n2.get_address('n1'),
                 1,
                 n1.get_address('n2'),
                 1,
                 a,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)

        # send a file
        with open(self.filename, 'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        plotter = Plotter()
        #print "Saving the sequence plot"
        #plotter.create_sequence_plot(c1.x, c1.y, c1.dropX, c1.dropY, c1.ackX, c1.ackY)
        self.c2 = c2
        self.c1 = c1
        self.t1 = t1
        self.t2 = t2
        self.net = net
        plotter.rateTimePlot(c2.packets_received, Sim.scheduler.current_time(),
                             'one/rateTime.png')
Beispiel #12
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        #Sim.set_debug('AppHandler')
        #Sim.set_debug('TCP')
        Sim.set_debug('Link')

        net = Network('networks/two.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a1 = AppHandler('test1.txt')
        a2 = AppHandler('test2.txt')

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a1,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)
        c2 = TCP(t2,
                 n2.get_address('n1'),
                 1,
                 n1.get_address('n2'),
                 1,
                 a1,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)

        c3 = TCP(t1,
                 n1.get_address('n2'),
                 2,
                 n2.get_address('n1'),
                 2,
                 a2,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)
        c4 = TCP(t2,
                 n2.get_address('n1'),
                 2,
                 n1.get_address('n2'),
                 2,
                 a2,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)

        # send a file
        with open('test1.txt', 'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)
        with open('test2.txt', 'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c3.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        # Variables for debugging
        self.c3 = c3
        self.c4 = c4
        self.c2 = c2
        self.c1 = c1
        self.t1 = t1
        self.t2 = t2
        self.net = net
        linkab = n1.links[0]
        self.linkab = linkab
        l = linkab

        # Plotting
        plotter = Plotter()

        # Plot sequence charts
        plotter.clear()
        plotter.create_sequence_plot(c1.x,
                                     c1.y,
                                     c1.dropX,
                                     c1.dropY,
                                     c1.ackX,
                                     c1.ackY,
                                     chart_name='two/sequence1.png')
        plotter.clear()
        plotter.create_sequence_plot(c3.x,
                                     c3.y,
                                     c3.dropX,
                                     c3.dropY,
                                     c3.ackX,
                                     c3.ackY,
                                     chart_name='two/sequence2.png')

        # Plot receiver rate
        plotter.clear()
        plotter.rateTimePlot(c2.packets_received,
                             Sim.scheduler.current_time(),
                             chart_name=None)
        plotter.rateTimePlot(c4.packets_received,
                             Sim.scheduler.current_time(),
                             chart_name='two/rateTime.png')

        # Plot queue size
        plotter.clear()
        plotter.queueSizePlot(l.queue_log_x,
                              l.queue_log_y,
                              l.dropped_packets_x,
                              l.dropped_packets_y,
                              chart_name='two/queueSize.png')

        # Plot congestion window
        plotter.clear()
        plotter.windowSizePlot(c1.window_x,
                               c1.window_y,
                               chart_name="two/windowSize1.png")
        plotter.clear()
        plotter.windowSizePlot(c3.window_x,
                               c3.window_y,
                               chart_name="two/windowSize2.png")
Beispiel #13
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        #Sim.set_debug('AppHandler')
        #Sim.set_debug('TCP')
        Sim.set_debug('Link')

        net = Network('networks/competing.txt')
        net.loss(self.loss)

        # setup routes
        # n1 - n3 - n4
        #      |
        #     n2
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n3 = net.get_node('n3')
        n4 = net.get_node('n4')

        # n1 forwarding entries
        n1.add_forwarding_entry(address=n3.get_address('n1'),link=n1.links[0])
        n1.add_forwarding_entry(address=n4.get_address('n3'),link=n1.links[0])

        # n2 forwarding entries
        n2.add_forwarding_entry(address=n3.get_address('n2'),link=n2.links[0])
        n2.add_forwarding_entry(address=n4.get_address('n3'),link=n2.links[0])

        # n3 forwarding entries
        n3.add_forwarding_entry(address=n1.get_address('n3'),link=n3.links[0])
        n3.add_forwarding_entry(address=n2.get_address('n3'),link=n3.links[1])
        n3.add_forwarding_entry(address=n4.get_address('n3'),link=n3.links[2])

        # n4 forwarding entries
        n4.add_forwarding_entry(address=n1.get_address('n3'),link=n4.links[0])
        n4.add_forwarding_entry(address=n2.get_address('n3'),link=n4.links[0])
        n4.add_forwarding_entry(address=n3.get_address('n4'),link=n4.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)
        t4 = Transport(n4)

        # setup application
        a1 = AppHandler('test1.txt')
        a2 = AppHandler('test2.txt')

        # setup connection
        c1 = TCP(t1,n1.get_address('n3'),1,n4.get_address('n3'),1,a1,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)
        c2 = TCP(t4,n4.get_address('n3'),1,n1.get_address('n3'),1,a1,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)

        c3 = TCP(t2,n2.get_address('n3'),2,n4.get_address('n3'),2,a2,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)
        c4 = TCP(t4,n4.get_address('n3'),2,n2.get_address('n3'),2,a2,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)

        # send a file
        with open('test1.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)
        with open('test2.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c3.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        # Variables for debugging
        self.c3 = c3
        self.c4 = c4
        self.c2 = c2
        self.c1 = c1
        self.t1 = t1
        self.t2 = t2
        self.net = net
        linkab = n1.links[0]
        self.linkab = linkab
        l = linkab

        # Plotting
        plotter = Plotter()

        # Plot sequence charts
        plotter.clear()
        plotter.create_sequence_plot(c1.x, c1.y, c1.dropX, c1.dropY, c1.ackX, c1.ackY, chart_name='advanced/competingRtt/sequence1.png')
        plotter.clear()
        plotter.create_sequence_plot(c3.x, c3.y, c3.dropX, c3.dropY, c3.ackX, c3.ackY, chart_name='advanced/competingRtt/sequence2.png')

        # Plot receiver rate
        plotter.clear()
        plotter.rateTimePlot(c2.packets_received, Sim.scheduler.current_time(), chart_name=None)
        plotter.rateTimePlot(c4.packets_received, Sim.scheduler.current_time(), chart_name='advanced/competingRtt/rateTime.png')

        # Plot queue size
        plotter.clear()
        plotter.queueSizePlot(l.queue_log_x, l.queue_log_y, l.dropped_packets_x, l.dropped_packets_y, chart_name='advanced/competingRtt/queueSize.png')

        # Plot congestion window
        plotter.clear()
        plotter.windowSizePlot(c1.window_x, c1.window_y, chart_name="advanced/competingRtt/windowSize1.png")
        plotter.clear()
        plotter.windowSizePlot(c3.window_x, c3.window_y, chart_name="advanced/competingRtt/windowSize2.png")
Beispiel #14
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')

        # setup network
        if self.use_queue:
            net = Network('networks/one-hop-queue.txt')
        else:
            net = Network('networks/one-hop.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)
        c2 = TCP(t2,
                 n2.get_address('n1'),
                 1,
                 n1.get_address('n2'),
                 1,
                 a,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=self.fast_recovery)

        # send a file
        with open(self.filename, 'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        print "%i,%f,%f,%f,%i,%f\n" % (self.window, time, avg, max, file_size,
                                       throughput)
        if self.loss == 0.0:
            print "Outputing results to experiment.csv"
            output_fh = open('experiment.csv', 'a')
            output_fh.write(
                "%i,%f,%f,%f,%i,%f\n" %
                (self.window, time, avg, max, file_size, throughput))
            output_fh.close()

        print "Saving the sequence plot"
        self.create_sequence_plot(c1.x, c1.y, c1.dropX, c1.dropY, c1.ackX,
                                  c1.ackY)
Beispiel #15
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        Sim.set_debug('AppHandler')
        Sim.set_debug('TCP')

        # setup network
        if self.use_queue:
            net = Network('networks/one-hop-queue.txt')
        else:
            net = Network('networks/one-hop.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a = AppHandler(self.filename)

        # setup connection
        c1 = TCP(t1,n1.get_address('n2'),1,n2.get_address('n1'),1,a,window=self.window)
        c2 = TCP(t2,n2.get_address('n1'),1,n1.get_address('n2'),1,a,window=self.window)

        # send a file
        with open(self.filename,'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        print "%i,%f,%f,%f,%i,%f\n" % (self.window,time,avg,max,file_size,throughput)
        if self.loss == 0.0:
            print "Outputing results to experiment.csv"
            output_fh = open('experiment.csv', 'a')
            output_fh.write("%i,%f,%f,%f,%i,%f\n" % (self.window,time,avg,max,file_size,throughput))
            output_fh.close()
Beispiel #16
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        #Sim.set_debug('AppHandler')
        #Sim.set_debug('TCP')
        Sim.set_debug('Link')

        net = Network('networks/five.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'),link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'),link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a1 = AppHandler('test1.txt')
        a2 = AppHandler('test2.txt')
        a3 = AppHandler('test3.txt')
        a4 = AppHandler('test4.txt')
        a5 = AppHandler('test5.txt')

        # setup connection
        c1 = TCP(t1,n1.get_address('n2'),1,n2.get_address('n1'),1,a1,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)
        c2 = TCP(t2,n2.get_address('n1'),1,n1.get_address('n2'),1,a1,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)

        c3 = TCP(t1,n1.get_address('n2'),2,n2.get_address('n1'),2,a2,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)
        c4 = TCP(t2,n2.get_address('n1'),2,n1.get_address('n2'),2,a2,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)

        c5 = TCP(t1,n1.get_address('n2'),3,n2.get_address('n1'),3,a3,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)
        c6 = TCP(t2,n2.get_address('n1'),3,n1.get_address('n2'),3,a3,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)

        c7 = TCP(t1,n1.get_address('n2'),4,n2.get_address('n1'),4,a4,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)
        c8 = TCP(t2,n2.get_address('n1'),4,n1.get_address('n2'),4,a4,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)

        c9 = TCP(t1,n1.get_address('n2'),5,n2.get_address('n1'),5,a5,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)
        c0 = TCP(t2,n2.get_address('n1'),5,n1.get_address('n2'),5,a5,window=self.window,threshold=self.threshold,fast_recovery=self.fast_recovery)

        # send a file
        with open('test1.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)
        with open('test2.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=1.5, event=data, handler=c3.send)
        with open('test3.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=2, event=data, handler=c5.send)
        with open('test4.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=2.5, event=data, handler=c7.send)
        with open('test5.txt','r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=3, event=data, handler=c9.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        # Variables for debugging
        self.c3 = c3
        self.c4 = c4
        self.c2 = c2
        self.c1 = c1
        self.t1 = t1
        self.t2 = t2
        self.net = net
        linkab = n1.links[0]
        self.linkab = linkab
        l = linkab

        # Plotting
        plotter = Plotter()

        # Plot sequence charts
        #plotter.clear()
        #plotter.create_sequence_plot(c1.x, c1.y, c1.dropX, c1.dropY, c1.ackX, c1.ackY, chart_name='five/sequence1.png')
        #plotter.clear()
        #plotter.create_sequence_plot(c3.x, c3.y, c3.dropX, c3.dropY, c3.ackX, c3.ackY, chart_name='five/sequence2.png')

        # Plot receiver rate
        plotter.clear()
        plotter.rateTimePlot(c2.packets_received, Sim.scheduler.current_time(), chart_name='five/rateTime1.png')
        plotter.rateTimePlot(c4.packets_received, Sim.scheduler.current_time(), chart_name='five/rateTime2.png')
        plotter.rateTimePlot(c6.packets_received, Sim.scheduler.current_time(), chart_name='five/rateTime3.png')
        plotter.rateTimePlot(c8.packets_received, Sim.scheduler.current_time(), chart_name='five/rateTime4.png')
        plotter.rateTimePlot(c0.packets_received, Sim.scheduler.current_time(), chart_name='five/rateTime5.png')

        # Plot queue size
        plotter.clear()
        plotter.queueSizePlot(l.queue_log_x, l.queue_log_y, l.dropped_packets_x, l.dropped_packets_y, chart_name='five/queueSize.png')
Beispiel #17
0
    def run(self):
        # parameters
        Sim.scheduler.reset()
        #Sim.set_debug('AppHandler')
        #Sim.set_debug('TCP')
        Sim.set_debug('Link')

        net = Network('networks/one.txt')
        net.loss(self.loss)

        # setup routes
        n1 = net.get_node('n1')
        n2 = net.get_node('n2')
        n1.add_forwarding_entry(address=n2.get_address('n1'), link=n1.links[0])
        n2.add_forwarding_entry(address=n1.get_address('n2'), link=n2.links[0])

        # setup transport
        t1 = Transport(n1)
        t2 = Transport(n2)

        # setup application
        a1 = AppHandler('test.txt')

        # setup connection
        c1 = TCP(t1,
                 n1.get_address('n2'),
                 1,
                 n2.get_address('n1'),
                 1,
                 a1,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=True,
                 aimdc=5.0 / 6.0)
        c2 = TCP(t2,
                 n2.get_address('n1'),
                 1,
                 n1.get_address('n2'),
                 1,
                 a1,
                 window=self.window,
                 threshold=self.threshold,
                 fast_recovery=True,
                 aimdc=5.0 / 6.0)

        # send a file
        with open('test.txt', 'r') as f:
            while True:
                data = f.read(1000)
                if not data:
                    break
                Sim.scheduler.add(delay=0, event=data, handler=c1.send)

        # run the simulation
        Sim.scheduler.run()

        # print some results
        print
        print "========== Overall results =========="
        time = Sim.scheduler.current_time()
        print "Total time: %f seconds" % time
        avg = numpy.mean(c2.queueing_delay_list)
        print "Average queueing delay: %f" % avg
        max = numpy.max(c2.queueing_delay_list)
        print "Max queueing delay: %f" % max
        file_size = os.path.getsize(self.filename)
        print "File size: %i" % file_size
        throughput = file_size / time
        print "Throughput: %f" % throughput

        plotter = Plotter()
        print "Saving the sequence plot"
        plotter.create_sequence_plot(c1.x,
                                     c1.y,
                                     c1.dropX,
                                     c1.dropY,
                                     c1.ackX,
                                     c1.ackY,
                                     chart_name='advanced/aimd/sequence.png')

        plotter.clear()
        plotter.rateTimePlot(c2.packets_received, Sim.scheduler.current_time(),
                             'advanced/aimd/rateTime1.png')

        linkab = n1.links[0]
        self.linkab = linkab
        plotter.clear()
        plotter.queueSizePlot(linkab.queue_log_x,
                              linkab.queue_log_y,
                              linkab.dropped_packets_x,
                              linkab.dropped_packets_y,
                              chart_name='advanced/aimd/queueSize.png')

        plotter.clear()
        plotter.windowSizePlot(c1.window_x,
                               c1.window_y,
                               chart_name="advanced/aimd/windowSize1.png")