A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
global-router-interface.h
Go to the documentation of this file.
1/*
2 * Copyright 2007 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 * Authors: Craig Dowell (craigdo@ee.washington.edu)
18 * Tom Henderson (tomhend@u.washington.edu)
19 */
20
21#ifndef GLOBAL_ROUTER_INTERFACE_H
22#define GLOBAL_ROUTER_INTERFACE_H
23
24#include "ns3/bridge-net-device.h"
25#include "ns3/channel.h"
26#include "ns3/global-route-manager.h"
27#include "ns3/ipv4-address.h"
28#include "ns3/ipv4-routing-table-entry.h"
29#include "ns3/net-device-container.h"
30#include "ns3/node.h"
31#include "ns3/object.h"
32#include "ns3/ptr.h"
33
34#include <list>
35#include <stdint.h>
36
37namespace ns3
38{
39
40class GlobalRouter;
41class Ipv4GlobalRouting;
42
53{
54 public:
55 friend class GlobalRoutingLSA;
56
65 {
66 Unknown = 0,
71 };
72
81
94 Ipv4Address linkId,
95 Ipv4Address linkData,
96 uint16_t metric);
97
104
116 Ipv4Address GetLinkId() const;
117
129 void SetLinkId(Ipv4Address addr);
130
142 Ipv4Address GetLinkData() const;
143
155 void SetLinkData(Ipv4Address addr);
156
166 LinkType GetLinkType() const;
167
177 void SetLinkType(LinkType linkType);
178
190 uint16_t GetMetric() const;
191
203 void SetMetric(uint16_t metric);
204
205 private:
217
227 Ipv4Address m_linkData; // for links to RouterLSA,
228
234
244 uint16_t m_metric;
245};
246
256{
257 public:
263 {
270 };
271
278 {
282 };
283
291
301 GlobalRoutingLSA(SPFStatus status, Ipv4Address linkStateId, Ipv4Address advertisingRtr);
302
312
319
333
344 void CopyLinkRecords(const GlobalRoutingLSA& lsa);
345
353
360
368
373 void ClearLinkRecords();
374
381 bool IsEmpty() const;
382
388 void Print(std::ostream& os) const;
389
394 LSType GetLSType() const;
399 void SetLSType(LSType typ);
400
410
418 void SetLinkStateId(Ipv4Address addr);
419
429
439
446
454
462
469
477
484 SPFStatus GetStatus() const;
485
491 void SetStatus(SPFStatus status);
492
497 Ptr<Node> GetNode() const;
498
503 void SetNode(Ptr<Node> node);
504
505 private:
519
528
532 typedef std::list<GlobalRoutingLinkRecord*> ListOfLinkRecords_t;
533
545
550
554 typedef std::list<Ipv4Address> ListOfAttachedRouters_t;
555
565
574};
575
583std::ostream& operator<<(std::ostream& os, GlobalRoutingLSA& lsa);
584
594class GlobalRouter : public Object
595{
596 public:
601 static TypeId GetTypeId();
602
606 GlobalRouter();
607
608 // Delete copy constructor and assignment operator to avoid misuse
609 GlobalRouter(const GlobalRouter&) = delete;
611
617
623
633 Ipv4Address GetRouterId() const;
634
653
667 uint32_t GetNumLSAs() const;
668
689 bool GetLSA(uint32_t n, GlobalRoutingLSA& lsa) const;
690
698 void InjectRoute(Ipv4Address network, Ipv4Mask networkMask);
699
706
714
727
737 bool WithdrawRoute(Ipv4Address network, Ipv4Mask networkMask);
738
739 private:
740 ~GlobalRouter() override;
741
745 void ClearLSAs();
746
757
770
781 bool AnotherRouterOnLink(Ptr<NetDevice> nd) const;
782
791
800 GlobalRoutingLSA* pLSA,
802
811 GlobalRoutingLSA* pLSA,
813
821
829
845
853
854 typedef std::list<GlobalRoutingLSA*> ListOfLSAs_t;
856
859
860 typedef std::list<Ipv4RoutingTableEntry*>
862 typedef std::list<Ipv4RoutingTableEntry*>::const_iterator
864 typedef std::list<Ipv4RoutingTableEntry*>::iterator
867
868 // Declared mutable so that const member functions can clear it
869 // (supporting the logical constness of the search methods of this class)
873 mutable std::vector<Ptr<BridgeNetDevice>> m_bridgesVisited;
877 void ClearBridgesVisited() const;
892 void MarkBridgeAsVisited(Ptr<BridgeNetDevice> device) const;
893
894 // inherited from Object
895 void DoDispose() override;
896};
897
898} // namespace ns3
899
900#endif /* GLOBAL_ROUTER_INTERFACE_H */
An interface aggregated to a node to provide global routing info.
std::list< GlobalRoutingLSA * > ListOfLSAs_t
container for the GlobalRoutingLSAs
Ipv4Address FindDesignatedRouterForLink(Ptr< NetDevice > ndLocal) const
Finds a designated router.
void MarkBridgeAsVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, mark a given device as having been visited.
Ptr< Ipv4GlobalRouting > m_routingProtocol
the Ipv4GlobalRouting in use
bool GetLSA(uint32_t n, GlobalRoutingLSA &lsa) const
Get a Global Routing Link State Advertisements that this router has said that it can export.
void ProcessSingleBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a single broadcast link.
bool WithdrawRoute(Ipv4Address network, Ipv4Mask networkMask)
Withdraw a route from the global unicast routing table.
NetDeviceContainer FindAllNonBridgedDevicesOnLink(Ptr< Channel > ch) const
Return a container of all non-bridged NetDevices on a link.
GlobalRouter & operator=(const GlobalRouter &)=delete
bool BridgeHasAlreadyBeenVisited(Ptr< BridgeNetDevice > device) const
When recursively checking for devices on the link, check whether a given device has already been visi...
InjectedRoutes m_injectedRoutes
Routes we are exporting.
void ClearBridgesVisited() const
Clear the list of bridges visited on the link.
void InjectRoute(Ipv4Address network, Ipv4Mask networkMask)
Inject a route to be circulated to other routers as an external route.
Ptr< BridgeNetDevice > NetDeviceIsBridged(Ptr< NetDevice > nd) const
Decide whether or not a given net device is being bridged by a BridgeNetDevice.
Ipv4Address GetRouterId() const
Get the Router ID associated with this Global Router.
uint32_t GetNumLSAs() const
Get the Number of Global Routing Link State Advertisements that this router can export.
ListOfLSAs_t m_LSAs
database of GlobalRoutingLSAs
void ProcessBridgedBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a bridged broadcast link.
GlobalRouter()
Create a Global Router class.
GlobalRouter(const GlobalRouter &)=delete
Ipv4RoutingTableEntry * GetInjectedRoute(uint32_t i)
Return the injected route indexed by i.
std::list< Ipv4RoutingTableEntry * > InjectedRoutes
container of Ipv4RoutingTableEntry
std::list< Ipv4RoutingTableEntry * >::iterator InjectedRoutesI
Iterator to container of Ipv4RoutingTableEntry.
void ClearLSAs()
Clear list of LSAs.
static TypeId GetTypeId()
Get the type ID.
Ptr< Ipv4GlobalRouting > GetRoutingProtocol()
Get the specific Global Routing Protocol used.
Ipv4Address m_routerId
router ID (its IPv4 address)
void RemoveInjectedRoute(uint32_t i)
Withdraw a route from the global unicast routing table.
bool AnotherRouterOnLink(Ptr< NetDevice > nd) const
Checks for the presence of another router on the NetDevice.
std::list< Ipv4RoutingTableEntry * >::const_iterator InjectedRoutesCI
Const Iterator to container of Ipv4RoutingTableEntry.
void SetRoutingProtocol(Ptr< Ipv4GlobalRouting > routing)
Set the specific Global Routing Protocol to be used.
Ptr< NetDevice > GetAdjacent(Ptr< NetDevice > nd, Ptr< Channel > ch) const
Link through the given channel and find the net device that's on the other end.
std::vector< Ptr< BridgeNetDevice > > m_bridgesVisited
Container of bridges visited.
void ProcessPointToPointLink(Ptr< NetDevice > ndLocal, GlobalRoutingLSA *pLSA)
Process a point to point link.
uint32_t DiscoverLSAs()
Walk the connected channels, discover the adjacent routers and build the associated number of Global ...
void DoDispose() override
Destructor implementation.
void ProcessBroadcastLink(Ptr< NetDevice > nd, GlobalRoutingLSA *pLSA, NetDeviceContainer &c)
Process a generic broadcast link.
uint32_t GetNInjectedRoutes()
Get the number of injected routes that have been added to the routing table.
void BuildNetworkLSAs(NetDeviceContainer c)
Build one NetworkLSA for each net device talking to a network that we are the designated router for.
a Link State Advertisement (LSA) for a router, used in global routing.
Ipv4Address GetAdvertisingRouter() const
Get the Advertising Router as defined by the OSPF spec.
void SetStatus(SPFStatus status)
Set the SPF status of the advertisement.
void Print(std::ostream &os) const
Print the contents of the Global Routing Link State Advertisement and any Global Routing Link Records...
SPFStatus
Enumeration of the possible values of the status flag in the Routing Link State Advertisements.
@ LSA_SPF_NOT_EXPLORED
New vertex not yet considered.
@ LSA_SPF_IN_SPFTREE
Vertex is in the SPF tree.
@ LSA_SPF_CANDIDATE
Vertex is in the SPF candidate queue.
uint32_t GetNAttachedRouters() const
Return the number of attached routers listed in the NetworkLSA.
std::list< Ipv4Address > ListOfAttachedRouters_t
A convenience typedef to avoid too much writers cramp.
Ptr< Node > GetNode() const
Get the Node pointer of the node that originated this LSA.
uint32_t AddLinkRecord(GlobalRoutingLinkRecord *lr)
Add a given Global Routing Link Record to the LSA.
LSType
corresponds to LS type field of RFC 2328 OSPF LSA header
@ Unknown
Uninitialized Type.
SPFStatus GetStatus() const
Get the SPF status of the advertisement.
Ipv4Address m_linkStateId
The Link State ID is defined by the OSPF spec.
bool IsEmpty() const
Check to see if the list of Global Routing Link Records present in the Global Routing Link State Adve...
Ipv4Mask GetNetworkLSANetworkMask() const
For a Network LSA, get the Network Mask field that precedes the list of attached routers.
GlobalRoutingLSA()
Create a blank Global Routing Link State Advertisement.
ListOfLinkRecords_t m_linkRecords
Each Link State Advertisement contains a number of Link Records that describe the kinds of links that...
Ipv4Address GetAttachedRouter(uint32_t n) const
Return an Ipv4Address corresponding to the specified attached router.
void SetNode(Ptr< Node > node)
Set the Node pointer of the node that originated this LSA.
LSType GetLSType() const
Return the LSType field of the LSA.
uint32_t AddAttachedRouter(Ipv4Address addr)
Add an attached router to the list in the NetworkLSA.
std::list< GlobalRoutingLinkRecord * > ListOfLinkRecords_t
A convenience typedef to avoid too much writers cramp.
uint32_t GetNLinkRecords() const
Return the number of Global Routing Link Records in the LSA.
~GlobalRoutingLSA()
Destroy an existing Global Routing Link State Advertisement.
Ipv4Address m_advertisingRtr
The Advertising Router is defined by the OSPF spec.
void SetLSType(LSType typ)
Set the LS type field of the LSA.
void ClearLinkRecords()
Release all of the Global Routing Link Records present in the Global Routing Link State Advertisement...
void SetAdvertisingRouter(Ipv4Address rtr)
Set the Advertising Router as defined by the OSPF spec.
SPFStatus m_status
This is a tristate flag used internally in the SPF computation to mark if an SPFVertex (a data struct...
LSType m_lsType
The type of the LSA.
ListOfAttachedRouters_t m_attachedRouters
Each Network LSA contains a list of attached routers.
GlobalRoutingLinkRecord * GetLinkRecord(uint32_t n) const
Return a pointer to the specified Global Routing Link Record.
void SetNetworkLSANetworkMask(Ipv4Mask mask)
For a Network LSA, set the Network Mask field that precedes the list of attached routers.
Ipv4Mask m_networkLSANetworkMask
Each Network LSA contains the network mask of the attached network.
void CopyLinkRecords(const GlobalRoutingLSA &lsa)
Copy any Global Routing Link Records in a given Global Routing Link State Advertisement to the curren...
void SetLinkStateId(Ipv4Address addr)
Set the Link State ID is defined by the OSPF spec.
GlobalRoutingLSA & operator=(const GlobalRoutingLSA &lsa)
Assignment operator for a Global Routing Link State Advertisement.
Ipv4Address GetLinkStateId() const
Get the Link State ID as defined by the OSPF spec.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:42
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:257
A record of an IPv4 routing table entry for Ipv4GlobalRouting and Ipv4StaticRouting.
holds a vector of ns3::NetDevice pointers
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::ostream & operator<<(std::ostream &os, const Angles &a)
Definition: angles.cc:129