A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
dsr-helper.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2011 Yufei Cheng
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation;
8
*
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
*
18
* Author: Yufei Cheng <yfcheng@ittc.ku.edu>
19
*
20
* James P.G. Sterbenz <jpgs@ittc.ku.edu>, director
21
* ResiliNets Research Group http://wiki.ittc.ku.edu/resilinets
22
* Information and Telecommunication Technology Center (ITTC)
23
* and Department of Electrical Engineering and Computer Science
24
* The University of Kansas Lawrence, KS USA.
25
*
26
* Work supported in part by NSF FIND (Future Internet Design) Program
27
* under grant CNS-0626918 (Postmodern Internet Architecture),
28
* NSF grant CNS-1050226 (Multilayer Network Resilience Analysis and Experimentation on GENI),
29
* US Department of Defense (DoD), and ITTC at The University of Kansas.
30
*/
31
32
#include "
dsr-helper.h
"
33
#include "ns3/node-container.h"
34
#include "ns3/node.h"
35
#include "ns3/callback.h"
36
#include "ns3/ptr.h"
37
#include "ns3/log.h"
38
#include "ns3/tcp-l4-protocol.h"
39
#include "ns3/udp-l4-protocol.h"
40
#include "ns3/dsr-options.h"
41
#include "ns3/dsr-routing.h"
42
#include "ns3/ipv4-route.h"
43
#include "ns3/node-list.h"
44
#include "ns3/names.h"
45
46
NS_LOG_COMPONENT_DEFINE
(
"DsrHelper"
);
47
48
namespace
ns3 {
49
50
DsrHelper::DsrHelper
()
51
{
52
NS_LOG_FUNCTION
(
this
);
53
m_agentFactory
.
SetTypeId
(
"ns3::dsr::DsrRouting"
);
54
}
55
56
DsrHelper::DsrHelper
(
const
DsrHelper
&o)
57
: m_agentFactory (o.m_agentFactory)
58
{
59
NS_LOG_FUNCTION
(
this
);
60
}
61
62
DsrHelper::~DsrHelper
()
63
{
64
NS_LOG_FUNCTION
(
this
);
65
}
66
67
DsrHelper
*
68
DsrHelper::Copy
(
void
)
const
69
{
70
NS_LOG_FUNCTION
(
this
);
71
return
new
DsrHelper
(*
this
);
72
}
73
74
Ptr<ns3::dsr::DsrRouting>
75
DsrHelper::Create
(
Ptr<Node>
node)
const
76
{
77
NS_LOG_FUNCTION
(
this
);
78
Ptr<ns3::dsr::DsrRouting>
agent =
m_agentFactory
.
Create
<
ns3::dsr::DsrRouting
> ();
79
// deal with the downtargets, install UdpL4Protocol, TcpL4Protocol, Icmpv4L4Protocol
80
Ptr<UdpL4Protocol>
udp = node->
GetObject
<
UdpL4Protocol
> ();
81
agent->
SetDownTarget
(udp->GetDownTarget ());
82
udp->SetDownTarget (
MakeCallback
(&
dsr::DsrRouting::Send
, agent));
83
Ptr<TcpL4Protocol>
tcp = node->
GetObject
<
TcpL4Protocol
> ();
84
tcp->SetDownTarget (
MakeCallback
(&
dsr::DsrRouting::Send
, agent));
85
Ptr<Icmpv4L4Protocol>
icmp = node->
GetObject
<
Icmpv4L4Protocol
> ();
86
icmp->SetDownTarget (
MakeCallback
(&
dsr::DsrRouting::Send
, agent));
87
node->
AggregateObject
(agent);
88
return
agent;
89
}
90
91
void
92
DsrHelper::Set
(std::string name,
const
AttributeValue
&value)
93
{
94
m_agentFactory
.
Set
(name, value);
95
}
96
97
}
// namespace ns3
ns3::dsr::DsrRouting::SetDownTarget
void SetDownTarget(IpL4Protocol::DownTargetCallback callback)
This method allows a caller to set the current down target callback set for this L4 protocol (IPv4 ca...
Definition:
dsr-routing.cc:3623
ns3::Ptr
smart pointer class similar to boost::intrusive_ptr
Definition:
ptr.h:59
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
Definition:
log.h:345
ns3::AttributeValue
Hold a value for an Attribute.
Definition:
attribute.h:56
ns3::ObjectFactory::SetTypeId
void SetTypeId(TypeId tid)
Definition:
object-factory.cc:41
ns3::DsrHelper::Set
void Set(std::string name, const AttributeValue &value)
Definition:
dsr-helper.cc:92
ns3::TcpL4Protocol
A layer between the sockets interface and IP.
Definition:
tcp-l4-protocol.h:56
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:50
ns3::DsrHelper::~DsrHelper
~DsrHelper()
Definition:
dsr-helper.cc:62
ns3::ObjectFactory::Create
Ptr< Object > Create(void) const
Definition:
object-factory.cc:90
ns3::MakeCallback
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Definition:
callback.h:1238
ns3::DsrHelper::Create
Ptr< ns3::dsr::DsrRouting > Create(Ptr< Node > node) const
Definition:
dsr-helper.cc:75
ns3::Object::AggregateObject
void AggregateObject(Ptr< Object > other)
Definition:
object.cc:243
dsr-helper.h
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:1538
ns3::DsrHelper::Copy
DsrHelper * Copy(void) const
Definition:
dsr-helper.cc:68
ns3::ObjectFactory::Set
void Set(std::string name, const AttributeValue &value)
Definition:
object-factory.cc:59
NS_LOG_COMPONENT_DEFINE
NS_LOG_COMPONENT_DEFINE("DsrHelper")
ns3::UdpL4Protocol
Implementation of the UDP protocol.
Definition:
udp-l4-protocol.h:48
ns3::DsrHelper
Definition:
dsr-helper.h:44
ns3::Icmpv4L4Protocol
Definition:
icmpv4-l4-protocol.h:14
ns3::DsrHelper::m_agentFactory
ObjectFactory m_agentFactory
Definition:
dsr-helper.h:79
ns3::Object::GetObject
Ptr< T > GetObject(void) const
Definition:
object.h:361
ns3::dsr::DsrRouting
Doxygen introspection did not find any typical Config paths.
Definition:
dsr-routing.h:95
src
dsr
helper
dsr-helper.cc
Generated on Sat Apr 19 2014 14:06:53 for ns-3 by
1.8.6