Bugfixing for ns3::MatrixPropagationLossModel ...
[nepi.git] / src / nepi / testbeds / ns3 / factories_metadata.py
index ace0f27..c2814fc 100644 (file)
@@ -1,12 +1,12 @@
-#!/usr/bin/env python
 # -*- coding: utf-8 -*-
 
+from util import  _get_ipv4_protocol_guid, _get_node_guid, _get_dev_number
 from nepi.util import tags
 from nepi.util.constants import AF_INET, ApplicationStatus as AS, \
         FactoryCategories as FC
 from nepi.util.tunchannel_impl import \
     preconfigure_tunchannel, postconfigure_tunchannel, \
-    wait_tunchannel, create_tunchannel
+    prestart_tunchannel, create_tunchannel
 import re
 
 wifi_standards = dict({
@@ -42,39 +42,6 @@ service_flow_scheduling_type = dict ({
     "SF_TYPE_ALL": 255
 })
 
-def _get_ipv4_protocol_guid(testbed_instance, node_guid):
-    # search for the Ipv4L3Protocol asociated with the device
-    protos_guids = testbed_instance.get_connected(node_guid, "protos", "node")
-    if len(protos_guids) == 0:
-        raise RuntimeError("No protocols where found for the node %d" % node_guid)
-    ipv4_guid = None
-    for proto_guid in protos_guids:
-        proto_factory_id = testbed_instance._create[proto_guid]
-        if proto_factory_id == "ns3::Ipv4L3Protocol":
-            ipv4_guid = proto_guid
-            break
-    if not ipv4_guid:
-        raise RuntimeError("No Ipv4L3Protocol associated to node %d. Can't add Ipv4 addresses" % node_guid)
-    return ipv4_guid
-
-def _get_node_guid(testbed_instance, guid):
-    # search for the node asociated with the device
-    node_guids = testbed_instance.get_connected(guid, "node", "devs")
-    if len(node_guids) == 0:
-        raise RuntimeError("Can't instantiate interface %d outside node" % guid)
-    node_guid = node_guids[0]
-    return node_guid
-
-def _get_dev_number(testbed_instance, guid):
-    node_guid = _get_node_guid(testbed_instance, guid)
-    dev_guids = testbed_instance.get_connected(node_guid, "devs", "node")
-    interface_number = 0
-    for guid_ in dev_guids:
-        if guid_ == guid:
-            break
-        interface_number += 1
-    return interface_number
-
 def _follow_trace(testbed_instance, guid, trace_id, filename):
     testbed_instance.follow_trace(guid, trace_id, filename)
     filepath = testbed_instance.trace_filepath(guid, trace_id)
@@ -211,7 +178,16 @@ def create_node(testbed_instance, guid):
     element = testbed_instance._elements[guid]
     element.AggregateObject(testbed_instance.ns3.PacketSocketFactory())
 
-def create_wifi_standard_model(testbed_instance, guid):
+def create_wifi_phy(testbed_instance, guid):
+    create_element(testbed_instance, guid)
+    element = testbed_instance._elements[guid]
+    parameters = testbed_instance._get_parameters(guid)
+    standard = parameters.get("Standard")
+    if not standard:
+        raise RuntimeError("No wifi standard set for %d" % guid)
+    element.ConfigureStandard(wifi_standards[standard])
+
+def create_wifi_mac(testbed_instance, guid):
     create_element(testbed_instance, guid)
     element = testbed_instance._elements[guid]
     parameters = testbed_instance._get_parameters(guid)
@@ -219,6 +195,11 @@ def create_wifi_standard_model(testbed_instance, guid):
     if not standard:
         raise RuntimeError("No wifi standard set for %d" % guid)
     element.ConfigureStandard(wifi_standards[standard])
+    qos = parameters.get("QosSupported")
+    # BUG: There seems to be an inheritance problem with the Python Bindings and SetQosSupported.
+    #      It seems to be onbly defined for regular-wifi-mac.h and not for its children...
+    #      Report this!
+    # element.SetQosSupported(qos)
 
 def create_waypoint_mobility(testbed_instance, guid):
     create_element(testbed_instance, guid)
@@ -407,7 +388,6 @@ def configure_element(testbed_instance, guid):
 
 def configure_device(testbed_instance, guid):
     configure_traces(testbed_instance, guid)
-
     element = testbed_instance._elements[guid]
 
     parameters = testbed_instance._get_parameters(guid)
@@ -495,9 +475,11 @@ def configure_node(testbed_instance, guid):
                     ifindex = ipv4.GetInterfaceForPrefix(nexthop_address, ifmask)
                     if ifindex == ifidx:
                         break
+                if ifindex == ifidx:
+                    break
             if ifindex < 0:
                 # Check previous ptp routes
-                for chaindest, chainprefix, chainhop in routes:
+                for chaindest, chainprefix, chainhop, metric in routes:
                     if chaindest == nexthop and chainprefix == 32:
                         chainhop_address = ns3.Ipv4Address(chainhop)
                         for ifidx in xrange(nifaces):
@@ -528,9 +510,28 @@ def configure_station(testbed_instance, guid):
     element = testbed_instance._elements[guid]
     element.Start()
 
+def configure_matrix_propagation(testbed_instance, guid):
+    create_element(testbed_instance, guid)
+    element = testbed_instance._elements[guid]
+    mp_guids = testbed_instance.get_connected(guid, "mobpair", "matrix")
+    for mpg in mp_guids:
+        mas = testbed_instance.get_connected(mpg, "ma", "mp")
+        if len(mas) != 1:
+            raise RuntimeError("Wrong number of source mobility models for MobilityPair %d" % guid)
+        mbs = testbed_instance.get_connected(mpg, "mb", "mp")
+        if len(mbs) != 1:
+            raise RuntimeError("Wrong number of destination mobility models for MobilityPair %d" % guid)
+        parameters = testbed_instance._get_parameters(mpg)
+        loss = parameters.get("Loss")
+        symmetric = parameters.get("Symmetric")
+        mas_elem = testbed_instance._elements[mas[0]]
+        mbs_elem = testbed_instance._elements[mbs[0]]
+        element.SetLoss(mas_elem, mbs_elem, loss, symmetric)    
+
+
 ###  Factories  ###
 
-factories_order = ["ns3::BasicEnergySource",
+factories_create_order = ["ns3::BasicEnergySource",
     "ns3::WifiRadioEnergyModel",
     "ns3::BSSchedulerRtps",
     "ns3::BSSchedulerSimple",
@@ -580,7 +581,6 @@ factories_order = ["ns3::BasicEnergySource",
     "ns3::EdcaTxopN",
     "ns3::StaWifiMac",
     "ns3::ApWifiMac",
-    "ns3::QadhocWifiMac",
     "ns3::MinstrelWifiManager",
     "ns3::CaraWifiManager",
     "ns3::AarfcdWifiManager",
@@ -668,6 +668,7 @@ factories_order = ["ns3::BasicEnergySource",
     "ns3::NakagamiPropagationLossModel",
     "ns3::FixedRssLossModel",
     "ns3::MatrixPropagationLossModel",
+    "ns3::Nepi::MobilityPair",
     "ns3::RangePropagationLossModel",
     "ns3::RandomPropagationDelayModel",
     "ns3::ConstantSpeedPropagationDelayModel",
@@ -689,6 +690,166 @@ factories_order = ["ns3::BasicEnergySource",
     "ns3::SubscriberStationNetDevice",
  ]
 
+factories_configure_order = ["ns3::BasicEnergySource",
+    "ns3::WifiRadioEnergyModel",
+    "ns3::BSSchedulerRtps",
+    "ns3::BSSchedulerSimple",
+    "ns3::UdpTraceClient",
+    "ns3::UdpServer",
+    "ns3::UdpClient",
+    "ns3::FlowMonitor",
+    "ns3::Radvd",
+    "ns3::Ping6",
+    "ns3::flame::FlameProtocol",
+    "ns3::flame::FlameRtable",
+    "ns3::dot11s::AirtimeLinkMetricCalculator",
+    "ns3::dot11s::HwmpProtocol",
+    "ns3::dot11s::HwmpRtable",
+    "ns3::dot11s::PeerManagementProtocol",
+    "ns3::dot11s::PeerLink",
+    "ns3::MeshWifiInterfaceMac",
+    "ns3::MeshPointDevice",
+    "ns3::UanMacRcGw",
+    "ns3::UanMacRc",
+    "ns3::UanPhyCalcSinrDual",
+    "ns3::UanPhyPerGenDefault",
+    "ns3::UanPhyDual",
+    "ns3::UanPropModelThorp",
+    "ns3::UanMacCw",
+    "ns3::UanNoiseModelDefault",
+    "ns3::UanMacAloha",
+    "ns3::UanPropModelIdeal",
+    "ns3::UanTransducerHd",
+    "ns3::UanPhyCalcSinrDefault",
+    "ns3::UanPhyGen",
+    "ns3::UanPhyCalcSinrFhFsk",
+    "ns3::UanPhyPerUmodem",
+    "ns3::UanChannel",
+    "ns3::V4Ping",
+    "ns3::AthstatsWifiTraceSink",
+    "ns3::FlameStack",
+    "ns3::Dot11sStack",
+    "ns3::NonCommunicatingNetDevice",
+    "ns3::HalfDuplexIdealPhy",
+    "ns3::AlohaNoackNetDevice",
+    "ns3::SpectrumAnalyzer",
+    "ns3::WaveformGenerator",
+    "ns3::MultiModelSpectrumChannel",
+    "ns3::SingleModelSpectrumChannel",
+    "ns3::MsduStandardAggregator",
+    "ns3::EdcaTxopN",
+    "ns3::StaWifiMac",
+    "ns3::ApWifiMac",
+    "ns3::MinstrelWifiManager",
+    "ns3::CaraWifiManager",
+    "ns3::AarfcdWifiManager",
+    "ns3::OnoeWifiManager",
+    "ns3::AmrrWifiManager",
+    "ns3::ConstantRateWifiManager",
+    "ns3::IdealWifiManager",
+    "ns3::AarfWifiManager",
+    "ns3::ArfWifiManager",
+    "ns3::WifiNetDevice",
+    "ns3::AdhocWifiMac",
+    "ns3::DcaTxop",
+    "ns3::WifiMacQueue",
+    "ns3::YansWifiChannel",
+    "ns3::YansWifiPhy",
+    "ns3::NistErrorRateModel",
+    "ns3::YansErrorRateModel",
+    "ns3::WaypointMobilityModel",
+    "ns3::ConstantAccelerationMobilityModel",
+    "ns3::RandomDirection2dMobilityModel",
+    "ns3::RandomWalk2dMobilityModel",
+    "ns3::SteadyStateRandomWaypointMobilityModel",
+    "ns3::RandomWaypointMobilityModel",
+    "ns3::GaussMarkovMobilityModel",
+    "ns3::ConstantVelocityMobilityModel",
+    "ns3::ConstantPositionMobilityModel",
+    "ns3::ListPositionAllocator",
+    "ns3::GridPositionAllocator",
+    "ns3::RandomRectanglePositionAllocator",
+    "ns3::RandomBoxPositionAllocator",
+    "ns3::RandomDiscPositionAllocator",
+    "ns3::UniformDiscPositionAllocator",
+    "ns3::HierarchicalMobilityModel",
+    "ns3::aodv::RoutingProtocol",
+    "ns3::UdpEchoServer",
+    "ns3::UdpEchoClient",
+    "ns3::PacketSink",
+    "ns3::OnOffApplication",
+    "ns3::VirtualNetDevice",
+    "ns3::FdNetDevice",
+    "ns3::Nepi::TunChannel",
+    "ns3::TapBridge",
+    "ns3::BridgeChannel",
+    "ns3::BridgeNetDevice",
+    "ns3::EmuNetDevice",
+    "ns3::CsmaChannel",
+    "ns3::CsmaNetDevice",
+    "ns3::PointToPointRemoteChannel",
+    "ns3::PointToPointChannel",
+    "ns3::PointToPointNetDevice",
+    "ns3::BaseStationNetDevice",
+    "ns3::SubscriberStationNetDevice",
+    "ns3::NscTcpL4Protocol",
+    "ns3::Icmpv6L4Protocol",
+    "ns3::Ipv6OptionPad1",
+    "ns3::Ipv6OptionPadn",
+    "ns3::Ipv6OptionJumbogram",
+    "ns3::Ipv6OptionRouterAlert",
+    "ns3::Ipv6ExtensionHopByHop",
+    "ns3::Ipv6ExtensionDestination",
+    "ns3::Ipv6ExtensionFragment",
+    "ns3::Ipv6ExtensionRouting",
+    "ns3::Ipv6ExtensionLooseRouting",
+    "ns3::Ipv6ExtensionESP",
+    "ns3::Ipv6ExtensionAH",
+    "ns3::Ipv6L3Protocol",
+    "ns3::LoopbackNetDevice",
+    "ns3::Icmpv4L4Protocol",
+    "ns3::RttMeanDeviation",
+    "ns3::ArpL3Protocol",
+    "ns3::TcpL4Protocol",
+    "ns3::UdpL4Protocol",
+    "ns3::Ipv4L3Protocol",
+    "ns3::SimpleNetDevice",
+    "ns3::SimpleChannel",
+    "ns3::PacketSocket",
+    "ns3::DropTailQueue",
+    "ns3::Node",
+    "ns3::FriisSpectrumPropagationLossModel",
+    "ns3::Cost231PropagationLossModel",
+    "ns3::JakesPropagationLossModel",
+    "ns3::RandomPropagationLossModel",
+    "ns3::FriisPropagationLossModel",
+    "ns3::TwoRayGroundPropagationLossModel",
+    "ns3::LogDistancePropagationLossModel",
+    "ns3::ThreeLogDistancePropagationLossModel",
+    "ns3::NakagamiPropagationLossModel",
+    "ns3::FixedRssLossModel",
+    "ns3::MatrixPropagationLossModel",
+    "ns3::Nepi::MobilityPair",
+    "ns3::RangePropagationLossModel",
+    "ns3::RandomPropagationDelayModel",
+    "ns3::ConstantSpeedPropagationDelayModel",
+    "ns3::RateErrorModel",
+    "ns3::ListErrorModel",
+    "ns3::ReceiveListErrorModel",
+    "ns3::PacketBurst",
+    "ns3::EnergySourceContainer",
+    "ns3::BSSchedulerRtps",
+    "ns3::BSSchedulerSimple",
+    "ns3::SimpleOfdmWimaxChannel",
+    "ns3::SimpleOfdmWimaxPhy",
+    "ns3::UplinkSchedulerMBQoS",
+    "ns3::UplinkSchedulerRtps",
+    "ns3::UplinkSchedulerSimple",
+    "ns3::IpcsClassifierRecord",
+    "ns3::ServiceFlow",
+ ]
+
+
 factories_info = dict({
     "ns3::Ping6": dict({
         "category": FC.CATEGORY_APPLICATIONS,
@@ -735,6 +896,7 @@ factories_info = dict({
         "configure_function": configure_node,
         "help": "",
         "connector_types": ["devs", "apps", "protos", "mobility"],
+        "box_attributes": ["Up"],
         "tags": [tags.NODE, tags.ALLOW_ROUTES],
     }),
      "ns3::GridPositionAllocator": dict({
@@ -784,7 +946,7 @@ factories_info = dict({
         "create_function": create_element,
         "configure_function": configure_element,
         "help": "",
-        "connector_types": ["node"],
+        "connector_types": ["node", "mp"],
         "box_attributes": ["Position",
            "Velocity"],
         "tags": [tags.MOBILE],
@@ -904,10 +1066,10 @@ factories_info = dict({
     }),
      "ns3::AdhocWifiMac": dict({
         "category": FC.CATEGORY_MAC_MODELS,
-        "create_function": create_element,
+        "create_function": create_wifi_mac,
         "configure_function": configure_element,
         "help": "",
-        "connector_types": [],
+        "connector_types": ["dev"],
         "box_attributes": ["CtsTimeout",
             "AckTimeout",
             "BasicBlockAckTimeout",
@@ -917,14 +1079,16 @@ factories_info = dict({
             "Slot",
             "Pifs",
             "MaxPropagationDelay",
-            "Ssid"],
+            "Ssid",
+            "Standard",
+            "QosSupported"],
     }),
      "ns3::ConstantAccelerationMobilityModel": dict({
         "category": FC.CATEGORY_MOBILITY_MODELS,
         "create_function": create_element,
         "configure_function": configure_element,
         "help": "",
-        "connector_types": ["node"],
+        "connector_types": ["node", "mp"],
         "box_attributes": ["Position",
             "Velocity"],
         "tags": [tags.MOBILE],
@@ -1048,7 +1212,7 @@ factories_info = dict({
         "help": "Network interface associated to a file descriptor",
         "connector_types": ["node", "->fd"],
         "box_attributes": ["Address", 
-            "tun_proto", "tun_addr", "tun_port", "tun_key"],
+            "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher_fdnd"],
         "traces": ["fdpcap", "fdascii"],
         "tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
     }),
@@ -1057,7 +1221,7 @@ factories_info = dict({
         "create_function": create_tunchannel,
         "preconfigure_function": preconfigure_tunchannel,
         "configure_function": postconfigure_tunchannel,
-        "prestart_function": wait_tunchannel,
+        "prestart_function": prestart_tunchannel,
         "help": "Channel to forward FdNetDevice data to "
                 "other TAP interfaces supporting the NEPI tunneling protocol.",
         "connector_types": ["fd->", "udp", "tcp"],
@@ -1539,10 +1703,16 @@ factories_info = dict({
      "ns3::MatrixPropagationLossModel": dict({
         "category": FC.CATEGORY_LOSS_MODELS,
         "create_function": create_element,
-        "configure_function": configure_element,
+        "configure_function": configure_matrix_propagation,
         "help": "",
-        "connector_types": [],
+        "connector_types": ["mobpair", "chan"],
         "box_attributes": ["DefaultLoss"],
+    }),
+    "ns3::Nepi::MobilityPair": dict({
+        "category": FC.CATEGORY_LOSS_MODELS,
+        "help": "",
+        "connector_types": ["matrix", "ma", "mb"],
+        "box_attributes": ["Loss", "Symmetric"],
     }),
      "ns3::WifiNetDevice": dict({
         "category": FC.CATEGORY_DEVICES,
@@ -1583,7 +1753,7 @@ factories_info = dict({
     }),
      "ns3::StaWifiMac": dict({
         "category": FC.CATEGORY_MAC_MODELS,
-        "create_function": create_wifi_standard_model,
+        "create_function": create_wifi_mac,
         "configure_function": configure_element,
         "help": "Station Wifi MAC Model",
         "connector_types": ["dev"],
@@ -1600,7 +1770,8 @@ factories_info = dict({
             "Pifs",
             "MaxPropagationDelay",
             "Ssid",
-            "Standard"],
+            "Standard",
+            "QosSupported"],
     }),
      "ns3::UdpEchoClient": dict({
         "category": FC.CATEGORY_APPLICATIONS,
@@ -1668,7 +1839,7 @@ factories_info = dict({
         "create_function": create_element,
         "configure_function": configure_element,
         "help": "",
-        "connector_types": ["node"],
+        "connector_types": ["node", "mp"],
         "box_attributes": ["Position",
             "Velocity"],
         "tags": [tags.MOBILE],
@@ -1752,7 +1923,7 @@ factories_info = dict({
     }),
      "ns3::ApWifiMac": dict({
         "category": FC.CATEGORY_MAC_MODELS,
-        "create_function": create_wifi_standard_model,
+        "create_function": create_wifi_mac,
         "configure_function": configure_element,
         "help": "Access point Wifi MAC Model",
         "connector_types": ["dev"],
@@ -1768,7 +1939,8 @@ factories_info = dict({
             "Pifs",
             "MaxPropagationDelay",
             "Ssid",
-            "Standard"],
+            "Standard",
+            "QosSupported"],
     }),
      "ns3::YansErrorRateModel": dict({
         "category": FC.CATEGORY_ERROR_MODELS,
@@ -1853,7 +2025,7 @@ factories_info = dict({
     }),
      "ns3::YansWifiPhy": dict({
         "category": FC.CATEGORY_PHY_MODELS,
-        "create_function": create_wifi_standard_model,
+        "create_function": create_wifi_phy,
         "configure_function": configure_element,
         "help": "",
         "connector_types": ["dev", "err", "chan"],
@@ -2146,23 +2318,6 @@ factories_info = dict({
             "RtsCtsThreshold",
             "FragmentationThreshold",
             "NonUnicastMode"],
-    }),
-     "ns3::QadhocWifiMac": dict({
-        "category": FC.CATEGORY_MAC_MODELS,
-        "create_function": create_element,
-        "configure_function": configure_element,
-        "help": "",
-        "connector_types": [],
-        "box_attributes": ["CtsTimeout",
-            "AckTimeout",
-            "BasicBlockAckTimeout",
-            "CompressedBlockAckTimeout",
-            "Sifs",
-            "EifsNoDifs",
-            "Slot",
-            "Pifs",
-            "MaxPropagationDelay",
-            "Ssid"],
     }),
      "ns3::JakesPropagationLossModel": dict({
         "category": FC.CATEGORY_LOSS_MODELS,