A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
aodv-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 IITP RAS
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Authors: Pavel Boyko <boyko@iitp.ru>, written after OlsrHelper by Mathieu Lacage
7 * <mathieu.lacage@sophia.inria.fr>
8 */
9#include "aodv-helper.h"
10
11#include "ns3/aodv-routing-protocol.h"
12#include "ns3/ipv4-list-routing.h"
13#include "ns3/names.h"
14#include "ns3/node-list.h"
15#include "ns3/ptr.h"
16
17namespace ns3
18{
19
22{
23 m_agentFactory.SetTypeId("ns3::aodv::RoutingProtocol");
24}
25
28{
29 return new AodvHelper(*this);
30}
31
34{
36 node->AggregateObject(agent);
37 return agent;
38}
39
40void
41AodvHelper::Set(std::string name, const AttributeValue& value)
42{
43 m_agentFactory.Set(name, value);
44}
45
46int64_t
48{
49 int64_t currentStream = stream;
50 Ptr<Node> node;
51 for (auto i = c.Begin(); i != c.End(); ++i)
52 {
53 node = (*i);
54 Ptr<Ipv4> ipv4 = node->GetObject<Ipv4>();
55 NS_ASSERT_MSG(ipv4, "Ipv4 not installed on node");
56 Ptr<Ipv4RoutingProtocol> proto = ipv4->GetRoutingProtocol();
57 NS_ASSERT_MSG(proto, "Ipv4 routing not installed on node");
59 if (aodv)
60 {
61 currentStream += aodv->AssignStreams(currentStream);
62 continue;
63 }
64 // Aodv may also be in a list
66 if (list)
67 {
68 int16_t priority;
71 for (uint32_t i = 0; i < list->GetNRoutingProtocols(); i++)
72 {
73 listProto = list->GetRoutingProtocol(i, priority);
74 listAodv = DynamicCast<aodv::RoutingProtocol>(listProto);
75 if (listAodv)
76 {
77 currentStream += listAodv->AssignStreams(currentStream);
78 break;
79 }
80 }
81 }
82 }
83 return (currentStream - stream);
84}
85
86} // namespace ns3
Helper class that adds AODV routing to nodes.
Definition aodv-helper.h:25
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
AodvHelper * Copy() const override
void Set(std::string name, const AttributeValue &value)
ObjectFactory m_agentFactory
the factory to create AODV routing object
Definition aodv-helper.h:69
Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const override
Hold a value for an Attribute.
Definition attribute.h:59
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition ipv4.h:69
a factory to create ns3::Ipv4RoutingProtocol objects
keep track of a set of node pointers.
Iterator End() const
Get an iterator which indicates past-the-last Node in the container.
Iterator Begin() const
Get an iterator which refers to the first Node in the container.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition assert.h:75
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580