A Discrete-Event Network Simulator
API
dsr-helper.cc
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2011 Yufei Cheng
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation;
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  *
17  * Author: Yufei Cheng <yfcheng@ittc.ku.edu>
18  *
19  * James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
20  * ResiliNets Research Group https://resilinets.org/
21  * Information and Telecommunication Technology Center (ITTC)
22  * and Department of Electrical Engineering and Computer Science
23  * The University of Kansas Lawrence, KS USA.
24  *
25  * Work supported in part by NSF FIND (Future Internet Design) Program
26  * under grant CNS-0626918 (Postmodern Internet Architecture),
27  * NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
28  * US Department of Defense (DoD), and ITTC at The University of Kansas.
29  */
30 
31 #include "dsr-helper.h"
32 
33 #include "ns3/callback.h"
34 #include "ns3/dsr-options.h"
35 #include "ns3/dsr-routing.h"
36 #include "ns3/ipv4-route.h"
37 #include "ns3/log.h"
38 #include "ns3/names.h"
39 #include "ns3/node-container.h"
40 #include "ns3/node-list.h"
41 #include "ns3/node.h"
42 #include "ns3/ptr.h"
43 #include "ns3/tcp-l4-protocol.h"
44 #include "ns3/udp-l4-protocol.h"
45 
46 namespace ns3
47 {
48 
49 NS_LOG_COMPONENT_DEFINE("DsrHelper");
50 
52 {
53  NS_LOG_FUNCTION(this);
54  m_agentFactory.SetTypeId("ns3::dsr::DsrRouting");
55 }
56 
58  : m_agentFactory(o.m_agentFactory)
59 {
60  NS_LOG_FUNCTION(this);
61 }
62 
64 {
65  NS_LOG_FUNCTION(this);
66 }
67 
68 DsrHelper*
70 {
71  NS_LOG_FUNCTION(this);
72  return new DsrHelper(*this);
73 }
74 
77 {
78  NS_LOG_FUNCTION(this);
80  // deal with the downtargets, install UdpL4Protocol, TcpL4Protocol, Icmpv4L4Protocol
82  agent->SetDownTarget(udp->GetDownTarget());
83  udp->SetDownTarget(MakeCallback(&dsr::DsrRouting::Send, agent));
85  tcp->SetDownTarget(MakeCallback(&dsr::DsrRouting::Send, agent));
87  icmp->SetDownTarget(MakeCallback(&dsr::DsrRouting::Send, agent));
88  node->AggregateObject(agent);
89  return agent;
90 }
91 
92 void
93 DsrHelper::Set(std::string name, const AttributeValue& value)
94 {
95  m_agentFactory.Set(name, value);
96 }
97 
98 } // namespace ns3
Hold a value for an Attribute.
Definition: attribute.h:70
DSR helper class to manage creation of DSR routing instance and to insert it on a node as a sublayer ...
Definition: dsr-helper.h:53
ObjectFactory m_agentFactory
DSR factory.
Definition: dsr-helper.h:91
DsrHelper * Copy() const
Definition: dsr-helper.cc:69
Ptr< ns3::dsr::DsrRouting > Create(Ptr< Node > node) const
Definition: dsr-helper.cc:76
DsrHelper()
Create an DsrHelper that makes life easier for people who want to install Dsr routing to nodes.
Definition: dsr-helper.cc:51
void Set(std::string name, const AttributeValue &value)
Set attribute values for future instances of DSR that this helper creates.
Definition: dsr-helper.cc:93
This is the implementation of the ICMP protocol as described in RFC 792.
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.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
void AggregateObject(Ptr< Object > other)
Aggregate two Objects together.
Definition: object.cc:259
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
TCP socket creation and multiplexing/demultiplexing.
Implementation of the UDP protocol.
Dsr Routing base.
Definition: dsr-routing.h:98
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.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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:704