2 # -*- coding: utf-8 -*-
4 from constants import TESTBED_ID
5 from nepi.core import metadata
6 from nepi.core.attributes import Attribute
7 from nepi.util import validation
9 ### Connection functions ####
11 def connect_node_device(testbed_instance, node_guid, device_guid):
12 node = testbed_instance._elements[node_guid]
13 device = testbed_instance._elements[device_guid]
14 node.AddDevice(device)
16 def connect_queue_device(testbed_instance, queue_guid, device_guid):
17 queue = testbed_instance._elements[queue_guid]
18 device = testbed_instance._elements[device_guid]
19 device.SetQueue(queue)
21 def connect_manager_device(testbed_instance, manager_guid, device_guid):
22 manager = testbed_instance._elements[manager_guid]
23 device = testbed_instance._elements[device_guid]
24 device.SetRemoteStationManager(manager)
26 def connect_phy_device(testbed_instance, phy_guid, device_guid):
27 phy = testbed_instance._elements[phy_guid]
28 device = testbed_instance._elements[device_guid]
31 # search for the node asociated with the device
32 node_guid = testbed_instance.get_connected(guid, "node", "devs")
33 if len(node_guid) == 0:
34 raise RuntimeError("Can't instantiate interface %d outside netns \
36 node = testbed_instance.elements[node_guid[0]]
39 def connect_mac_device(testbed_instance, mac_guid, device_guid):
40 mac = testbed_instance._elements[mac_guid]
41 device = testbed_instance._elements[device_guid]
44 def connect_errormodel_device(testbed_instance, model_guid, device_guid):
45 model = testbed_instance._elements[model_guid]
46 device = testbed_instance._elements[device_guid]
47 device.SetReceiveErrorModel(model)
49 def connect_errormodel_phy(testbed_instance, err_guid, phy_guid):
50 err = testbed_instance._elements[err_guid]
51 phy = testbed_instance._elements[phy_guid]
52 phy.SetErrorRateModel(err)
54 def connect_channel_device(testbed_instance, channel_guid, device_guid):
55 channel = testbed_instance._elements[channel_guid]
56 device = testbed_instance._elements[device_guid]
57 device.Attach(channel)
59 def connect_simple_channel_device(testbed_instance, channel_guid, device_guid):
60 channel = testbed_instance._elements[channel_guid]
61 device = testbed_instance._elements[device_guid]
62 device.SetChannel(channel)
64 def connect_loss_channel(testbed_instance, loss, channel):
65 loss = testbed_instance._elements[loss_guid]
66 channel = testbed_instance._elements[channel_guid]
67 channel.SetPropagationLossModel(loss)
69 def connect_next_loss(testbed_instance, prev_guid, next_guid):
70 prev = testbed_instance._elements[prev_guid]
71 next = testbed_instance._elements[next_guid]
74 def connect_delay_channel(testbed_instance, delay_guid, channel_guid):
75 delay = testbed_instance._elements[delay_guid]
76 channel = testbed_instance._elements[channel_guid]
77 channel.SetPropagationDelayModel(delay)
79 def connect_node_application(testbed_instance, node_guid, application_guid):
80 node = testbed_instance._elements[node_guid]
81 application = testbed_instance._elements[application_guid]
82 node.AddApplication(application)
83 # works for ArpL3Protocol, Ipv4L3Protocol, UdpL4Protocol, TcpL4Protocol,
84 # NscTcpL4Protocol, MobilityModel (every subclass),
85 # RoutingProtocol (every subclass)
87 def connect_node_other(testbed_instance, node_guid, other_guid):
88 node = testbed_instance._elements[node_guid]
89 other = testbed_instance._elements[other_guid]
90 node.AggregateObject(other)
92 def connect_fd(testbed_instance, fdnd_guid, cross_data):
93 fdnd = testbed_instance._elements[fdnd_guid]
94 address = fdnd.socket_address
95 fdnd.set_attribute_value("LinuxSocketAddress", address)
97 ### Connector information ###
99 connector_types = dict({
101 "help": "Connector to a ns3::Node object (mandatory)",
107 "help": "Connector to network interfaces",
113 "help": "Connector to exactly two network interfaces (mandatory)",
119 "help": "Connector to exactly one network interface (mandatory)",
125 "help": "Connector to applications",
131 "help": "Connector to network stacks and protocols",
137 "help": "Connector to a channel for the device (mandatory)",
143 "help": "Connector to a queueing discipline (mandatory)",
149 "help": "Connector to an error model for the device",
155 "help": "Connector to interconnect devices with file descriptors",
161 "help": "Connector to interconnect elements with a PHY wifi model",
167 "help": "Connector to interconnect a wifi channel with PHY wifi models",
173 "help": "Connector to interconnect a device with a MAC wifi model",
179 "help": "Connector to interconnect a wifi device with a wifi manager",
185 "help": "Connector to a delay model",
191 "help": "Connector to a loss model",
197 "help": "Connector to the previous loss model",
203 "help": "Connector to the next loss model",
209 "help": "Connector to a mobility model for the node",
218 "from": ( "ns3", "ns3::Node", "devs" ),
219 "to": ( "ns3", "ns3::BridgeNetDevice", "node" ),
220 "init_code": connect_node_device,
224 "from": ( "ns3", "ns3::Node", "devs" ),
225 "to": ( "ns3", "ns3::CsmaNetDevice", "node" ),
226 "init_code": connect_node_device,
230 "from": ( "ns3", "ns3::Node", "devs" ),
231 "to": ( "ns3", "ns3::EmuNetDevice", "node" ),
232 "init_code": connect_node_device,
236 "from": ( "ns3", "ns3::Node", "devs" ),
237 "to": ( "ns3", "ns3::PointToPointNetDevice", "node" ),
238 "init_code": connect_node_device,
242 "from": ( "ns3", "ns3::Node", "devs" ),
243 "to": ( "ns3", "ns3::SimpleNetDevice", "node" ),
244 "init_code": connect_node_device,
248 "from": ( "ns3", "ns3::Node", "devs" ),
249 "to": ( "ns3", "ns3::FileDescriptorNetDevice", "node" ),
250 "init_code": connect_node_device,
254 "from": ( "ns3", "ns3::Node", "devs" ),
255 "to": ( "ns3", "ns3::WifiNetDevice", "node" ),
256 "init_code": connect_node_device,
260 "from": ( "ns3", "ns3::DropTailQueue", "dev" ),
261 "to": ( "ns3", "ns3::CsmaNetDevice", "queue" ),
262 "init_code": connect_queue_device,
266 "from": ( "ns3", "ns3::DropTailQueue", "dev" ),
267 "to": ( "ns3", "ns3::EmuNetDevice", "queue" ),
268 "init_code": connect_queue_device,
272 "from": ( "ns3", "ns3::DropTailQueue", "dev" ),
273 "to": ( "ns3", "ns3::PointToPointNetDevice", "queue" ),
274 "init_code": connect_queue_device,
278 "from": ( "ns3", "ns3::ArfWifiManager", "dev" ),
279 "to": ( "ns3", "ns3::WifiNetDevice", "manager" ),
280 "init_code": connect_manager_device,
284 "from": ( "ns3", "ns3::ConstantRateWifiManager", "dev" ),
285 "to": ( "ns3", "ns3::WifiNetDevice", "manager" ),
286 "init_code": connect_manager_device,
290 "from": ( "ns3", "ns3::YansWifiPhy", "dev" ),
291 "to": ( "ns3", "ns3::WifiNetDevice", "phy" ),
292 "init_code": connect_phy_device,
296 "from": ( "ns3", "ns3::QapWifiMac", "dev" ),
297 "to": ( "ns3", "ns3::WifiNetDevice", "mac" ),
298 "init_code": connect_mac_device,
302 "from": ( "ns3", "ns3::QstaWifiMac", "dev" ),
303 "to": ( "ns3", "ns3::WifiNetDevice", "mac" ),
304 "init_code": connect_mac_device,
308 "from": ( "ns3", "ns3::RateErrorModel", "dev" ),
309 "to": ( "ns3", "ns3::CsmaNetDevice", "err" ),
310 "init_code": connect_errormodel_device,
314 "from": ( "ns3", "ns3::RateErrorModel", "dev" ),
315 "to": ( "ns3", "ns3::PointToPointNetDevice", "err" ),
316 "init_code": connect_errormodel_device,
320 "from": ( "ns3", "ns3::ListErrorModel", "dev" ),
321 "to": ( "ns3", "ns3::CsmaNetDevice", "err" ),
322 "init_code": connect_errormodel_device,
326 "from": ( "ns3", "ns3::ListErrorModel", "dev" ),
327 "to": ( "ns3", "ns3::PointToPointNetDevice", "err" ),
328 "init_code": connect_errormodel_device,
332 "from": ( "ns3", "ns3::NistErrorRateModel", "phy" ),
333 "to": ( "ns3", "ns3::YansWifiPhy", "err" ),
334 "init_code": connect_errormodel_phy,
338 "from": ( "ns3", "ns3::CsmaChannel", "devs" ),
339 "to": ( "ns3", "ns3::CsmaNetDevice", "chan" ),
340 "init_code": connect_channel_device,
344 "from": ( "ns3", "ns3::PointToPointChannel", "dev2" ),
345 "to": ( "ns3", "ns3::PointToPointNetDevice", "chan" ),
346 "init_code": connect_channel_device,
350 "from": ( "ns3", "ns3::SimpleChannel", "devs" ),
351 "to": ( "ns3", "ns3::SimpleNetDevice", "chan" ),
352 "init_code": connect_simple_channel_device,
356 "from": ( "ns3", "ns3::YansWifiChannel", "phys" ),
357 "to": ( "ns3", "ns3::YansWifiPhy", "chan" ),
358 "init_code": connect_simple_channel_device,
362 "from": ( "ns3", "ns3::LogDistancePropagationLossModel", "prev" ),
363 "to": ( "ns3", "ns3::YansWifiChannel", "loss" ),
364 "init_code": connect_loss_channel,
368 "from": ( "ns3", "ns3::LogDistancePropagationLossModel", "prev" ),
369 "to": ( "ns3", "ns3::LogDistancePropagationLossModel", "next" ),
370 "init_code": connect_next_loss,
374 "from": ( "ns3", "ns3::ConstantSpeedPropagationDelayModel", "chan" ),
375 "to": ( "ns3", "ns3::YansWifiChannel", "delay" ),
376 "init_code": connect_delay_channel,
380 "from": ( "ns3", "ns3::Node", "apps" ),
381 "to": ( "ns3", "ns3::OnOffApplication", "node" ),
382 "init_code": connect_node_application,
386 "from": ( "ns3", "ns3::Node", "apps" ),
387 "to": ( "ns3", "ns3::PacketSink", "node" ),
388 "init_code": connect_node_application,
392 "from": ( "ns3", "ns3::Node", "apps" ),
393 "to": ( "ns3", "ns3::UdpEchoClient", "node" ),
394 "init_code": connect_node_application,
398 "from": ( "ns3", "ns3::Node", "apps" ),
399 "to": ( "ns3", "ns3::UdpEchoServer", "node" ),
400 "init_code": connect_node_application,
404 "from": ( "ns3", "ns3::Node", "apps" ),
405 "to": ( "ns3", "ns3::V4Ping", "node" ),
406 "init_code": connect_node_application,
410 "from": ( "ns3", "ns3::Node", "protos" ),
411 "to": ( "ns3", "ns3::ArpL3Protocol", "node" ),
412 "init_code": connect_node_other,
416 "from": ( "ns3", "ns3::Node", "protos" ),
417 "to": ( "ns3", "ns3::Icmpv4L4Protocol", "node" ),
418 "init_code": connect_node_other,
422 "from": ( "ns3", "ns3::Node", "protos" ),
423 "to": ( "ns3", "ns3::Ipv4L3Protocol", "node" ),
424 "init_code": connect_node_other,
428 "from": ( "ns3", "ns3::Node", "protos" ),
429 "to": ( "ns3", "ns3::UdpL4Protocol", "node" ),
430 "init_code": connect_node_other,
434 "from": ( "ns3", "ns3::Node", "protos" ),
435 "to": ( "ns3", "ns3::TcpL4Protocol", "node" ),
436 "init_code": connect_node_other,
440 "from": ( "ns3", "ns3::Node", "mobility" ),
441 "to": ( "ns3", "ns3::ConstantAccelerationMobilityModel", "node" ),
442 "init_code": connect_node_other,
446 "from": ( "ns3", "ns3::Node", "mobility" ),
447 "to": ( "ns3", "ns3::ConstantPositionMobilityModel", "node" ),
448 "init_code": connect_node_other,
452 "from": ( "ns3", "ns3::Node", "mobility" ),
453 "to": ( "ns3", "ns3::ConstantVelocityMobilityModel", "node" ),
454 "init_code": connect_node_other,
458 "from": ( "ns3", "ns3::Node", "mobility" ),
459 "to": ( "ns3", "ns3::HierarchicalMobilityModel", "node" ),
460 "init_code": connect_node_other,
464 "from": ( "ns3", "ns3::Node", "mobility" ),
465 "to": ( "ns3", "ns3::RandomDirection2dMobilityModel", "node" ),
466 "init_code": connect_node_other,
470 "from": ( "ns3", "ns3::Node", "mobility" ),
471 "to": ( "ns3", "ns3::RandomWalk2dMobilityModel", "node" ),
472 "init_code": connect_node_other,
476 "from": ( "ns3", "ns3::Node", "mobility" ),
477 "to": ( "ns3", "ns3::RandomWaypointMobilityModel", "node" ),
478 "init_code": connect_node_other,
482 "from": ( "ns3", "ns3::FileDescriptorNetDevice", "fd" ),
483 "to": ( "netns", "TapNodeInterface", "fd" ),
484 "init_code": connect_fd,
491 "name": "P2PPcapTrace",
492 "help": "Trace to sniff packets from a P2P network device"
495 "name": "P2PAsciiTrace",
496 "help": "Ascii trace from a P2P network device"
498 "csmapcap_promisc": dict({
499 "name": "CsmaPromiscPcapTrace",
500 "help": "Trace to sniff packets from a Csma network device in promiscuous mode"
503 "name": "CsmaPcapTrace",
504 "help": "Trace to sniff packets from a Csma network device"
507 "name": "FileDescriptorPcapTrace",
508 "help": "Trace to sniff packets from a FileDescriptor network device"
510 "yanswifipcap": dict({
511 "name": "YansWifiPhyPcapTrace",
512 "help": "Trace to sniff packets from a Wifi network device"
516 factories_order = ["ns3::BasicEnergySource",
517 "ns3::WifiRadioEnergyModel",
518 "ns3::BSSchedulerRtps",
519 "ns3::BSSchedulerSimple",
520 "ns3::SubscriberStationNetDevice",
521 "ns3::BaseStationNetDevice",
522 "ns3::UdpTraceClient",
528 "ns3::flame::FlameProtocol",
529 "ns3::flame::FlameRtable",
530 "ns3::dot11s::AirtimeLinkMetricCalculator",
531 "ns3::dot11s::HwmpProtocol",
532 "ns3::dot11s::HwmpRtable",
533 "ns3::dot11s::PeerManagementProtocol",
534 "ns3::dot11s::PeerLink",
535 "ns3::MeshWifiInterfaceMac",
536 "ns3::MeshPointDevice",
539 "ns3::UanPhyCalcSinrDual",
540 "ns3::UanPhyPerGenDefault",
542 "ns3::UanPropModelThorp",
544 "ns3::UanNoiseModelDefault",
546 "ns3::UanPropModelIdeal",
547 "ns3::UanTransducerHd",
548 "ns3::UanPhyCalcSinrDefault",
550 "ns3::UanPhyCalcSinrFhFsk",
551 "ns3::UanPhyPerUmodem",
554 "ns3::AthstatsWifiTraceSink",
557 "ns3::NonCommunicatingNetDevice",
558 "ns3::HalfDuplexIdealPhy",
559 "ns3::AlohaNoackNetDevice",
560 "ns3::SpectrumAnalyzer",
561 "ns3::WaveformGenerator",
562 "ns3::MultiModelSpectrumChannel",
563 "ns3::SingleModelSpectrumChannel",
564 "ns3::MsduStandardAggregator",
568 "ns3::QadhocWifiMac",
569 "ns3::MinstrelWifiManager",
570 "ns3::CaraWifiManager",
571 "ns3::AarfcdWifiManager",
572 "ns3::OnoeWifiManager",
573 "ns3::AmrrWifiManager",
574 "ns3::ConstantRateWifiManager",
575 "ns3::IdealWifiManager",
576 "ns3::AarfWifiManager",
577 "ns3::ArfWifiManager",
578 "ns3::WifiNetDevice",
584 "ns3::YansWifiChannel",
586 "ns3::NistErrorRateModel",
587 "ns3::YansErrorRateModel",
588 "ns3::WaypointMobilityModel",
589 "ns3::ConstantAccelerationMobilityModel",
590 "ns3::RandomDirection2dMobilityModel",
591 "ns3::RandomWalk2dMobilityModel",
592 "ns3::SteadyStateRandomWaypointMobilityModel",
593 "ns3::RandomWaypointMobilityModel",
594 "ns3::GaussMarkovMobilityModel",
595 "ns3::ConstantVelocityMobilityModel",
596 "ns3::ConstantPositionMobilityModel",
597 "ns3::ListPositionAllocator",
598 "ns3::GridPositionAllocator",
599 "ns3::RandomRectanglePositionAllocator",
600 "ns3::RandomBoxPositionAllocator",
601 "ns3::RandomDiscPositionAllocator",
602 "ns3::UniformDiscPositionAllocator",
603 "ns3::HierarchicalMobilityModel",
604 "ns3::aodv::RoutingProtocol",
605 "ns3::UdpEchoServer",
606 "ns3::UdpEchoClient",
608 "ns3::OnOffApplication",
609 "ns3::VirtualNetDevice",
610 "ns3::FileDescriptorNetDevice",
612 "ns3::BridgeChannel",
613 "ns3::BridgeNetDevice",
616 "ns3::CsmaNetDevice",
617 "ns3::PointToPointRemoteChannel",
618 "ns3::PointToPointChannel",
619 "ns3::PointToPointNetDevice",
620 "ns3::NscTcpL4Protocol",
621 "ns3::Icmpv6L4Protocol",
622 "ns3::Ipv6OptionPad1",
623 "ns3::Ipv6OptionPadn",
624 "ns3::Ipv6OptionJumbogram",
625 "ns3::Ipv6OptionRouterAlert",
626 "ns3::Ipv6ExtensionHopByHop",
627 "ns3::Ipv6ExtensionDestination",
628 "ns3::Ipv6ExtensionFragment",
629 "ns3::Ipv6ExtensionRouting",
630 "ns3::Ipv6ExtensionLooseRouting",
631 "ns3::Ipv6ExtensionESP",
632 "ns3::Ipv6ExtensionAH",
633 "ns3::Ipv6L3Protocol",
634 "ns3::LoopbackNetDevice",
635 "ns3::Icmpv4L4Protocol",
636 "ns3::RttMeanDeviation",
637 "ns3::ArpL3Protocol",
638 "ns3::TcpL4Protocol",
639 "ns3::UdpL4Protocol",
640 "ns3::Ipv4L3Protocol",
641 "ns3::SimpleNetDevice",
642 "ns3::SimpleChannel",
644 "ns3::DropTailQueue",
646 "ns3::FriisSpectrumPropagationLossModel",
647 "ns3::Cost231PropagationLossModel",
648 "ns3::JakesPropagationLossModel",
649 "ns3::RandomPropagationLossModel",
650 "ns3::FriisPropagationLossModel",
651 "ns3::TwoRayGroundPropagationLossModel",
652 "ns3::LogDistancePropagationLossModel",
653 "ns3::ThreeLogDistancePropagationLossModel",
654 "ns3::NakagamiPropagationLossModel",
655 "ns3::FixedRssLossModel",
656 "ns3::MatrixPropagationLossModel",
657 "ns3::RangePropagationLossModel",
658 "ns3::RandomPropagationDelayModel",
659 "ns3::ConstantSpeedPropagationDelayModel",
660 "ns3::RateErrorModel",
661 "ns3::ListErrorModel",
662 "ns3::ReceiveListErrorModel",
664 "ns3::EnergySourceContainer"
667 testbed_attributes = dict({
668 "simu_impl_type": dict({
669 "name": "SimulatorImplementationType",
670 "help": "The object class to use as the simulator implementation",
671 "type": Attribute.STRING,
672 "flags": Attribute.DesignOnly,
673 "validation_function": validation.is_string
676 "name": "ChecksumEnabled",
677 "help": "A global switch to enable all checksums for all protocols",
678 "type": Attribute.BOOL,
680 "flags": Attribute.DesignOnly,
681 "validation_function": validation.is_bool
685 class VersionedMetadataInfo(metadata.VersionedMetadataInfo):
687 def connector_types(self):
688 return connector_types
691 def connections(self):
695 def attributes(self):
696 from attributes_metadata_v3_9_RC3 import attributes
704 def create_order(self):
705 return factories_order
708 def configure_order(self):
709 return factories_order
712 def factories_info(self):
713 from factories_metadata_v3_9_RC3 import factories_info
714 return factories_info
717 def testbed_attributes(self):
718 return testbed_attributes