-#!/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({
"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)
element = testbed_instance._elements[guid]
filename = "trace-fd-node-%d-dev-%d.pcap" % (node_guid, interface_number)
filepath = _follow_trace(testbed_instance, guid, trace_id, filename)
- helper = testbed_instance.ns3.FileDescriptorHelper()
+ helper = testbed_instance.ns3.FdNetDeviceHelper()
helper.EnablePcap(filepath, element, explicitFilename = True)
+def fdascii_trace(testbed_instance, guid, trace_id):
+ node_guid = _get_node_guid(testbed_instance, guid)
+ interface_number = _get_dev_number(testbed_instance, guid)
+ element = testbed_instance._elements[guid]
+ filename = "trace-fd-node-%d-dev-%d.tr" % (node_guid, interface_number)
+ filepath = _follow_trace(testbed_instance, guid, trace_id, filename)
+ helper = testbed_instance.ns3.FdNetDeviceHelper()
+ asciiHelper = testbed_instance.ns3.AsciiTraceHelper()
+ stream = asciiHelper.CreateFileStream(filepath)
+ helper.EnableAscii(stream, element)
+
def yanswifipcap_trace(testbed_instance, guid, trace_id):
dev_guid = testbed_instance.get_connected(guid, "dev", "phy")[0]
node_guid = _get_node_guid(testbed_instance, dev_guid)
"P2PAsciiTrace": p2pascii_trace,
"CsmaPcapTrace": csmapcap_trace,
"CsmaPcapPromiscTrace": csmapcap_promisc_trace,
- "FileDescriptorPcapTrace": fdpcap_trace,
+ "FdPcapTrace": fdpcap_trace,
+ "FdAsciiTrace": fdascii_trace,
"YansWifiPhyPcapTrace": yanswifipcap_trace,
"WimaxPcapTrace": wimaxpcap_trace,
"WimaxAsciiTrace": wimaxascii_trace,
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)
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)
+ standard = parameters.get("Standard")
+ 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)
element = testbed_instance._elements[guid]
def configure_device(testbed_instance, guid):
configure_traces(testbed_instance, guid)
-
element = testbed_instance._elements[guid]
parameters = testbed_instance._get_parameters(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):
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",
"ns3::SingleModelSpectrumChannel",
"ns3::MsduStandardAggregator",
"ns3::EdcaTxopN",
- "ns3::QstaWifiMac",
- "ns3::QapWifiMac",
- "ns3::QadhocWifiMac",
+ "ns3::StaWifiMac",
+ "ns3::ApWifiMac",
"ns3::MinstrelWifiManager",
"ns3::CaraWifiManager",
"ns3::AarfcdWifiManager",
"ns3::AarfWifiManager",
"ns3::ArfWifiManager",
"ns3::WifiNetDevice",
- "ns3::NqstaWifiMac",
- "ns3::NqapWifiMac",
"ns3::AdhocWifiMac",
"ns3::DcaTxop",
"ns3::WifiMacQueue",
"ns3::PacketSink",
"ns3::OnOffApplication",
"ns3::VirtualNetDevice",
- "ns3::FileDescriptorNetDevice",
+ "ns3::FdNetDevice",
"ns3::Nepi::TunChannel",
"ns3::TapBridge",
"ns3::BridgeChannel",
"ns3::NakagamiPropagationLossModel",
"ns3::FixedRssLossModel",
"ns3::MatrixPropagationLossModel",
+ "ns3::Nepi::MobilityPair",
"ns3::RangePropagationLossModel",
"ns3::RandomPropagationDelayModel",
"ns3::ConstantSpeedPropagationDelayModel",
"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,
"configure_function": configure_node,
"help": "",
"connector_types": ["devs", "apps", "protos", "mobility"],
+ "box_attributes": ["Up"],
"tags": [tags.NODE, tags.ALLOW_ROUTES],
}),
"ns3::GridPositionAllocator": dict({
"create_function": create_element,
"configure_function": configure_element,
"help": "",
- "connector_types": ["node"],
+ "connector_types": ["node", "mp"],
"box_attributes": ["Position",
"Velocity"],
"tags": [tags.MOBILE],
}),
"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",
"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],
"WaypointList"],
"tags": [tags.MOBILE],
}),
- "ns3::FileDescriptorNetDevice": dict({
+ "ns3::FdNetDevice": dict({
"category": FC.CATEGORY_DEVICES,
"create_function": create_element,
"configure_function": configure_device,
"help": "Network interface associated to a file descriptor",
"connector_types": ["node", "->fd"],
"box_attributes": ["Address",
- "LinuxSocketAddress",
- "tun_proto", "tun_addr", "tun_port", "tun_key"],
- "traces": ["fdpcap"],
+ "tun_proto", "tun_addr", "tun_port", "tun_key", "tun_cipher_fdnd"],
+ "traces": ["fdpcap", "fdascii"],
"tags": [tags.INTERFACE, tags.ALLOW_ADDRESSES],
}),
"ns3::Nepi::TunChannel": dict({
"create_function": create_tunchannel,
"preconfigure_function": preconfigure_tunchannel,
"configure_function": postconfigure_tunchannel,
- "prestart_function": wait_tunchannel,
- "help": "Channel to forward FileDescriptorNetDevice data to "
+ "prestart_function": prestart_tunchannel,
+ "help": "Channel to forward FdNetDevice data to "
"other TAP interfaces supporting the NEPI tunneling protocol.",
"connector_types": ["fd->", "udp", "tcp"],
"allow_addresses": False,
- "box_attributes": ["tun_proto", "tun_addr", "tun_port", "tun_key"],
+ "box_attributes": ["tun_proto", "tun_addr", "tun_port", "tun_key","tun_cipher"],
"tags": [tags.TUNNEL],
}),
"help": "",
"connector_types": [],
"box_attributes": ["SpreadCoef"],
- }),
- "ns3::NqstaWifiMac": dict({
- "category": FC.CATEGORY_MAC_MODELS,
- "create_function": create_wifi_standard_model,
- "configure_function": configure_element,
- "help": "",
- "connector_types": ["dev"],
- "box_attributes": ["ProbeRequestTimeout",
- "AssocRequestTimeout",
- "MaxMissedBeacons",
- "CtsTimeout",
- "AckTimeout",
- "BasicBlockAckTimeout",
- "CompressedBlockAckTimeout",
- "Sifs",
- "EifsNoDifs",
- "Slot",
- "Pifs",
- "MaxPropagationDelay",
- "Ssid"],
}),
"ns3::Icmpv6L4Protocol": dict({
"category": FC.CATEGORY_PROTOCOLS,
"box_attributes": ["X",
"Y"],
"tags": [tags.MOBILE],
- }),
- "ns3::NqapWifiMac": dict({
- "category": FC.CATEGORY_MAC_MODELS,
- "create_function": create_wifi_standard_model,
- "configure_function": configure_element,
- "help": "",
- "connector_types": ["dev"],
- "box_attributes": ["BeaconInterval",
- "BeaconGeneration",
- "CtsTimeout",
- "AckTimeout",
- "BasicBlockAckTimeout",
- "CompressedBlockAckTimeout",
- "Sifs",
- "EifsNoDifs",
- "Slot",
- "Pifs",
- "MaxPropagationDelay",
- "Ssid"],
}),
"ns3::HierarchicalMobilityModel": dict({
"category": FC.CATEGORY_MOBILITY_MODELS,
"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,
"connector_types": [],
"box_attributes": ["ExtensionNumber"],
}),
- "ns3::QstaWifiMac": 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"],
"Pifs",
"MaxPropagationDelay",
"Ssid",
- "Standard"],
+ "Standard",
+ "QosSupported"],
}),
"ns3::UdpEchoClient": dict({
"category": FC.CATEGORY_APPLICATIONS,
"create_function": create_element,
"configure_function": configure_element,
"help": "",
- "connector_types": ["node"],
+ "connector_types": ["node", "mp"],
"box_attributes": ["Position",
"Velocity"],
"tags": [tags.MOBILE],
"connector_types": [],
"box_attributes": ["OptionNumber"],
}),
- "ns3::QapWifiMac": 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"],
"Pifs",
"MaxPropagationDelay",
"Ssid",
- "Standard"],
+ "Standard",
+ "QosSupported"],
}),
"ns3::YansErrorRateModel": dict({
"category": FC.CATEGORY_ERROR_MODELS,
}),
"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"],
"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,