A Discrete-Event Network Simulator
API
radvd-interface.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 Strasbourg University
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: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
19  */
20 
21 #include "radvd-interface.h"
22 #include <ns3/log.h>
23 
24 namespace ns3
25 {
26 
27 NS_LOG_COMPONENT_DEFINE ("RadvdInterface");
28 
29 RadvdInterface::RadvdInterface (uint32_t interface)
30  : m_interface (interface)
31 {
32  NS_LOG_FUNCTION (this << interface);
33  /* initialize default value as specified in radvd.conf manpage */
34  m_sendAdvert = true;
35  m_maxRtrAdvInterval = 600000;
36  m_minRtrAdvInterval = (uint32_t)(double) (0.33 * m_maxRtrAdvInterval);
37  m_minDelayBetweenRAs = 3000;
38  m_managedFlag = false;
39  m_otherConfigFlag = false;
40  m_linkMtu = 0; /* 0 means not sending MTU option in RA */
41  m_reachableTime = 0; /* means unspecified for the router */
42  m_retransTimer = 0; /* means unspecified for the router */
43  m_curHopLimit = 64;
46  m_sourceLLAddress = true;
47  m_homeAgentFlag = false;
48  m_homeAgentInfo = false;
51  m_mobRtrSupportFlag = false;
52  m_intervalOpt = false;
54 }
55 
56 RadvdInterface::RadvdInterface (uint32_t interface, uint32_t maxRtrAdvInterval, uint32_t minRtrAdvInterval)
57  : m_interface (interface)
58 {
59  NS_LOG_FUNCTION (this << interface << maxRtrAdvInterval << minRtrAdvInterval);
60  NS_ASSERT (maxRtrAdvInterval > minRtrAdvInterval);
61  m_sendAdvert = true;
62  m_maxRtrAdvInterval = maxRtrAdvInterval;
63  m_minRtrAdvInterval = minRtrAdvInterval;
64  m_minDelayBetweenRAs = 3000;
65  m_managedFlag = false;
66  m_otherConfigFlag = false;
67  m_linkMtu = 0; /* 0 means not sending MTU option in RA */
68  m_reachableTime = 0; /* means unspecified for the router */
69  m_retransTimer = 0; /* means unspecified for the router */
70  m_curHopLimit = 64;
73  m_sourceLLAddress = true;
74  m_homeAgentFlag = false;
75  m_homeAgentInfo = false;
78  m_mobRtrSupportFlag = false;
79  m_intervalOpt = false;
81 }
82 
84 {
85  NS_LOG_FUNCTION (this);
86  /* clear prefixes */
87  for (RadvdPrefixListI it = m_prefixes.begin (); it != m_prefixes.end (); ++it)
88  {
89  (*it) = 0;
90  }
91  m_prefixes.clear ();
92 }
93 
95 {
96  NS_LOG_FUNCTION (this << routerPrefix);
97  m_prefixes.push_back (routerPrefix);
98 }
99 
100 
102 {
103  NS_LOG_FUNCTION (this);
104  return m_interface;
105 }
106 
107 std::list<Ptr<RadvdPrefix> > RadvdInterface::GetPrefixes () const
108 {
109  NS_LOG_FUNCTION (this);
110  return m_prefixes;
111 }
112 
114 {
115  NS_LOG_FUNCTION (this);
116  return m_sendAdvert;
117 }
118 
119 void RadvdInterface::SetSendAdvert (bool sendAdvert)
120 {
121  NS_LOG_FUNCTION (this << sendAdvert);
122  m_sendAdvert = sendAdvert;
123 }
124 
126 {
127  NS_LOG_FUNCTION (this);
128  return m_maxRtrAdvInterval;
129 }
130 
131 void RadvdInterface::SetMaxRtrAdvInterval (uint32_t maxRtrAdvInterval)
132 {
133  NS_LOG_FUNCTION (this << maxRtrAdvInterval);
134  m_maxRtrAdvInterval = maxRtrAdvInterval;
135 }
136 
138 {
139  NS_LOG_FUNCTION (this);
140  return m_minRtrAdvInterval;
141 }
142 
143 void RadvdInterface::SetMinRtrAdvInterval (uint32_t minRtrAdvInterval)
144 {
145  NS_LOG_FUNCTION (this << minRtrAdvInterval);
146  m_minRtrAdvInterval = minRtrAdvInterval;
147 }
148 
150 {
151  NS_LOG_FUNCTION (this);
152  return m_minDelayBetweenRAs;
153 }
154 
155 void RadvdInterface::SetMinDelayBetweenRAs (uint32_t minDelayBetweenRAs)
156 {
157  NS_LOG_FUNCTION (this << minDelayBetweenRAs);
158  m_minDelayBetweenRAs = minDelayBetweenRAs;
159 }
160 
162 {
163  NS_LOG_FUNCTION (this);
164  return m_managedFlag;
165 }
166 
167 void RadvdInterface::SetManagedFlag (bool managedFlag)
168 {
169  NS_LOG_FUNCTION (this << managedFlag);
170  m_managedFlag = managedFlag;
171 }
172 
174 {
175  NS_LOG_FUNCTION (this);
176  return m_otherConfigFlag;
177 }
178 
179 void RadvdInterface::SetOtherConfigFlag (bool otherConfigFlag)
180 {
181  NS_LOG_FUNCTION (this << otherConfigFlag);
182  m_otherConfigFlag = otherConfigFlag;
183 }
184 
185 uint32_t RadvdInterface::GetLinkMtu () const
186 {
187  NS_LOG_FUNCTION (this);
188  return m_linkMtu;
189 }
190 
191 void RadvdInterface::SetLinkMtu (uint32_t linkMtu)
192 {
193  NS_LOG_FUNCTION (this << linkMtu);
194  m_linkMtu = linkMtu;
195 }
196 
198 {
199  NS_LOG_FUNCTION (this);
200  return m_reachableTime;
201 }
202 
203 void RadvdInterface::SetReachableTime (uint32_t reachableTime)
204 {
205  NS_LOG_FUNCTION (this << reachableTime);
206  m_reachableTime = reachableTime;
207 }
208 
210 {
211  NS_LOG_FUNCTION (this);
212  return m_defaultLifeTime;
213 }
214 
215 void RadvdInterface::SetDefaultLifeTime (uint32_t defaultLifeTime)
216 {
217  NS_LOG_FUNCTION (this << defaultLifeTime);
218  m_defaultLifeTime = defaultLifeTime;
219 }
220 
222 {
223  NS_LOG_FUNCTION (this);
224  return m_retransTimer;
225 }
226 
227 void RadvdInterface::SetRetransTimer (uint32_t retransTimer)
228 {
229  NS_LOG_FUNCTION (this << retransTimer);
230  m_retransTimer = retransTimer;
231 }
232 
234 {
235  NS_LOG_FUNCTION (this);
236  return m_curHopLimit;
237 }
238 
239 void RadvdInterface::SetCurHopLimit (uint8_t curHopLimit)
240 {
241  NS_LOG_FUNCTION (this << curHopLimit);
242  m_curHopLimit = curHopLimit;
243 }
244 
246 {
247  NS_LOG_FUNCTION (this);
248  return m_defaultPreference;
249 }
250 
251 void RadvdInterface::SetDefaultPreference (uint8_t defaultPreference)
252 {
253  NS_LOG_FUNCTION (this << defaultPreference);
254  m_defaultPreference = defaultPreference;
255 }
256 
258 {
259  NS_LOG_FUNCTION (this);
260  return m_sourceLLAddress;
261 }
262 
263 void RadvdInterface::SetSourceLLAddress (bool sourceLLAddress)
264 {
265  NS_LOG_FUNCTION (this << sourceLLAddress);
266  m_sourceLLAddress = sourceLLAddress;
267 }
268 
270 {
271  NS_LOG_FUNCTION (this);
272  return m_homeAgentFlag;
273 }
274 
275 void RadvdInterface::SetHomeAgentFlag (bool homeAgentFlag)
276 {
277  NS_LOG_FUNCTION (this << homeAgentFlag);
278  m_homeAgentFlag = homeAgentFlag;
279 }
280 
282 {
283  NS_LOG_FUNCTION (this);
284  return m_homeAgentInfo;
285 }
286 
287 void RadvdInterface::SetHomeAgentInfo (bool homeAgentInfo)
288 {
289  NS_LOG_FUNCTION (this << homeAgentInfo);
290  m_homeAgentInfo = homeAgentInfo;
291 }
292 
294 {
295  NS_LOG_FUNCTION (this);
296  return m_homeAgentLifeTime;
297 }
298 
299 void RadvdInterface::SetHomeAgentLifeTime (uint32_t homeAgentLifeTime)
300 {
301  NS_LOG_FUNCTION (this << homeAgentLifeTime);
302  m_homeAgentLifeTime = homeAgentLifeTime;
303 }
304 
306 {
307  NS_LOG_FUNCTION (this);
308  return m_homeAgentPreference;
309 }
310 
311 void RadvdInterface::SetHomeAgentPreference (uint32_t homeAgentPreference)
312 {
313  NS_LOG_FUNCTION (this << homeAgentPreference);
314  m_homeAgentPreference = homeAgentPreference;
315 }
316 
318 {
319  NS_LOG_FUNCTION (this);
320  return m_mobRtrSupportFlag;
321 }
322 
323 void RadvdInterface::SetMobRtrSupportFlag (bool mobRtrSupportFlag)
324 {
325  NS_LOG_FUNCTION (this << mobRtrSupportFlag);
326  m_mobRtrSupportFlag = mobRtrSupportFlag;
327 }
328 
330 {
331  NS_LOG_FUNCTION (this);
332  return m_intervalOpt;
333 }
334 
335 void RadvdInterface::SetIntervalOpt (bool intervalOpt)
336 {
337  NS_LOG_FUNCTION (this << intervalOpt);
338  m_intervalOpt = intervalOpt;
339 }
340 
342 {
343  return m_lastSendTime;
344 }
345 
347 {
348  m_lastSendTime = now;
350  {
352  }
353 }
354 
356 {
358 }
359 
360 } /* namespace ns3 */
361 
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::RadvdInterface::GetMinDelayBetweenRAs
uint32_t GetMinDelayBetweenRAs() const
Get minimum delay between RAs.
Definition: radvd-interface.cc:149
ns3::RadvdInterface::SetMinRtrAdvInterval
void SetMinRtrAdvInterval(uint32_t minRtrAdvInterval)
Get minimum RA interval.
Definition: radvd-interface.cc:143
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:67
ns3::RadvdInterface::m_managedFlag
bool m_managedFlag
Managed flag.
Definition: radvd-interface.h:364
ns3::RadvdInterface::SetCurHopLimit
void SetCurHopLimit(uint8_t curHopLimit)
Set current hop limit.
Definition: radvd-interface.cc:239
ns3::RadvdInterface::SetHomeAgentFlag
void SetHomeAgentFlag(bool homeAgentFlag)
Set "home agent" flag.
Definition: radvd-interface.cc:275
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::RadvdInterface::GetDefaultPreference
uint8_t GetDefaultPreference() const
Get default preference.
Definition: radvd-interface.cc:245
ns3::RadvdInterface::RadvdPrefixListI
std::list< Ptr< RadvdPrefix > >::iterator RadvdPrefixListI
Container Iterator: Ptr to RadvdPrefix.
Definition: radvd-interface.h:42
ns3::RadvdInterface::m_homeAgentPreference
uint32_t m_homeAgentPreference
Home agent preference.
Definition: radvd-interface.h:428
ns3::RadvdInterface::m_prefixes
RadvdPrefixList m_prefixes
List of prefixes to advertise.
Definition: radvd-interface.h:339
ns3::RadvdInterface::m_minRtrAdvInterval
uint32_t m_minRtrAdvInterval
Minimum RA interval in milliseconds.
Definition: radvd-interface.h:354
ns3::RadvdInterface::SetIntervalOpt
void SetIntervalOpt(bool intervalOpt)
Set flag to add or not advertisement interval to RA.
Definition: radvd-interface.cc:335
ns3::RadvdInterface::SetLinkMtu
void SetLinkMtu(uint32_t linkMtu)
Set link MTU.
Definition: radvd-interface.cc:191
ns3::RadvdInterface::m_homeAgentInfo
bool m_homeAgentInfo
Flag to add Home Agent Information option (Mobile IPv6).
Definition: radvd-interface.h:418
ns3::RadvdInterface::SetMaxRtrAdvInterval
void SetMaxRtrAdvInterval(uint32_t maxRtrAdvInterval)
Get maximum RA interval.
Definition: radvd-interface.cc:131
ns3::RadvdInterface::SetHomeAgentLifeTime
void SetHomeAgentLifeTime(uint32_t homeAgentLifeTime)
Set home agent lifetime.
Definition: radvd-interface.cc:299
ns3::RadvdInterface::IsHomeAgentFlag
bool IsHomeAgentFlag() const
Is "home agent" flag enabled ?
Definition: radvd-interface.cc:269
ns3::RadvdInterface::GetLastRaTxTime
Time GetLastRaTxTime()
Get the last time a RA has been sent.
Definition: radvd-interface.cc:341
ns3::RadvdInterface::SetLastRaTxTime
void SetLastRaTxTime(Time now)
Set the last RA send time.
Definition: radvd-interface.cc:346
ns3::RadvdInterface::SetReachableTime
void SetReachableTime(uint32_t reachableTime)
Set reachable time.
Definition: radvd-interface.cc:203
ns3::RadvdInterface::IsMobRtrSupportFlag
bool IsMobRtrSupportFlag() const
Is "mobile router support" flag enabled ?
Definition: radvd-interface.cc:317
ns3::RadvdInterface::GetCurHopLimit
uint8_t GetCurHopLimit() const
Get current hop limit.
Definition: radvd-interface.cc:233
ns3::RadvdInterface::m_homeAgentFlag
bool m_homeAgentFlag
Flag to add HA (home agent) flag in RA.
Definition: radvd-interface.h:412
ns3::RadvdInterface::GetHomeAgentPreference
uint32_t GetHomeAgentPreference() const
Get home agent preference.
Definition: radvd-interface.cc:305
ns3::Ptr< RadvdPrefix >
ns3::RadvdInterface::GetDefaultLifeTime
uint32_t GetDefaultLifeTime() const
Get default lifetime.
Definition: radvd-interface.cc:209
ns3::RadvdInterface::GetInterface
uint32_t GetInterface() const
Get interface index for this configuration.
Definition: radvd-interface.cc:101
ns3::RadvdInterface::m_defaultLifeTime
uint32_t m_defaultLifeTime
Default life time in seconds.
Definition: radvd-interface.h:394
ns3::RadvdInterface::GetMinRtrAdvInterval
uint32_t GetMinRtrAdvInterval() const
Get minimum RA interval.
Definition: radvd-interface.cc:137
ns3::RadvdInterface::SetOtherConfigFlag
void SetOtherConfigFlag(bool otherConfigFlag)
Set "other config" flag.
Definition: radvd-interface.cc:179
ns3::RadvdInterface::m_minDelayBetweenRAs
uint32_t m_minDelayBetweenRAs
Minimum delay between RA in milliseconds.
Definition: radvd-interface.h:359
ns3::RadvdInterface::SetMinDelayBetweenRAs
void SetMinDelayBetweenRAs(uint32_t minDelayBetweenRAs)
Set minimum delay between RAs.
Definition: radvd-interface.cc:155
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::RadvdInterface::m_homeAgentLifeTime
uint32_t m_homeAgentLifeTime
Home agent lifetime in seconds.
Definition: radvd-interface.h:423
ns3::RadvdInterface::m_interface
uint32_t m_interface
Interface to advertise RA.
Definition: radvd-interface.h:334
ns3::RadvdInterface::m_reachableTime
uint32_t m_reachableTime
Reachable time in milliseconds.
Definition: radvd-interface.h:379
ns3::RadvdInterface::m_retransTimer
uint32_t m_retransTimer
Retransmission timer in milliseconds.
Definition: radvd-interface.h:384
ns3::RadvdInterface::m_maxRtrAdvInterval
uint32_t m_maxRtrAdvInterval
Maximum RA interval in milliseconds.
Definition: radvd-interface.h:349
ns3::RadvdInterface::GetHomeAgentLifeTime
uint32_t GetHomeAgentLifeTime() const
Get home agent lifetime.
Definition: radvd-interface.cc:293
ns3::RadvdInterface::GetReachableTime
uint32_t GetReachableTime() const
Get reachable time.
Definition: radvd-interface.cc:197
ns3::RadvdInterface::m_sendAdvert
bool m_sendAdvert
Flag whether or not router sends periodic RA and respond to RS.
Definition: radvd-interface.h:344
ns3::RadvdInterface::AddPrefix
void AddPrefix(Ptr< RadvdPrefix > routerPrefix)
Add a prefix to advertise on interface.
Definition: radvd-interface.cc:94
ns3::RadvdInterface::SetManagedFlag
void SetManagedFlag(bool managedFlag)
Set managed flag.
Definition: radvd-interface.cc:167
ns3::RadvdInterface::GetPrefixes
RadvdPrefixList GetPrefixes() const
Get list of prefixes advertised for this interface.
Definition: radvd-interface.cc:107
ns3::RadvdInterface::SetSendAdvert
void SetSendAdvert(bool sendAdvert)
Set send advert flag.
Definition: radvd-interface.cc:119
ns3::RadvdInterface::m_defaultPreference
uint8_t m_defaultPreference
Preference associated with default router.
Definition: radvd-interface.h:402
ns3::RadvdInterface::GetMaxRtrAdvInterval
uint32_t GetMaxRtrAdvInterval() const
Get maximum RA interval.
Definition: radvd-interface.cc:125
ns3::RadvdInterface::m_sourceLLAddress
bool m_sourceLLAddress
Flag to add link-layer address in RA.
Definition: radvd-interface.h:407
ns3::RadvdInterface::SetHomeAgentInfo
void SetHomeAgentInfo(bool homeAgentFlag)
Set flag to add or not HA information option to RA.
Definition: radvd-interface.cc:287
radvd-interface.h
ns3::RadvdInterface::GetLinkMtu
uint32_t GetLinkMtu() const
Get link MTU.
Definition: radvd-interface.cc:185
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:244
ns3::RadvdInterface::SetRetransTimer
void SetRetransTimer(uint32_t retransTimer)
Set retransmission timer.
Definition: radvd-interface.cc:227
ns3::RadvdInterface::IsHomeAgentInfo
bool IsHomeAgentInfo() const
Is Home Agent Information option should be included in RA ?
Definition: radvd-interface.cc:281
ns3::RadvdInterface::SetSourceLLAddress
void SetSourceLLAddress(bool sourceLLAddress)
Set flag to add or not LLA to RA.
Definition: radvd-interface.cc:263
ns3::RadvdInterface::m_linkMtu
uint32_t m_linkMtu
Link MTU to use.
Definition: radvd-interface.h:374
ns3::RadvdInterface::SetHomeAgentPreference
void SetHomeAgentPreference(uint32_t homeAgentPreference)
Set home agent preference.
Definition: radvd-interface.cc:311
ns3::RadvdInterface::m_mobRtrSupportFlag
bool m_mobRtrSupportFlag
Flag for HA to signals it supports Mobile Router registrations (NEMO Basic).
Definition: radvd-interface.h:433
ns3::RadvdInterface::m_otherConfigFlag
bool m_otherConfigFlag
Other configuration flag.
Definition: radvd-interface.h:369
ns3::RadvdInterface::m_lastSendTime
Time m_lastSendTime
Last RA send time.
Definition: radvd-interface.h:443
ns3::RadvdInterface::IsSendAdvert
bool IsSendAdvert() const
Is send advert enabled (periodic RA and reply to RS) ?
Definition: radvd-interface.cc:113
ns3::RadvdInterface::RadvdInterface
RadvdInterface(uint32_t interface)
Constructor.
Definition: radvd-interface.cc:29
ns3::RadvdInterface::m_initialRtrAdvertisementsLeft
uint8_t m_initialRtrAdvertisementsLeft
Number of fast announcement to do.
Definition: radvd-interface.h:448
ns3::RadvdInterface::IsInitialRtrAdv
bool IsInitialRtrAdv()
Checks if the interface is subject to the initial Rtr Advertisements rule.
Definition: radvd-interface.cc:355
ns3::RadvdInterface::m_intervalOpt
bool m_intervalOpt
Flag to add Advertisement Interval option in RA.
Definition: radvd-interface.h:438
ns3::RadvdInterface::~RadvdInterface
~RadvdInterface()
Destructor.
Definition: radvd-interface.cc:83
ns3::RadvdInterface::IsSourceLLAddress
bool IsSourceLLAddress() const
Is source LLA option should be included in RA ?
Definition: radvd-interface.cc:257
ns3::RadvdInterface::IsOtherConfigFlag
bool IsOtherConfigFlag() const
Is "other config" flag enabled ?
Definition: radvd-interface.cc:173
ns3::RadvdInterface::GetRetransTimer
uint32_t GetRetransTimer() const
Get retransmission timer.
Definition: radvd-interface.cc:221
ns3::RadvdInterface::SetDefaultLifeTime
void SetDefaultLifeTime(uint32_t defaultLifeTime)
Set default lifetime.
Definition: radvd-interface.cc:215
ns3::RadvdInterface::SetMobRtrSupportFlag
void SetMobRtrSupportFlag(bool mobRtrSupportFlag)
Set "mobile router support" flag.
Definition: radvd-interface.cc:323
ns3::RadvdInterface::SetDefaultPreference
void SetDefaultPreference(uint8_t defaultPreference)
Set default preference.
Definition: radvd-interface.cc:251
ns3::RadvdInterface::IsManagedFlag
bool IsManagedFlag() const
Is managed flag enabled ?
Definition: radvd-interface.cc:161
ns3::RadvdInterface::IsIntervalOpt
bool IsIntervalOpt() const
Is advertisement interval option should be included in RA ?
Definition: radvd-interface.cc:329
ns3::RadvdInterface::m_curHopLimit
uint32_t m_curHopLimit
Current hop limit (TTL).
Definition: radvd-interface.h:389