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
nix-vector-helper.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 The Georgia Institute of Technology
3
* Copyright (c) 2021 NITK Surathkal
4
*
5
* SPDX-License-Identifier: GPL-2.0-only
6
*
7
* This file is adapted from the old ipv4-nix-vector-helper.cc.
8
*
9
* Authors: Josh Pelkey <jpelkey@gatech.edu>
10
*
11
* Modified by: Ameya Deshpande <ameyanrd@outlook.com>
12
*/
13
14
#include "
nix-vector-helper.h
"
15
16
#include "ns3/assert.h"
17
#include "ns3/nix-vector-routing.h"
18
19
namespace
ns3
20
{
21
22
template
<
typename
T>
23
NixVectorHelper<T>::NixVectorHelper
()
24
{
25
std::string name;
26
if
constexpr
(IsIpv4)
27
{
28
name =
"Ipv4"
;
29
}
30
else
31
{
32
name =
"Ipv6"
;
33
}
34
35
m_agentFactory.SetTypeId(
"ns3::"
+ name +
"NixVectorRouting"
);
36
}
37
38
template
<
typename
T>
39
NixVectorHelper<T>::NixVectorHelper
(
const
NixVectorHelper<T>
& o)
40
: m_agentFactory(o.m_agentFactory)
41
{
42
// Check if the T is Ipv4RoutingHelper or Ipv6RoutingHelper.
43
static_assert
((std::is_same_v<Ipv4RoutingHelper, T> || std::is_same_v<Ipv6RoutingHelper, T>),
44
"Template parameter is not Ipv4RoutingHelper or Ipv6Routing Helper"
);
45
}
46
47
template
<
typename
T>
48
NixVectorHelper<T>
*
49
NixVectorHelper<T>::Copy
()
const
50
{
51
return
new
NixVectorHelper<T>
(*
this
);
52
}
53
54
template
<
typename
T>
55
Ptr<typename NixVectorHelper<T>::IpRoutingProtocol
>
56
NixVectorHelper<T>::Create
(
Ptr<Node>
node)
const
57
{
58
Ptr<NixVectorRouting<IpRoutingProtocol>
> agent =
59
m_agentFactory.Create<
NixVectorRouting<IpRoutingProtocol>
>();
60
agent->SetNode(node);
61
node->AggregateObject(agent);
62
return
agent;
63
}
64
65
template
<
typename
T>
66
void
67
NixVectorHelper<T>::PrintRoutingPathAt
(
Time
printTime,
68
Ptr<Node>
source,
69
IpAddress
dest,
70
Ptr<OutputStreamWrapper>
stream,
71
Time::Unit
unit)
72
{
73
Simulator::Schedule
(printTime, &
NixVectorHelper<T>::PrintRoute
, source, dest, stream, unit);
74
}
75
76
template
<
typename
T>
77
void
78
NixVectorHelper<T>::PrintRoute
(
Ptr<Node>
source,
79
IpAddress
dest,
80
Ptr<OutputStreamWrapper>
stream,
81
Time::Unit
unit)
82
{
83
Ptr<NixVectorRouting<IpRoutingProtocol>
> rp =
84
T::template GetRouting<NixVectorRouting<IpRoutingProtocol>>(
85
source->GetObject<
Ip
>()->GetRoutingProtocol());
86
NS_ASSERT
(rp);
87
rp->PrintRoutingPath(source, dest, stream, unit);
88
}
89
90
template
class
NixVectorHelper<Ipv4RoutingHelper>
;
91
template
class
NixVectorHelper<Ipv6RoutingHelper>
;
92
93
}
// namespace ns3
ns3::NixVectorHelper
Helper class that adds Nix-vector routing to nodes.
Definition
nix-vector-helper.h:42
ns3::NixVectorHelper::PrintRoute
static void PrintRoute(Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing path for the source and destination.
Definition
nix-vector-helper.cc:78
ns3::NixVectorHelper::Copy
NixVectorHelper< T > * Copy() const override
Definition
nix-vector-helper.cc:49
ns3::NixVectorHelper::Ip
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
Definition
nix-vector-helper.h:46
ns3::NixVectorHelper::PrintRoutingPathAt
void PrintRoutingPathAt(Time printTime, Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing path for a source and destination at a particular time.
Definition
nix-vector-helper.cc:67
ns3::NixVectorHelper::NixVectorHelper
NixVectorHelper()
Construct an NixVectorHelper to make life easier while adding Nix-vector routing to nodes.
Definition
nix-vector-helper.cc:23
ns3::NixVectorHelper::Create
Ptr< IpRoutingProtocol > Create(Ptr< Node > node) const override
Definition
nix-vector-helper.cc:56
ns3::NixVectorHelper::IpAddress
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
Definition
nix-vector-helper.h:48
ns3::NixVectorRouting
Nix-vector routing protocol.
Definition
nix-vector-routing.h:61
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
ns3::Simulator::Schedule
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition
simulator.h:560
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::Time::Unit
Unit
The unit to use to interpret a number representing time.
Definition
nstime.h:100
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
nix-vector-helper.h
src
nix-vector-routing
helper
nix-vector-helper.cc
Generated on Fri Nov 8 2024 13:59:05 for ns-3 by
1.11.0