A Discrete-Event Network Simulator
API
__init__.py
Go to the documentation of this file.
1 from ns import *
2 
3 # Some useful tricks for visualizer
4 # we need to check if the node has a mobility model, but we can't pass Ptr<MobilityModel> to python
5 ns.cppyy.cppdef(
6  """using namespace ns3; bool hasMobilityModel(Ptr<Node> node){ return !(node->GetObject<MobilityModel>() == 0); };"""
7 )
8 ns.cppyy.cppdef(
9  """using namespace ns3; Vector3D getNodePosition(Ptr<Node> node){ return node->GetObject<MobilityModel>()->GetPosition(); };"""
10 )
11 ns.cppyy.cppdef(
12  """using namespace ns3; Ptr<Ipv4> getNodeIpv4(Ptr<Node> node){ return node->GetObject<Ipv4>(); };"""
13 )
14 ns.cppyy.cppdef(
15  """using namespace ns3; Ptr<Ipv6> getNodeIpv6(Ptr<Node> node){ return node->GetObject<Ipv6>(); };"""
16 )
17 ns.cppyy.cppdef(
18  """using namespace ns3; std::string getMobilityModelName(Ptr<Node> node){ return node->GetObject<MobilityModel>()->GetInstanceTypeId().GetName(); };"""
19 )
20 ns.cppyy.cppdef(
21  """using namespace ns3; bool hasOlsr(Ptr<Node> node){ return !(node->GetObject<olsr::RoutingProtocol>() == 0); };"""
22 )
23 ns.cppyy.cppdef(
24  """using namespace ns3; Ptr<olsr::RoutingProtocol> getNodeOlsr(Ptr<Node> node){ return node->GetObject<olsr::RoutingProtocol>(); };"""
25 )
26 
27 
28 from .core import add_initialization_hook, register_plugin, set_bounds, start