本文整理汇总了C++中NodeContainer类的典型用法代码示例。如果您正苦于以下问题:C++ NodeContainer类的具体用法?C++ NodeContainer怎么用?C++ NodeContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoInstall
EnergySourceContainer
EnergySourceHelper::Install (NodeContainer c) const
{
EnergySourceContainer container;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
Ptr<EnergySource> src = DoInstall (*i);
container.Add (src);
/*
* Check if EnergySourceContainer is already aggregated to target node. If
* not, create a new EnergySourceContainer and aggregate it to node.
*/
Ptr<EnergySourceContainer> EnergySourceContrainerOnNode =
(*i)->GetObject<EnergySourceContainer> ();
if (EnergySourceContrainerOnNode == NULL)
{
ObjectFactory fac;
fac.SetTypeId ("ns3::EnergySourceContainer");
EnergySourceContrainerOnNode = fac.Create<EnergySourceContainer> ();
EnergySourceContrainerOnNode->Add (src);
(*i)->AggregateObject (EnergySourceContrainerOnNode);
}
else
{
EnergySourceContrainerOnNode->Add (src); // append new EnergySource
}
}
return container;
}
示例2: return
bool
Ns3WimaxSimpleOFDMTestCase::DoRunOnce (double FrameDuration)
{
WimaxHelper::SchedulerType scheduler = WimaxHelper::SCHED_TYPE_SIMPLE;
NodeContainer ssNodes;
NodeContainer bsNodes;
ssNodes.Create (3);
bsNodes.Create (1);
WimaxHelper wimax;
NetDeviceContainer ssDevs, bsDevs;
ssDevs = wimax.Install (ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler, FrameDuration);
bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION,
WimaxHelper::SIMPLE_PHY_TYPE_OFDM, scheduler, FrameDuration);
Simulator::Stop (Seconds (1));
Simulator::Run ();
for (int i = 0; i < 3; i++)
{
if (ssDevs.Get (i)->GetObject<SubscriberStationNetDevice> ()->IsRegistered ()
== false)
{
NS_LOG_DEBUG ("SS[" << i << "] not registered");
return true; // Test fail because SS[i] is not registered
}
}
Simulator::Destroy ();
return (false); // Test was ok, all the SSs are registered
}
示例3: writeContainer
void Writer::writeContainer(const NodeContainer& container)
{
XML::NodeContainer::const_iterator it = container.beginChild();
XML::NodeContainer::const_iterator end = container.endChild();
for (; it != end; ++it)
{
if ((*it)->type() == ELEMENT_NODE)
{
XML::ElementNodePtr child = Core::dynamic_ptr_cast<XML::ElementNode>(*it);
writeElement(child);
}
else if ((*it)->type() == TEXT_NODE)
{
XML::TextNodePtr child = Core::dynamic_ptr_cast<XML::TextNode>(*it);
m_buffer += child->text();
}
else
{
ASSERT_FALSE();
}
}
}
示例4: Install
void
StrategyChoiceHelper::Install(const NodeContainer& c, const Name& namePrefix, const Name& strategy)
{
for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
Install(*i, namePrefix, strategy);
}
}
示例5: Update
void
StackHelper::Update(const NodeContainer& c)
{
for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
Update(*i);
}
}
示例6: main
int
main (int argc, char *argv[])
{
NodeContainer nodes;
nodes.Create (2);
PointToPointHelper pointToPoint;
NetDeviceContainer devices;
devices = pointToPoint.Install (nodes);
InternetStackHelper stack;
stack.Install (nodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.252");
Ipv4InterfaceContainer interfaces = address.Assign (devices);
uint16_t sinkPort = 8080;
Address sinkAddress (InetSocketAddress (interfaces.GetAddress (1), sinkPort));
Ptr<PacketSink> receiverApplication = CreateObject<PacketSink> ();
receiverApplication->SetAttribute ("Local", AddressValue (InetSocketAddress (Ipv4Address::GetAny(), 8080)));
receiverApplication->SetAttribute ("Protocol", TypeIdValue(TcpSocketFactory::GetTypeId()));
receiverApplication->TraceConnectWithoutContext ("Rx", MakeCallback (&CountRx));
nodes.Get(1)->AddApplication(receiverApplication);
Ptr<MyApp> app = CreateObject<MyApp> (nodes.Get (0), sinkAddress);
nodes.Get (0)->AddApplication (app);
Simulator::Stop ();
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
示例7: main
int main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
NodeContainer c;
c.Create (10000);
MobilityHelper mobility;
mobility.SetPositionAllocator ("ns3::RandomDiscPositionAllocator",
"X", StringValue ("100.0"),
"Y", StringValue ("100.0"),
"Rho", StringValue ("ns3::UniformRandomVariable[Min=0|Max=30]"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (c);
Config::Connect ("/NodeList/*/$ns3::MobilityModel/CourseChange",
MakeCallback (&CourseChange));
Simulator::Stop (Seconds (100.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
示例8: main
int
main(int argc, char* argv[])
{
// Setting default parameters for PointToPoint links and channels
Config::SetDefault("ns3::PointToPointNetDevice::DataRate", StringValue("1Mbps"));
Config::SetDefault("ns3::PointToPointChannel::Delay", StringValue("10ms"));
Config::SetDefault("ns3::QueueBase::MaxPackets", UintegerValue(10));
// Read optional command-line parameters (e.g., enable visualizer with ./waf --run=<> --visualize
CommandLine cmd;
cmd.Parse(argc, argv);
// Creating 3x3 topology
PointToPointHelper p2p;
PointToPointGridHelper grid(3, 3, p2p);
grid.BoundingBox(100, 100, 200, 200);
// Install NDN stack on all nodes
ndn::StackHelper ndnHelper;
ndnHelper.InstallAll();
// Set BestRoute strategy
ndn::StrategyChoiceHelper::InstallAll("/", "/localhost/nfd/strategy/best-route");
// Installing global routing interface on all nodes
ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
ndnGlobalRoutingHelper.InstallAll();
// Getting containers for the consumer/producer
Ptr<Node> producer = grid.GetNode(2, 2);
NodeContainer consumerNodes;
consumerNodes.Add(grid.GetNode(0, 0));
// Install NDN applications
std::string prefix = "/prefix";
ndn::AppHelper consumerHelper("ns3::ndn::ConsumerCbr");
consumerHelper.SetPrefix(prefix);
consumerHelper.SetAttribute("Frequency", StringValue("100")); // 100 interests a second
consumerHelper.Install(consumerNodes);
ndn::AppHelper producerHelper("ns3::ndn::Producer");
producerHelper.SetPrefix(prefix);
producerHelper.SetAttribute("PayloadSize", StringValue("1024"));
producerHelper.Install(producer);
// Add /prefix origins to ndn::GlobalRouter
ndnGlobalRoutingHelper.AddOrigins(prefix, producer);
// Calculate and install FIBs
ndn::GlobalRoutingHelper::CalculateRoutes();
Simulator::Stop(Seconds(20.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
示例9: main
int
main (int argc, char *argv[])
{
CommandLine cmd;
cmd.Parse (argc, argv);
//
// We are interacting with the outside, real, world. This means we have to
// interact in real-time and therefore means we have to use the real-time
// simulator and take the time to calculate checksums.
//
GlobalValue::Bind ("SimulatorImplementationType", StringValue ("ns3::RealtimeSimulatorImpl"));
GlobalValue::Bind ("ChecksumEnabled", BooleanValue (true));
//
// Create two ghost nodes. The first will represent the virtual machine host
// on the left side of the network; and the second will represent the VM on
// the right side.
//
NodeContainer nodes;
nodes.Create (2);
//
// Use a CsmaHelper to get a CSMA channel created, and the needed net
// devices installed on both of the nodes. The data rate and delay for the
// channel can be set through the command-line parser. For example,
//
// ./waf --run "tap=csma-virtual-machine --ns3::CsmaChannel::DataRate=10000000"
//
CsmaHelper csma;
NetDeviceContainer devices = csma.Install (nodes);
//
// Use the TapBridgeHelper to connect to the pre-configured tap devices for
// the left side. We go with "UseBridge" mode since the CSMA devices support
// promiscuous mode and can therefore make it appear that the bridge is
// extended into ns-3. The install method essentially bridges the specified
// tap to the specified CSMA device.
//
TapBridgeHelper tapBridge;
tapBridge.SetAttribute ("Mode", StringValue ("UseBridge"));
tapBridge.SetAttribute ("DeviceName", StringValue ("tap-left"));
tapBridge.Install (nodes.Get (0), devices.Get (0));
//
// Connect the right side tap to the right side CSMA device on the right-side
// ghost node.
//
tapBridge.SetAttribute ("DeviceName", StringValue ("tap-right"));
tapBridge.Install (nodes.Get (1), devices.Get (1));
//
// Run the simulation for ten minutes to give the user time to play around
//
Simulator::Stop (Seconds (600.));
Simulator::Run ();
Simulator::Destroy ();
}
示例10: onoff
//
// Network topology
//
// n0 n1 n2 n3
// | | | |
// =====================
//
// - Packet socket flow from n0 to n1 and from node n3 to n0
// -- We will test reception at node n0
// - Default 512 byte packets generated by traffic generator
//
void
CsmaPacketSocketTestCase::DoRun (void)
{
// Here, we will explicitly create four nodes.
NodeContainer nodes;
nodes.Create (4);
PacketSocketHelper packetSocket;
packetSocket.Install (nodes);
// create the shared medium used by all csma devices.
Ptr<CsmaChannel> channel = CreateObjectWithAttributes<CsmaChannel> (
"DataRate", DataRateValue (DataRate (5000000)),
"Delay", TimeValue (MilliSeconds (2)));
// use a helper function to connect our nodes to the shared channel.
CsmaHelper csma;
csma.SetDeviceAttribute ("EncapsulationMode", StringValue ("Llc"));
NetDeviceContainer devs = csma.Install (nodes, channel);
// Create the OnOff application to send raw datagrams
//
// Make packets be sent about every DefaultPacketSize / DataRate =
// 4096 bits / (5000 bits/second) = 0.82 second.
PacketSocketAddress socket;
socket.SetSingleDevice (devs.Get (0)->GetIfIndex ());
socket.SetPhysicalAddress (devs.Get (1)->GetAddress ());
socket.SetProtocol (2);
OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
onoff.SetConstantRate (DataRate (5000));
ApplicationContainer apps = onoff.Install (nodes.Get (0));
apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));
socket.SetSingleDevice (devs.Get (3)->GetIfIndex ());
socket.SetPhysicalAddress (devs.Get (0)->GetAddress ());
socket.SetProtocol (3);
onoff.SetAttribute ("Remote", AddressValue (socket));
apps = onoff.Install (nodes.Get (3));
apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));
PacketSinkHelper sink = PacketSinkHelper ("ns3::PacketSocketFactory",
socket);
apps = sink.Install (nodes.Get (0));
apps.Start (Seconds (0.0));
apps.Stop (Seconds (20.0));
// Trace receptions
Config::Connect ("/NodeList/0/ApplicationList/*/$ns3::PacketSink/Rx",
MakeCallback (&CsmaPacketSocketTestCase::SinkRx, this));
Simulator::Run ();
Simulator::Destroy ();
// We should have received 10 packets on node 0
NS_TEST_ASSERT_MSG_EQ (m_count, 10, "Node 0 should have received 10 packets");
}
示例11:
Ptr<FaceContainer>
StackHelper::Install(const NodeContainer& c) const
{
Ptr<FaceContainer> faces = Create<FaceContainer>();
for (NodeContainer::Iterator i = c.Begin(); i != c.End(); ++i) {
faces->AddAll(Install(*i));
}
return faces;
}
示例12: buildNonboundaryEdgeList
void EdgeContainer::buildNonboundaryEdgeList()
{
NodeContainer pContainer = m_triangleContainer.getPointContainer();
m_edgeToTriangleIndecesMap.clear();
m_edgeList.clear();
// Loop over all triangles and build a unique list of non-boundary edges.
for (unsigned indexOuter = 0; indexOuter < m_triangleContainer.size() ; ++ indexOuter)
{
const Triangle& tOuter = m_triangleContainer.at(indexOuter);
for (unsigned indexInner = indexOuter + 1; indexInner < m_triangleContainer.size() ; ++ indexInner)
{
if ( m_triangleContainer.hasCommonNode(indexInner, indexOuter) )
{
const Triangle& tInner = m_triangleContainer.at(indexInner);
// Find common nodes
std::vector<NodeContainer::SizeType> edgePointList;
for (unsigned ii = 0; ii < 3; ++ii)
{
for (unsigned jj = 0; jj < 3; ++jj)
{
if (tOuter.at(ii) == tInner.at(jj))
{
edgePointList.push_back(pContainer.find(tOuter.at(ii)));
}
}
}
assert(edgePointList.size() < 3); // Three matching nodes = coincident triangle
if (edgePointList.size() == 2)
{
// Found a common edge
Edge e;
std::sort(edgePointList.begin(), edgePointList.end());
e.set(pContainer.at(edgePointList.at(0)), pContainer.at(edgePointList.at(1)));
// Add items in sorted order (smallest to largest - basis function direction)
if (indexOuter < indexInner)
{
e.setSortedAssociatedTriangles({indexOuter, indexInner});
m_edgeToTriangleIndecesMap.push_back({indexOuter, indexInner});
}
else
{
e.setSortedAssociatedTriangles({indexInner, indexOuter});
m_edgeToTriangleIndecesMap.push_back({indexInner, indexOuter});
}
m_edgeList.push_back(e);
}
}
}
}
buildTriangleToEdgeMap();
}
示例13:
ApplicationContainer
BulkSendHelper::Install (NodeContainer c) const
{
ApplicationContainer apps;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
apps.Add (InstallPriv (*i));
}
return apps;
}
示例14: NS_LOG_DEBUG
void
DsrMainHelper::Install (DsrHelper &dsrHelper, NodeContainer nodes)
{
NS_LOG_DEBUG ("Passed node container");
delete m_dsrHelper;
m_dsrHelper = dsrHelper.Copy ();
for (NodeContainer::Iterator i = nodes.Begin (); i != nodes.End (); ++i)
{
Install (*i);
}
}
示例15: Install
Ptr<FlowMonitor>
FlowMonitorHelper::Install (NodeContainer nodes)
{
for (NodeContainer::Iterator i = nodes.Begin (); i != nodes.End (); ++i)
{
Ptr<Node> node = *i;
if (node->GetObject<Ipv4L3Protocol> ())
{
Install (node);
}
}
return m_flowMonitor;
}