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
ipv4-route.cc
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 University of Washington
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
*/
7
8
#include "
ipv4-route.h
"
9
10
#include "ns3/assert.h"
11
#include "ns3/log.h"
12
#include "ns3/net-device.h"
13
14
namespace
ns3
15
{
16
17
NS_LOG_COMPONENT_DEFINE
(
"Ipv4Route"
);
18
19
Ipv4Route::Ipv4Route
()
20
{
21
NS_LOG_FUNCTION
(
this
);
22
}
23
24
void
25
Ipv4Route::SetDestination
(
Ipv4Address
dest)
26
{
27
NS_LOG_FUNCTION
(
this
<< dest);
28
m_dest
= dest;
29
}
30
31
Ipv4Address
32
Ipv4Route::GetDestination
()
const
33
{
34
NS_LOG_FUNCTION
(
this
);
35
return
m_dest
;
36
}
37
38
void
39
Ipv4Route::SetSource
(
Ipv4Address
src)
40
{
41
NS_LOG_FUNCTION
(
this
<< src);
42
m_source
= src;
43
}
44
45
Ipv4Address
46
Ipv4Route::GetSource
()
const
47
{
48
NS_LOG_FUNCTION
(
this
);
49
return
m_source
;
50
}
51
52
void
53
Ipv4Route::SetGateway
(
Ipv4Address
gw)
54
{
55
NS_LOG_FUNCTION
(
this
<< gw);
56
m_gateway
= gw;
57
}
58
59
Ipv4Address
60
Ipv4Route::GetGateway
()
const
61
{
62
NS_LOG_FUNCTION
(
this
);
63
return
m_gateway
;
64
}
65
66
void
67
Ipv4Route::SetOutputDevice
(
Ptr<NetDevice>
outputDevice)
68
{
69
NS_LOG_FUNCTION
(
this
<< outputDevice);
70
m_outputDevice
= outputDevice;
71
}
72
73
Ptr<NetDevice>
74
Ipv4Route::GetOutputDevice
()
const
75
{
76
NS_LOG_FUNCTION
(
this
);
77
return
m_outputDevice
;
78
}
79
80
std::ostream&
81
operator<<
(std::ostream& os,
const
Ipv4Route
& route)
82
{
83
os <<
"source="
<< route.
GetSource
() <<
" dest="
<< route.
GetDestination
()
84
<<
" gw="
<< route.
GetGateway
();
85
return
os;
86
}
87
88
Ipv4MulticastRoute::Ipv4MulticastRoute
()
89
{
90
NS_LOG_FUNCTION
(
this
);
91
m_ttls
.clear();
92
}
93
94
void
95
Ipv4MulticastRoute::SetGroup
(
const
Ipv4Address
group)
96
{
97
NS_LOG_FUNCTION
(
this
<< group);
98
m_group
= group;
99
}
100
101
Ipv4Address
102
Ipv4MulticastRoute::GetGroup
()
const
103
{
104
NS_LOG_FUNCTION
(
this
);
105
return
m_group
;
106
}
107
108
void
109
Ipv4MulticastRoute::SetOrigin
(
const
Ipv4Address
origin)
110
{
111
NS_LOG_FUNCTION
(
this
<< origin);
112
m_origin
= origin;
113
}
114
115
Ipv4Address
116
Ipv4MulticastRoute::GetOrigin
()
const
117
{
118
NS_LOG_FUNCTION
(
this
);
119
return
m_origin
;
120
}
121
122
void
123
Ipv4MulticastRoute::SetParent
(
uint32_t
parent)
124
{
125
NS_LOG_FUNCTION
(
this
<< parent);
126
m_parent
= parent;
127
}
128
129
uint32_t
130
Ipv4MulticastRoute::GetParent
()
const
131
{
132
NS_LOG_FUNCTION
(
this
);
133
return
m_parent
;
134
}
135
136
void
137
Ipv4MulticastRoute::SetOutputTtl
(
uint32_t
oif,
uint32_t
ttl)
138
{
139
NS_LOG_FUNCTION
(
this
<< oif << ttl);
140
if
(ttl >=
MAX_TTL
)
141
{
142
// This TTL value effectively disables the interface
143
auto
iter =
m_ttls
.find(oif);
144
if
(iter !=
m_ttls
.end())
145
{
146
m_ttls
.erase(iter);
147
}
148
}
149
else
150
{
151
m_ttls
[oif] = ttl;
152
}
153
}
154
155
std::map<uint32_t, uint32_t>
156
Ipv4MulticastRoute::GetOutputTtlMap
()
const
157
{
158
NS_LOG_FUNCTION
(
this
);
159
return
m_ttls
;
160
}
161
162
}
// namespace ns3
ns3::Ipv4Address
Ipv4 addresses are stored in host order in this class.
Definition
ipv4-address.h:31
ns3::Ipv4MulticastRoute::GetParent
uint32_t GetParent() const
Definition
ipv4-route.cc:130
ns3::Ipv4MulticastRoute::m_group
Ipv4Address m_group
Group.
Definition
ipv4-route.h:151
ns3::Ipv4MulticastRoute::GetGroup
Ipv4Address GetGroup() const
Definition
ipv4-route.cc:102
ns3::Ipv4MulticastRoute::GetOutputTtlMap
std::map< uint32_t, uint32_t > GetOutputTtlMap() const
Definition
ipv4-route.cc:156
ns3::Ipv4MulticastRoute::GetOrigin
Ipv4Address GetOrigin() const
Definition
ipv4-route.cc:116
ns3::Ipv4MulticastRoute::SetOrigin
void SetOrigin(const Ipv4Address origin)
Definition
ipv4-route.cc:109
ns3::Ipv4MulticastRoute::m_origin
Ipv4Address m_origin
Source of packet.
Definition
ipv4-route.h:152
ns3::Ipv4MulticastRoute::SetOutputTtl
void SetOutputTtl(uint32_t oif, uint32_t ttl)
Definition
ipv4-route.cc:137
ns3::Ipv4MulticastRoute::SetGroup
void SetGroup(const Ipv4Address group)
Definition
ipv4-route.cc:95
ns3::Ipv4MulticastRoute::m_parent
uint32_t m_parent
Source interface.
Definition
ipv4-route.h:153
ns3::Ipv4MulticastRoute::MAX_TTL
static const uint32_t MAX_TTL
Maximum time-to-live (TTL)
Definition
ipv4-route.h:148
ns3::Ipv4MulticastRoute::m_ttls
std::map< uint32_t, uint32_t > m_ttls
Time to Live container.
Definition
ipv4-route.h:154
ns3::Ipv4MulticastRoute::Ipv4MulticastRoute
Ipv4MulticastRoute()
Definition
ipv4-route.cc:88
ns3::Ipv4MulticastRoute::SetParent
void SetParent(uint32_t iif)
Definition
ipv4-route.cc:123
ns3::Ipv4Route
IPv4 route cache entry (similar to Linux struct rtable)
Definition
ipv4-route.h:31
ns3::Ipv4Route::m_source
Ipv4Address m_source
Source address.
Definition
ipv4-route.h:81
ns3::Ipv4Route::SetGateway
void SetGateway(Ipv4Address gw)
Definition
ipv4-route.cc:53
ns3::Ipv4Route::GetOutputDevice
Ptr< NetDevice > GetOutputDevice() const
Definition
ipv4-route.cc:74
ns3::Ipv4Route::GetGateway
Ipv4Address GetGateway() const
Definition
ipv4-route.cc:60
ns3::Ipv4Route::SetDestination
void SetDestination(Ipv4Address dest)
Definition
ipv4-route.cc:25
ns3::Ipv4Route::SetSource
void SetSource(Ipv4Address src)
Definition
ipv4-route.cc:39
ns3::Ipv4Route::GetSource
Ipv4Address GetSource() const
Definition
ipv4-route.cc:46
ns3::Ipv4Route::m_gateway
Ipv4Address m_gateway
Gateway address.
Definition
ipv4-route.h:82
ns3::Ipv4Route::SetOutputDevice
void SetOutputDevice(Ptr< NetDevice > outputDevice)
Equivalent in Linux to dst_entry.dev.
Definition
ipv4-route.cc:67
ns3::Ipv4Route::GetDestination
Ipv4Address GetDestination() const
Definition
ipv4-route.cc:32
ns3::Ipv4Route::m_outputDevice
Ptr< NetDevice > m_outputDevice
Output device.
Definition
ipv4-route.h:83
ns3::Ipv4Route::Ipv4Route
Ipv4Route()
Definition
ipv4-route.cc:19
ns3::Ipv4Route::m_dest
Ipv4Address m_dest
Destination address.
Definition
ipv4-route.h:80
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition
mpi-test-fixtures.h:37
uint32_t
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
ipv4-route.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::operator<<
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition
angles.cc:148
src
internet
model
ipv4-route.cc
Generated on Fri Nov 8 2024 13:59:01 for ns-3 by
1.11.0