1111
|
1 |
|
|
2 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
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 |
#ifndef GLOBAL_ROUTER_H
|
|
19 |
#define GLOBAL_ROUTER_H
|
|
20 |
|
|
21 |
#include <stdint.h>
|
|
22 |
#include <list>
|
|
23 |
#include "ns3/object.h"
|
|
24 |
#include "ns3/ptr.h"
|
|
25 |
#include "ns3/node.h"
|
|
26 |
#include "ns3/channel.h"
|
|
27 |
#include "ns3/ipv4-address.h"
|
|
28 |
#include "ns3/routing-environment.h"
|
|
29 |
|
|
30 |
namespace ns3 {
|
|
31 |
|
|
32 |
/**
|
|
33 |
* @brief A single link record for a link state advertisement.
|
|
34 |
*
|
|
35 |
* The GlobalRouterLinkRecord is modeled after the OSPF link record field of
|
|
36 |
* a Link State Advertisement. Right now we will only see two types of link
|
|
37 |
* records corresponding to a stub network and a point-to-point link (channel).
|
|
38 |
*/
|
|
39 |
class GlobalRouterLinkRecord
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
/**
|
|
43 |
* @enum LinkType
|
|
44 |
* @brief Enumeration of the possible types of Global Router Link Records.
|
|
45 |
*
|
|
46 |
* These values are defined in the OSPF spec. We currently only use
|
|
47 |
* PointToPoint and StubNetwork types.
|
|
48 |
*/
|
|
49 |
enum LinkType {
|
|
50 |
Unknown = 0, /**< Uninitialized Link Record */
|
|
51 |
PointToPoint, /**< Record representing a point to point channel */
|
|
52 |
TransitNetwork, /**< Unused -- for future OSPF compatibility */
|
|
53 |
StubNetwork, /**< Record represents a leaf node network */
|
|
54 |
VirtualLink /**< Unused -- for future OSPF compatibility */
|
|
55 |
};
|
|
56 |
/**
|
|
57 |
* @brief Construct an empty ("uninitialized") Global Router Link Record.
|
|
58 |
*
|
|
59 |
* The Link ID and Link Data Ipv4 addresses are set to "0.0.0.0";
|
|
60 |
* The Link Type is set to Unknown;
|
|
61 |
* The metric is set to 0.
|
|
62 |
*/
|
|
63 |
GlobalRouterLinkRecord ();
|
|
64 |
/**
|
|
65 |
* Construct an initialized Global Router Link Record.
|
|
66 |
*
|
|
67 |
* @param linkType The type of link record to construct.
|
|
68 |
* @param linkId The link ID for the record.
|
|
69 |
* @param linkData The link data field for the record.
|
|
70 |
* @param metric The metric field for the record.
|
|
71 |
* @see LinkType
|
|
72 |
* @see SetLinkId
|
|
73 |
* @see SetLinkData
|
|
74 |
*/
|
|
75 |
GlobalRouterLinkRecord (
|
|
76 |
LinkType linkType,
|
|
77 |
Ipv4Address linkId,
|
|
78 |
Ipv4Address linkData,
|
|
79 |
uint32_t metric);
|
|
80 |
/**
|
|
81 |
* @brief Destroy a Global Router Link Record.
|
|
82 |
*
|
|
83 |
* Currently does nothing. Here as a placeholder only.
|
|
84 |
*/
|
|
85 |
~GlobalRouterLinkRecord ();
|
|
86 |
/**
|
|
87 |
* Get the Link ID field of the Global Router Link Record.
|
|
88 |
*
|
|
89 |
* For an OSPF type 1 link (PointToPoint) the Link ID will be the Router ID
|
|
90 |
* of the neighboring router.
|
|
91 |
*
|
|
92 |
* For an OSPF type 3 link (StubNetwork), the Link ID will be the adjacent
|
|
93 |
* neighbor's IP address
|
|
94 |
*
|
|
95 |
* @returns The Ipv4Address corresponding to the Link ID field of the record.
|
|
96 |
*/
|
|
97 |
Ipv4Address GetLinkId(void) const;
|
|
98 |
/**
|
|
99 |
* @brief Set the Link ID field of the Global Router Link Record.
|
|
100 |
*
|
|
101 |
* For an OSPF type 1 link (PointToPoint) the Link ID must be the Router ID
|
|
102 |
* of the neighboring router.
|
|
103 |
*
|
|
104 |
* For an OSPF type 3 link (StubNetwork), the Link ID must be the adjacent
|
|
105 |
* neighbor's IP address
|
|
106 |
*
|
|
107 |
* @param addr An Ipv4Address to store in the Link ID field of the record.
|
|
108 |
*/
|
|
109 |
void SetLinkId(Ipv4Address addr);
|
|
110 |
/**
|
|
111 |
* @brief Get the Link Data field of the Global Router Link Record.
|
|
112 |
*
|
|
113 |
* For an OSPF type 1 link (PointToPoint) the Link Data will be the IP
|
|
114 |
* address of the node of the local side of the link.
|
|
115 |
*
|
|
116 |
* For an OSPF type 3 link (StubNetwork), the Link Data will be the
|
|
117 |
* network mask
|
|
118 |
*
|
|
119 |
* @returns The Ipv4Address corresponding to the Link Data field of the record.
|
|
120 |
*/
|
|
121 |
Ipv4Address GetLinkData(void) const;
|
|
122 |
/**
|
|
123 |
* @brief Set the Link Data field of the Global Router Link Record.
|
|
124 |
*
|
|
125 |
* For an OSPF type 1 link (PointToPoint) the Link Data must be the IP
|
|
126 |
* address of the node of the local side of the link.
|
|
127 |
*
|
|
128 |
* For an OSPF type 3 link (StubNetwork), the Link Data must be set to the
|
|
129 |
* network mask
|
|
130 |
*
|
|
131 |
* @param addr An Ipv4Address to store in the Link Data field of the record.
|
|
132 |
*/
|
|
133 |
void SetLinkData(Ipv4Address addr);
|
|
134 |
/**
|
|
135 |
* @brief Get the Link Type field of the Global Router Link Record.
|
|
136 |
*
|
|
137 |
* The Link Type describes the kind of link a given record represents. The
|
|
138 |
* values are defined by OSPF.
|
|
139 |
*
|
|
140 |
* @see LinkType
|
|
141 |
* @returns The LinkType of the current Global Router Link Record.
|
|
142 |
*/
|
|
143 |
LinkType GetLinkType(void) const;
|
|
144 |
/**
|
|
145 |
* @brief Set the Link Type field of the Global Router Link Record.
|
|
146 |
*
|
|
147 |
* The Link Type describes the kind of link a given record represents. The
|
|
148 |
* values are defined by OSPF.
|
|
149 |
*
|
|
150 |
* @see LinkType
|
|
151 |
* @param linkType The new LinkType for the current Global Router Link Record.
|
|
152 |
*/
|
|
153 |
void SetLinkType(LinkType linkType);
|
|
154 |
/**
|
|
155 |
* @brief Get the Metric Data field of the Global Router Link Record.
|
|
156 |
*
|
|
157 |
* The metric is an abstract cost associated with forwarding a packet across
|
|
158 |
* a link. A sum of metrics must have a well-defined meaning. That is, you
|
|
159 |
* shouldn't use bandwidth as a metric (how does the sum of the bandwidth of
|
|
160 |
* two hops relate to the cost of sending a packet); rather you should use
|
|
161 |
* something like delay.
|
|
162 |
*
|
|
163 |
* @returns The metric field of the Global Router Link Record.
|
|
164 |
*/
|
|
165 |
uint32_t GetMetric(void) const;
|
|
166 |
/**
|
|
167 |
* @brief Set the Metric Data field of the Global Router Link Record.
|
|
168 |
*
|
|
169 |
* The metric is an abstract cost associated with forwarding a packet across
|
|
170 |
* a link. A sum of metrics must have a well-defined meaning. That is, you
|
|
171 |
* shouldn't use bandwidth as a metric (how does the sum of the bandwidth of
|
|
172 |
* two hops relate to the cost of sending a packet); rather you should use
|
|
173 |
* something like delay.
|
|
174 |
*
|
|
175 |
* @param metric The new metric for the current Global Router Link Record.
|
|
176 |
*/
|
|
177 |
void SetMetric(uint32_t metric);
|
|
178 |
|
|
179 |
private:
|
|
180 |
/**
|
|
181 |
* m_linkId and m_linkData are defined by OSPF to have different meanings
|
|
182 |
* depending on the type of link a given link records represents. They work
|
|
183 |
* together.
|
|
184 |
*
|
|
185 |
* For Type 1 link (PointToPoint), set m_linkId to Router ID of
|
|
186 |
* neighboring router.
|
|
187 |
*
|
|
188 |
* For Type 3 link (Stub), set m_linkId to neighbor's IP address
|
|
189 |
*/
|
|
190 |
Ipv4Address m_linkId;
|
|
191 |
/**
|
|
192 |
* m_linkId and m_linkData are defined by OSPF to have different meanings
|
|
193 |
* depending on the type of link a given link records represents. They work
|
|
194 |
* together.
|
|
195 |
*
|
|
196 |
* For Type 1 link (PointToPoint), set m_linkData to local IP address
|
|
197 |
*
|
|
198 |
* For Type 3 link (Stub), set m_linkData to mask
|
|
199 |
*/
|
|
200 |
Ipv4Address m_linkData; // for links to RouterLSA,
|
|
201 |
/**
|
|
202 |
* The type of the Global Router Link Record. Defined in the OSPF spec.
|
|
203 |
* We currently only use PointToPoint and StubNetwork types.
|
|
204 |
*/
|
|
205 |
LinkType m_linkType;
|
|
206 |
/**
|
|
207 |
* The metric for a given link.
|
|
208 |
*
|
|
209 |
* A metric is abstract cost associated with forwarding a packet across a
|
|
210 |
* link. A sum of metrics must have a well-defined meaning. That is, you
|
|
211 |
* shouldn't use bandwidth as a metric (how does the sum of the bandwidth
|
|
212 |
* of two hops relate to the cost of sending a packet); rather you should
|
|
213 |
* use something like delay.
|
|
214 |
*/
|
|
215 |
uint32_t m_metric;
|
|
216 |
};
|
|
217 |
|
|
218 |
/**
|
|
219 |
* @brief a Link State Advertisement (LSA) for a router, used in global
|
|
220 |
* routing.
|
|
221 |
*
|
|
222 |
* Roughly equivalent to a global incarnation of the OSPF link state header
|
|
223 |
* combined with a list of Link Records. Since it's global, there's
|
|
224 |
* no need for age or sequence number. See RFC 2328, Appendix A.
|
|
225 |
*/
|
|
226 |
class GlobalRouterLSA
|
|
227 |
{
|
|
228 |
public:
|
|
229 |
/**
|
|
230 |
* @enum SPFStatus
|
|
231 |
* @brief Enumeration of the possible values of the status flag in the Router
|
|
232 |
* Link State Advertisements.
|
|
233 |
*/
|
|
234 |
enum SPFStatus {
|
|
235 |
LSA_SPF_NOT_EXPLORED = 0, /**< New vertex not yet considered */
|
|
236 |
LSA_SPF_CANDIDATE, /**< Vertex is in the SPF candidate queue */
|
|
237 |
LSA_SPF_IN_SPFTREE /**< Vertex is in the SPF tree */
|
|
238 |
};
|
|
239 |
/**
|
|
240 |
* @brief Create a blank Global Router Link State Advertisement.
|
|
241 |
*
|
|
242 |
* On completion Ipv4Address variables initialized to 0.0.0.0 and the
|
|
243 |
* list of Link State Records is empty.
|
|
244 |
*/
|
|
245 |
GlobalRouterLSA();
|
|
246 |
/**
|
|
247 |
* @brief Create an initialized Global Router Link State Advertisement.
|
|
248 |
*
|
|
249 |
* On completion the list of Link State Records is empty.
|
|
250 |
*
|
|
251 |
* @param status The status to of the new LSA.
|
|
252 |
* @param linkStateId The Ipv4Address for the link state ID field.
|
|
253 |
* @param advertisingRtr The Ipv4Address for the advertising router field.
|
|
254 |
*/
|
|
255 |
GlobalRouterLSA(SPFStatus status, Ipv4Address linkStateId,
|
|
256 |
Ipv4Address advertisingRtr);
|
|
257 |
/**
|
|
258 |
* @brief Copy constructor for a Global Router Link State Advertisement.
|
|
259 |
*
|
|
260 |
* Takes a piece of memory and constructs a semantically identical copy of
|
|
261 |
* the given LSA.
|
|
262 |
*
|
|
263 |
* @param lsa The existing LSA to be used as the source.
|
|
264 |
*/
|
|
265 |
GlobalRouterLSA (GlobalRouterLSA& lsa);
|
|
266 |
/**
|
|
267 |
* @brief Destroy an existing Global Router Link State Advertisement.
|
|
268 |
*
|
|
269 |
* Any Global Router Link Records present in the list are freed.
|
|
270 |
*/
|
|
271 |
~GlobalRouterLSA();
|
|
272 |
/**
|
|
273 |
* @brief Assignment operator for a Global Router Link State Advertisement.
|
|
274 |
*
|
|
275 |
* Takes an existing Global Router Link State Advertisement and overwrites
|
|
276 |
* it to make a semantically identical copy of a given prototype LSA.
|
|
277 |
*
|
|
278 |
* If there are any Global Router Link Records present in the existing
|
|
279 |
* LSA, they are freed before the assignment happens.
|
|
280 |
*
|
|
281 |
* @param lsa The existing LSA to be used as the source.
|
|
282 |
* @returns Reference to the overwritten LSA.
|
|
283 |
*/
|
|
284 |
GlobalRouterLSA& operator= (const GlobalRouterLSA& lsa);
|
|
285 |
/**
|
|
286 |
* @brief Copy any Global Router Link Records in a given Global Router Link
|
|
287 |
* State Advertisement to the current LSA.
|
|
288 |
*
|
|
289 |
* Existing Link Records are not deleted -- this is a concatenation of Link
|
|
290 |
* Records.
|
|
291 |
*
|
|
292 |
* @see ClearLinkRecords ()
|
|
293 |
* @param lsa The LSA to copy the Link Records from.
|
|
294 |
*/
|
|
295 |
void CopyLinkRecords (const GlobalRouterLSA& lsa);
|
|
296 |
/**
|
|
297 |
* @brief Add a given Global Router Link Record to the LSA.
|
|
298 |
*
|
|
299 |
* @param lr The Global Router Link Record to be added.
|
|
300 |
* @returns The number of link records in the list.
|
|
301 |
*/
|
|
302 |
uint32_t AddLinkRecord (GlobalRouterLinkRecord* lr);
|
|
303 |
/**
|
|
304 |
* @brief Return the number of Global Router Link Records in the LSA.
|
|
305 |
*
|
|
306 |
* @returns The number of link records in the list.
|
|
307 |
*/
|
|
308 |
uint32_t GetNLinkRecords (void) const;
|
|
309 |
/**
|
|
310 |
* @brief Return a pointer to the specified Global Router Link Record.
|
|
311 |
*
|
|
312 |
* @param n The LSA number desired.
|
|
313 |
* @returns The number of link records in the list.
|
|
314 |
*/
|
|
315 |
GlobalRouterLinkRecord* GetLinkRecord (uint32_t n) const;
|
|
316 |
/**
|
|
317 |
* @brief Release all of the Global Router Link Records present in the Global
|
|
318 |
* Router Link State Advertisement and make the list of link records empty.
|
|
319 |
*/
|
|
320 |
void ClearLinkRecords(void);
|
|
321 |
/**
|
|
322 |
* @brief Check to see if the list of Global Router Link Records present in the
|
|
323 |
* Global Router Link State Advertisement is empty.
|
|
324 |
*
|
|
325 |
* @returns True if the list is empty, false otherwise.
|
|
326 |
*/
|
|
327 |
bool IsEmpty(void) const;
|
|
328 |
/**
|
|
329 |
* @brief Print the contents of the Global Router Link State Advertisement and
|
|
330 |
* any Global Router Link Records present in the list. Quite verbose.
|
|
331 |
*/
|
|
332 |
void Print (std::ostream &os) const;
|
|
333 |
/**
|
|
334 |
* @brief Get the Link State ID as defined by the OSPF spec. We always set it
|
|
335 |
* to the router ID of the router making the advertisement.
|
|
336 |
*
|
|
337 |
* @see RoutingEnvironment::AllocateRouterId ()
|
|
338 |
* @see GlobalRouter::GetRouterId ()
|
|
339 |
* @returns The Ipv4Address stored as the link state ID.
|
|
340 |
*/
|
|
341 |
Ipv4Address GetLinkStateId (void) const;
|
|
342 |
/**
|
|
343 |
* @brief Set the Link State ID is defined by the OSPF spec. We always set it
|
|
344 |
* to the router ID of the router making the advertisement.
|
|
345 |
*
|
|
346 |
* @see RoutingEnvironment::AllocateRouterId ()
|
|
347 |
* @see GlobalRouter::GetRouterId ()
|
|
348 |
*/
|
|
349 |
void SetLinkStateId (Ipv4Address addr);
|
|
350 |
/**
|
|
351 |
* @brief Get the Advertising Router as defined by the OSPF spec. We always
|
|
352 |
* set it to the router ID of the router making the advertisement.
|
|
353 |
*
|
|
354 |
* @see RoutingEnvironment::AllocateRouterId ()
|
|
355 |
* @see GlobalRouter::GetRouterId ()
|
|
356 |
* @returns The Ipv4Address stored as the advetising router.
|
|
357 |
*/
|
|
358 |
Ipv4Address GetAdvertisingRouter (void) const;
|
|
359 |
/**
|
|
360 |
* @brief Set the Advertising Router as defined by the OSPF spec. We always
|
|
361 |
* set it to the router ID of the router making the advertisement.
|
|
362 |
*
|
|
363 |
* @see RoutingEnvironment::AllocateRouterId ()
|
|
364 |
* @see GlobalRouter::GetRouterId ()
|
|
365 |
*/
|
|
366 |
void SetAdvertisingRouter (Ipv4Address rtr);
|
|
367 |
/**
|
|
368 |
* @brief Get the SPF status of the advertisement.
|
|
369 |
*
|
|
370 |
* @see SPFStatus
|
|
371 |
* @returns The SPFStatus of the LSA.
|
|
372 |
*/
|
|
373 |
SPFStatus GetStatus (void) const;
|
|
374 |
/**
|
|
375 |
* @brief Set the SPF status of the advertisement
|
|
376 |
*
|
|
377 |
* @see SPFStatus
|
|
378 |
*/
|
|
379 |
void SetStatus (SPFStatus status);
|
|
380 |
|
|
381 |
private:
|
|
382 |
/**
|
|
383 |
* The Link State ID is defined by the OSPF spec. We always set it to the
|
|
384 |
* router ID of the router making the advertisement.
|
|
385 |
*
|
|
386 |
* @see RoutingEnvironment::AllocateRouterId ()
|
|
387 |
* @see GlobalRouter::GetRouterId ()
|
|
388 |
*/
|
|
389 |
Ipv4Address m_linkStateId;
|
|
390 |
/**
|
|
391 |
* The Advertising Router is defined by the OSPF spec. We always set it to
|
|
392 |
* the router ID of the router making the advertisement.
|
|
393 |
*
|
|
394 |
* @see RoutingEnvironment::AllocateRouterId ()
|
|
395 |
* @see GlobalRouter::GetRouterId ()
|
|
396 |
*/
|
|
397 |
Ipv4Address m_advertisingRtr;
|
|
398 |
/**
|
|
399 |
* A convenience typedef to avoid too much writers cramp.
|
|
400 |
*/
|
|
401 |
typedef std::list<GlobalRouterLinkRecord*> ListOfLinkRecords_t;
|
|
402 |
/**
|
|
403 |
* Each Link State Advertisement contains a number of Link Records that
|
|
404 |
* describe the kinds of links that are attached to a given node. We
|
|
405 |
* consider PointToPoint and StubNetwork links.
|
|
406 |
*
|
|
407 |
* m_linkRecords is an STL list container to hold the Link Records that have
|
|
408 |
* been discovered and prepared for the advertisement.
|
|
409 |
*
|
|
410 |
* @see GlobalRouter::DiscoverLSAs ()
|
|
411 |
*/
|
|
412 |
ListOfLinkRecords_t m_linkRecords;
|
|
413 |
/**
|
|
414 |
* This is a tristate flag used internally in the SPF computation to mark
|
|
415 |
* if an SPFVertex (a data structure representing a vertex in the SPF tree
|
|
416 |
* -- a router) is new, is a candidate for a shortest path, or is in its
|
|
417 |
* proper position in the tree.
|
|
418 |
*/
|
|
419 |
SPFStatus m_status;
|
|
420 |
};
|
|
421 |
|
|
422 |
std::ostream& operator<< (std::ostream& os, GlobalRouterLSA& lsa);
|
|
423 |
|
|
424 |
/**
|
|
425 |
* @brief An interface aggregated to a node to provide global routing info
|
|
426 |
*
|
|
427 |
* An interface aggregated to a node that provides global routing information
|
|
428 |
* to a global route manager. The presence of the interface indicates that
|
|
429 |
* the node is a router. The interface is the mechanism by which the router
|
|
430 |
* advertises its connections to neighboring routers. We're basically
|
|
431 |
* allowing the route manager to query for link state advertisements.
|
|
432 |
*/
|
|
433 |
class GlobalRouter : public Object
|
|
434 |
{
|
|
435 |
public:
|
|
436 |
/**
|
|
437 |
* @brief The Interface ID of the Global Router interface.
|
|
438 |
*
|
|
439 |
* @see Object::QueryInterface ()
|
|
440 |
*/
|
|
441 |
static const InterfaceId iid;
|
|
442 |
/**
|
|
443 |
* @brief Create a Global Router class and aggregate its interface onto the
|
|
444 |
* Node provided.
|
|
445 |
*
|
|
446 |
* @param node The existing Node onto which this router will be aggregated.
|
|
447 |
*/
|
|
448 |
GlobalRouter (Ptr<Node> node);
|
|
449 |
/**
|
|
450 |
* @brief Get the Router ID associated with this Global Router.
|
|
451 |
*
|
|
452 |
* The Router IDs are allocated in the RoutingEnvironment -- one per Router,
|
|
453 |
* starting at 0.0.0.1 and incrementing with each instantiation of a router.
|
|
454 |
*
|
|
455 |
* @see RoutingEnvironment::AllocateRouterId ()
|
|
456 |
* @returns The Router ID associated with the Global Router.
|
|
457 |
*/
|
|
458 |
Ipv4Address GetRouterId (void) const;
|
|
459 |
/**
|
|
460 |
* @brief Walk the connected channels, discover the adjacent routers and build
|
|
461 |
* the associated number of Global Router Link State Advertisements that
|
|
462 |
* this router can export.
|
|
463 |
*
|
|
464 |
* This is a fairly expensive operation in that every time it is called
|
|
465 |
* the current list of LSAs is built by walking connected point-to-point
|
|
466 |
* channels and peeking into adjacent IPV4 stacks to get address information.
|
|
467 |
* This is done to allow for limited dymanics of the Global Routing
|
|
468 |
* environment. By that we mean that you can discover new link state
|
|
469 |
* advertisements after a network topology change by calling DiscoverLSAs
|
|
470 |
* and then by reading those advertisements.
|
|
471 |
*
|
|
472 |
* @see GlobalRouterLSA
|
|
473 |
* @see GlobalRouter::GetLSA ()
|
|
474 |
* @returns The number of Global Router Link State Advertisements.
|
|
475 |
*/
|
|
476 |
uint32_t DiscoverLSAs (void);
|
|
477 |
/**
|
|
478 |
* @brief Get the Number of Global Router Link State Advertisements that this
|
|
479 |
* router can export.
|
|
480 |
*
|
|
481 |
* To get meaningful information you must have previously called DiscoverLSAs.
|
|
482 |
* After you know how many LSAs are present in the router, you may call
|
|
483 |
* GetLSA () to retrieve the actual advertisement.
|
|
484 |
*
|
|
485 |
* @see GlobalRouterLSA
|
|
486 |
* @see GlobalRouter::DiscoverLSAs ()
|
|
487 |
* @see GlobalRouter::GetLSA ()
|
|
488 |
* @returns The number of Global Router Link State Advertisements.
|
|
489 |
*/
|
|
490 |
uint32_t GetNumLSAs (void) const;
|
|
491 |
/**
|
|
492 |
* @brief Get a Global Router Link State Advertisements that this router has
|
|
493 |
* said that it can export.
|
|
494 |
*
|
|
495 |
* This is a fairly inexpensive expensive operation in that the hard work
|
|
496 |
* was done in GetNumLSAs. We just copy the indicated Global Router Link
|
|
497 |
* State Advertisement into the requested GlobalRouterLSA object.
|
|
498 |
*
|
|
499 |
* You must call GlobalRouter::GetNumLSAs before calling this method in
|
|
500 |
* order to discover the adjacent routers and build the advertisements.
|
|
501 |
* GetNumLSAs will return the number of LSAs this router advertises.
|
|
502 |
* The parameter n (requested LSA number) must be in the range 0 to
|
|
503 |
* GetNumLSAs() - 1.
|
|
504 |
*
|
|
505 |
* @see GlobalRouterLSA
|
|
506 |
* @see GlobalRouter::GetNumLSAs ()
|
|
507 |
* @param n The index number of the LSA you want to read.
|
|
508 |
* @param lsa The GlobalRouterLSA class to receive the LSA information.
|
|
509 |
* @returns The number of Global Router Link State Advertisements.
|
|
510 |
*/
|
|
511 |
bool GetLSA (uint32_t n, GlobalRouterLSA &lsa) const;
|
|
512 |
|
|
513 |
protected:
|
|
514 |
virtual ~GlobalRouter ();
|
|
515 |
void ClearLSAs (void);
|
|
516 |
|
|
517 |
Ptr<NetDevice> GetAdjacent(Ptr<NetDevice> nd, Ptr<Channel> ch) const;
|
|
518 |
uint32_t FindIfIndexForDevice(Ptr<Node> node, Ptr<NetDevice> nd) const;
|
|
519 |
|
|
520 |
Ptr<Node> m_node;
|
|
521 |
|
|
522 |
typedef std::list<GlobalRouterLSA*> ListOfLSAs_t;
|
|
523 |
ListOfLSAs_t m_LSAs;
|
|
524 |
|
|
525 |
Ipv4Address m_routerId;
|
|
526 |
|
|
527 |
private:
|
|
528 |
/**
|
|
529 |
* @brief Global Router copy construction is disallowed.
|
|
530 |
*/
|
|
531 |
GlobalRouter (GlobalRouter& sr);
|
|
532 |
/**
|
|
533 |
* @brief Global Router assignment operator is disallowed.
|
|
534 |
*/
|
|
535 |
GlobalRouter& operator= (GlobalRouter& sr);
|
|
536 |
};
|
|
537 |
|
|
538 |
} // namespace ns3
|
|
539 |
|
|
540 |
#endif /* GLOBAL_ROUTER_H */
|