Exemplo n.º 1
0
    def testScheduleDestroy(self):
        """! Test schedule destroy
        @param self this object
        @return none
        """
        def callback(args):
            """! Callback function
            @param args
            @return none
            """
            self._args_received = args
            self._cb_time = Simulator.Now()

        Simulator.Destroy()
        self._args_received = None
        self._cb_time = None

        def null():
            pass

        Simulator.Schedule(Seconds(123), null)
        Simulator.ScheduleDestroy(callback, "args")
        Simulator.Run()
        Simulator.Destroy()
        self.assertEqual(self._args_received, "args")
        self.assertEqual(self._cb_time.GetSeconds(), 123.0)
Exemplo n.º 2
0
    def testScheduleDestroy(self):
        def callback(args):
            self._args_received = args
            self._cb_time = Simulator.Now()

        Simulator.Destroy()
        self._args_received = None
        self._cb_time = None

        def null():
            pass

        Simulator.Schedule(Seconds(123), null)
        Simulator.ScheduleDestroy(callback, "args")
        Simulator.Run()
        Simulator.Destroy()
        self.assertEqual(self._args_received, "args")
        self.assertEqual(self._cb_time.GetSeconds(), 123.0)
Exemplo n.º 3
0
    def testScheduleNow(self):
        def callback(args):
            self._args_received = args
            self._cb_time = Simulator.Now()

        Simulator.Destroy()
        self._args_received = None
        self._cb_time = None
        Simulator.ScheduleNow(callback, "args")
        Simulator.Run()
        self.assertEqual(self._args_received, "args")
        self.assertEqual(self._cb_time.GetSeconds(), 0.0)
Exemplo n.º 4
0
    def testScheduleWithContext(self):
        def callback(context, args):
            self._context_received = context
            self._args_received = args
            self._cb_time = Simulator.Now()

        Simulator.Destroy()
        self._args_received = None
        self._cb_time = None
        self._context_received = None
        Simulator.ScheduleWithContext(54321, Seconds(123), callback, "args")
        Simulator.Run()
        self.assertEqual(self._context_received, 54321)
        self.assertEqual(self._args_received, "args")
        self.assertEqual(self._cb_time.GetSeconds(), 123.0)
Exemplo n.º 5
0
 def testScheduleNow(self):
     """! Test schedule now
     @param self this object
     @return none
     """
     def callback(args):
         """! Callback function
         @param args arguments
         return none
         """
         self._args_received = args
         self._cb_time = Simulator.Now()
     Simulator.Destroy()
     self._args_received = None
     self._cb_time = None
     Simulator.ScheduleNow(callback, "args")
     Simulator.Run()
     self.assertEqual(self._args_received, "args")
     self.assertEqual(self._cb_time.GetSeconds(), 0.0)
Exemplo n.º 6
0
 def testScheduleWithContext(self):
     """! Test schedule with context
     @param self this object
     @return none
     """
     def callback(context, args):
         """! Callback
         @param context the cntet
         @param args the arguments
         @return none
         """
         self._context_received = context
         self._args_received = args
         self._cb_time = Simulator.Now()
     Simulator.Destroy()
     self._args_received = None
     self._cb_time = None
     self._context_received = None
     Simulator.ScheduleWithContext(54321, Seconds(123), callback, "args")
     Simulator.Run()
     self.assertEqual(self._context_received, 54321)
     self.assertEqual(self._args_received, "args")
     self.assertEqual(self._cb_time.GetSeconds(), 123.0)
Exemplo n.º 7
0
server.Stop(Seconds(10.0))

udp_echo_client_helper = UdpEchoClientHelper(Ipv4Address("10.1.1.1"), 50000)
udp_echo_client_helper.SetAttribute("MaxPackets", UintegerValue(1000))
udp_echo_client_helper.SetAttribute("Interval", TimeValue(Seconds(1.0)))
#udp_echo_client_helper.SetAttribute("Interval", TimeValue(Seconds(0.1)))
#udp_echo_client_helper.SetAttribute("Interval", TimeValue(Seconds(0.01)))
udp_echo_client_helper.SetAttribute("PacketSize", UintegerValue(1024))

#em1 = Ptr()
#em1 = CreateObjectWithAttributes("RanVar", StringValue ("ns3::UniformRandomVariable[Min=0.0,Max=1.0]"), "ErrorRate", DoubleValue (0.01));

#udp_echo_client_helper.SetAttribute("RecieveErrorModel", PointerValue(em1))
client_1 = udp_echo_client_helper.Install(right_node_1)
client_1.Start(Seconds(2.0))
client_1.Stop(Seconds(9.0))

client_2 = udp_echo_client_helper.Install(right_node_2)
client_2.Start(Seconds(2.0))
client_2.Stop(Seconds(9.0))

client_3 = udp_echo_client_helper.Install(left_node_2)
client_3.Start(Seconds(2.0))
client_3.Stop(Seconds(9.0))

point_to_point_helper.EnablePcapAll("dumbbell")
#PointToPointHelper.EnablePcapHelper("dumbbell")

Simulator.Run()
Simulator.Destroy()