A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
dsr-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2011 Yufei Cheng
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Yufei Cheng <yfcheng@ittc.ku.edu>
7
*
8
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
9
* ResiliNets Research Group https://resilinets.org/
10
* Information and Telecommunication Technology Center (ITTC)
11
* and Department of Electrical Engineering and Computer Science
12
* The University of Kansas Lawrence, KS USA.
13
*
14
* Work supported in part by NSF FIND (Future Internet Design) Program
15
* under grant CNS-0626918 (Postmodern Internet Architecture),
16
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
17
* US Department of Defense (DoD), and ITTC at The University of Kansas.
18
*/
19
20
#include "
dsr-helper.h
"
21
22
#include "ns3/callback.h"
23
#include "ns3/dsr-options.h"
24
#include "ns3/dsr-routing.h"
25
#include "ns3/ipv4-route.h"
26
#include "ns3/log.h"
27
#include "ns3/names.h"
28
#include "ns3/node-container.h"
29
#include "ns3/node-list.h"
30
#include "ns3/node.h"
31
#include "ns3/ptr.h"
32
#include "ns3/tcp-l4-protocol.h"
33
#include "ns3/udp-l4-protocol.h"
34
35
namespace
ns3
36
{
37
38
NS_LOG_COMPONENT_DEFINE
(
"DsrHelper"
);
39
40
DsrHelper::DsrHelper
()
41
{
42
NS_LOG_FUNCTION
(
this
);
43
m_agentFactory
.SetTypeId(
"ns3::dsr::DsrRouting"
);
44
}
45
46
DsrHelper::DsrHelper
(
const
DsrHelper
& o)
47
:
m_agentFactory
(o.
m_agentFactory
)
48
{
49
NS_LOG_FUNCTION
(
this
);
50
}
51
52
DsrHelper::~DsrHelper
()
53
{
54
NS_LOG_FUNCTION
(
this
);
55
}
56
57
DsrHelper
*
58
DsrHelper::Copy
()
const
59
{
60
NS_LOG_FUNCTION
(
this
);
61
return
new
DsrHelper
(*
this
);
62
}
63
64
Ptr<ns3::dsr::DsrRouting>
65
DsrHelper::Create
(
Ptr<Node>
node)
const
66
{
67
NS_LOG_FUNCTION
(
this
);
68
Ptr<ns3::dsr::DsrRouting>
agent =
m_agentFactory
.Create<
ns3::dsr::DsrRouting
>();
69
// deal with the downtargets, install UdpL4Protocol, TcpL4Protocol, Icmpv4L4Protocol
70
Ptr<UdpL4Protocol>
udp = node->GetObject<
UdpL4Protocol
>();
71
agent->SetDownTarget(udp->GetDownTarget());
72
udp->SetDownTarget(
MakeCallback
(&
dsr::DsrRouting::Send
, agent));
73
Ptr<TcpL4Protocol>
tcp = node->GetObject<
TcpL4Protocol
>();
74
tcp->SetDownTarget(
MakeCallback
(&
dsr::DsrRouting::Send
, agent));
75
Ptr<Icmpv4L4Protocol>
icmp = node->GetObject<
Icmpv4L4Protocol
>();
76
icmp->SetDownTarget(
MakeCallback
(&
dsr::DsrRouting::Send
, agent));
77
node->AggregateObject(agent);
78
return
agent;
79
}
80
81
void
82
DsrHelper::Set
(std::string name,
const
AttributeValue
& value)
83
{
84
m_agentFactory
.Set(name, value);
85
}
86
87
}
// namespace ns3
ns3::AttributeValue
Hold a value for an Attribute.
Definition
attribute.h:59
ns3::DsrHelper
DSR helper class to manage creation of DSR routing instance and to insert it on a node as a sublayer ...
Definition
dsr-helper.h:42
ns3::DsrHelper::m_agentFactory
ObjectFactory m_agentFactory
DSR factory.
Definition
dsr-helper.h:80
ns3::DsrHelper::~DsrHelper
~DsrHelper()
Definition
dsr-helper.cc:52
ns3::DsrHelper::Copy
DsrHelper * Copy() const
Definition
dsr-helper.cc:58
ns3::DsrHelper::Create
Ptr< ns3::dsr::DsrRouting > Create(Ptr< Node > node) const
Definition
dsr-helper.cc:65
ns3::DsrHelper::DsrHelper
DsrHelper()
Create an DsrHelper that makes life easier for people who want to install Dsr routing to nodes.
Definition
dsr-helper.cc:40
ns3::DsrHelper::Set
void Set(std::string name, const AttributeValue &value)
Set attribute values for future instances of DSR that this helper creates.
Definition
dsr-helper.cc:82
ns3::Icmpv4L4Protocol
This is the implementation of the ICMP protocol as described in RFC 792.
Definition
icmpv4-l4-protocol.h:36
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
ptr.h:66
ns3::TcpL4Protocol
TCP socket creation and multiplexing/demultiplexing.
Definition
tcp-l4-protocol.h:70
ns3::UdpL4Protocol
Implementation of the UDP protocol.
Definition
udp-l4-protocol.h:53
ns3::dsr::DsrRouting
Dsr Routing base.
Definition
dsr-routing.h:97
ns3::dsr::DsrRouting::Send
void Send(Ptr< Packet > packet, Ipv4Address source, Ipv4Address destination, uint8_t protocol, Ptr< Ipv4Route > route)
This function is called by higher layer protocol when sending packets.
Definition
dsr-routing.cc:1511
dsr-helper.h
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition
log-macros-enabled.h:229
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::MakeCallback
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition
callback.h:684
src
dsr
helper
dsr-helper.cc
Generated on Wed Jun 11 2025 13:15:28 for ns-3 by
1.13.2