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