A Discrete-Event Network Simulator
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
35namespace ns3
36{
37
38NS_LOG_COMPONENT_DEFINE("DsrHelper");
39
41{
42 NS_LOG_FUNCTION(this);
43 m_agentFactory.SetTypeId("ns3::dsr::DsrRouting");
44}
45
47 : m_agentFactory(o.m_agentFactory)
48{
49 NS_LOG_FUNCTION(this);
50}
51
56
59{
60 NS_LOG_FUNCTION(this);
61 return new DsrHelper(*this);
62}
63
66{
67 NS_LOG_FUNCTION(this);
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
81void
82DsrHelper::Set(std::string name, const AttributeValue& value)
83{
84 m_agentFactory.Set(name, value);
85}
86
87} // namespace ns3
Hold a value for an Attribute.
Definition attribute.h:59
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
ObjectFactory m_agentFactory
DSR factory.
Definition dsr-helper.h:80
DsrHelper * Copy() const
Definition dsr-helper.cc:58
Ptr< ns3::dsr::DsrRouting > Create(Ptr< Node > node) const
Definition dsr-helper.cc:65
DsrHelper()
Create an DsrHelper that makes life easier for people who want to install Dsr routing to nodes.
Definition dsr-helper.cc:40
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
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.
Smart pointer class similar to boost::intrusive_ptr.
TCP socket creation and multiplexing/demultiplexing.
Implementation of the UDP protocol.
Dsr Routing base.
Definition dsr-routing.h:87
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:191
#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:684