2 from ns.core 
import Simulator, Seconds, Config, int64x64_t
 
   20         Simulator.ScheduleNow(callback, 
"args")
 
   23         self.assertEqual(self._cb_time.GetSeconds(), 0.0)
 
   32         Simulator.Schedule(Seconds(123), callback, 
"args")
 
   35         self.assertEqual(self._cb_time.GetSeconds(), 123.0)
 
   45         Simulator.Schedule(Seconds(123), null)
 
   46         Simulator.ScheduleDestroy(callback, 
"args")
 
   50         self.assertEqual(self._cb_time.GetSeconds(), 123.0)
 
   53         def callback(context, args):
 
   61         Simulator.ScheduleWithContext(54321, Seconds(123), callback, 
"args")
 
   65         self.assertEqual(self._cb_time.GetSeconds(), 123.0)
 
   68         self.assert_(Seconds(123) == Seconds(123))
 
   69         self.assert_(Seconds(123) >= Seconds(123))
 
   70         self.assert_(Seconds(123) <= Seconds(123))
 
   71         self.assert_(Seconds(124) > Seconds(123))
 
   72         self.assert_(Seconds(123) < Seconds(124))
 
   75         self.assertEqual(Seconds(10) + Seconds(5), Seconds(15))
 
   76         self.assertEqual(Seconds(10) - Seconds(5), Seconds(5))
 
   78         v1 = int64x64_t(5.0)*int64x64_t(10)
 
   79         self.assertEqual(v1, int64x64_t(50))
 
   82         Config.SetDefault(
"ns3::OnOffApplication::PacketSize", ns.core.UintegerValue(123))
 
   86         node = ns.network.Node()
 
   87         internet = ns.internet.InternetStackHelper()
 
   88         internet.Install(node)
 
   91         def rx_callback(socket):
 
   95         sink = ns.network.Socket.CreateSocket(node, ns.core.TypeId.LookupByName(
"ns3::UdpSocketFactory"))
 
   96         sink.Bind(ns.network.InetSocketAddress(ns.network.Ipv4Address.GetAny(), 80))
 
   97         sink.SetRecvCallback(rx_callback)
 
   99         source = ns.network.Socket.CreateSocket(node, ns.core.TypeId.LookupByName(
"ns3::UdpSocketFactory"))
 
  100         source.SendTo(ns.network.Packet(19), 0, ns.network.InetSocketAddress(ns.network.Ipv4Address(
"127.0.0.1"), 80))
 
  104         self.assertEqual(self._received_packet.GetSize(), 19)
 
  112         queue = ns.network.DropTailQueue()
 
  114         queue.SetAttribute(
"MaxPackets", ns.core.UintegerValue(123456))
 
  116         limit = ns.core.UintegerValue()
 
  117         queue.GetAttribute(
"MaxPackets", limit)
 
  118         self.assertEqual(limit.Get(), 123456)
 
  121         mobility = ns.mobility.RandomWaypointMobilityModel()
 
  122         ptr = ns.core.PointerValue()
 
  123         mobility.GetAttribute(
"PositionAllocator", ptr)
 
  124         self.assertEqual(ptr.GetObject(), 
None)
 
  126         pos = ns.mobility.ListPositionAllocator()
 
  127         mobility.SetAttribute(
"PositionAllocator", ns.core.PointerValue(pos))
 
  129         ptr = ns.core.PointerValue()
 
  130         mobility.GetAttribute(
"PositionAllocator", ptr)
 
  131         self.assert_(ptr.GetObject() 
is not None)
 
  134         csma = ns.csma.CsmaNetDevice()
 
  135         channel = ns.csma.CsmaChannel()
 
  138         c1 = csma.GetChannel()
 
  139         c2 = csma.GetChannel()
 
  141         self.assert_(c1 
is c2)
 
  144         typeId1 = ns.core.TypeId.LookupByNameFailSafe(
"ns3::UdpSocketFactory")
 
  145         self.assertEqual(typeId1.GetName (), 
"ns3::UdpSocketFactory")
 
  147         self.assertRaises(KeyError, ns.core.TypeId.LookupByNameFailSafe, 
"__InvalidTypeName__")
 
  150         cmd = ns.core.CommandLine()
 
  151         cmd.AddValue(
"Test1", 
"this is a test option")
 
  152         cmd.AddValue(
"Test2", 
"this is a test option")
 
  153         cmd.AddValue(
"Test3", 
"this is a test option", variable=
"test_xxx")
 
  161         cmd.AddValue(
"Test4", 
"this is a test option", variable=
"test_foo", namespace=foo)
 
  163         cmd.Parse([
"python", 
"--Test1=value1", 
"--Test2=value2", 
"--Test3=123", 
"--Test4=xpto"])
 
  165         self.assertEqual(cmd.Test1, 
"value1")
 
  166         self.assertEqual(cmd.Test2, 
"value2")
 
  167         self.assertEqual(cmd.test_xxx, 
"123")
 
  168         self.assertEqual(foo.test_foo, 
"xpto")
 
  171         class MyNode(ns.network.Node):
 
  173                 super(MyNode, self).__init__()
 
  178 if __name__ == 
'__main__':
 
def testAttributes
Yes, I know, the GetAttribute interface for Python is horrible, we should fix this soon...
 
def testTimeNumericOperations
 
def testScheduleWithContext