A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
global-router-interface.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright 2007 University of Washington
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
* Authors: Craig Dowell (craigdo@ee.washington.edu)
19
* Tom Henderson (tomhend@u.washington.edu)
20
*/
21
22
#ifndef GLOBAL_ROUTER_INTERFACE_H
23
#define GLOBAL_ROUTER_INTERFACE_H
24
25
#include <stdint.h>
26
#include <list>
27
#include "ns3/object.h"
28
#include "ns3/ptr.h"
29
#include "ns3/node.h"
30
#include "ns3/channel.h"
31
#include "ns3/ipv4-address.h"
32
#include "ns3/net-device-container.h"
33
#include "ns3/bridge-net-device.h"
34
#include "ns3/global-route-manager.h"
35
#include "ns3/ipv4-routing-table-entry.h"
36
37
namespace
ns3 {
38
39
class
GlobalRouter;
40
class
Ipv4GlobalRouting;
41
49
class
GlobalRoutingLinkRecord
50
{
51
public
:
52
friend
class
GlobalRoutingLSA
;
60
enum
LinkType
{
61
Unknown
= 0,
62
PointToPoint
,
63
TransitNetwork
,
64
StubNetwork
,
65
VirtualLink
66
};
67
75
GlobalRoutingLinkRecord
();
76
88
GlobalRoutingLinkRecord
(
89
LinkType
linkType,
90
Ipv4Address
linkId,
91
Ipv4Address
linkData,
92
uint16_t metric);
93
99
~GlobalRoutingLinkRecord
();
100
112
Ipv4Address
GetLinkId
(
void
)
const
;
113
125
void
SetLinkId
(
Ipv4Address
addr);
126
138
Ipv4Address
GetLinkData
(
void
)
const
;
139
151
void
SetLinkData
(
Ipv4Address
addr);
152
162
LinkType
GetLinkType
(
void
)
const
;
163
173
void
SetLinkType
(
LinkType
linkType);
174
186
uint16_t
GetMetric
(
void
)
const
;
187
199
void
SetMetric
(uint16_t metric);
200
201
private
:
212
Ipv4Address
m_linkId
;
213
223
Ipv4Address
m_linkData
;
// for links to RouterLSA,
224
229
LinkType
m_linkType
;
230
240
uint16_t
m_metric
;
241
};
242
251
class
GlobalRoutingLSA
252
{
253
public
:
258
enum
LSType
{
259
Unknown
= 0,
260
RouterLSA
,
261
NetworkLSA
,
262
SummaryLSA
,
263
SummaryLSA_ASBR
,
264
ASExternalLSAs
265
};
271
enum
SPFStatus
{
272
LSA_SPF_NOT_EXPLORED
= 0,
273
LSA_SPF_CANDIDATE
,
274
LSA_SPF_IN_SPFTREE
275
};
282
GlobalRoutingLSA
();
283
293
GlobalRoutingLSA
(
SPFStatus
status,
Ipv4Address
linkStateId,
294
Ipv4Address
advertisingRtr);
295
304
GlobalRoutingLSA
(
GlobalRoutingLSA
& lsa);
305
311
~GlobalRoutingLSA
();
312
325
GlobalRoutingLSA
&
operator=
(
const
GlobalRoutingLSA
& lsa);
326
337
void
CopyLinkRecords
(
const
GlobalRoutingLSA
& lsa);
338
345
uint32_t
AddLinkRecord
(
GlobalRoutingLinkRecord
* lr);
346
352
uint32_t
GetNLinkRecords
(
void
)
const
;
353
360
GlobalRoutingLinkRecord
*
GetLinkRecord
(uint32_t n)
const
;
361
366
void
ClearLinkRecords
(
void
);
367
374
bool
IsEmpty
(
void
)
const
;
375
380
void
Print
(std::ostream &os)
const
;
381
385
LSType
GetLSType
(
void
)
const
;
389
void
SetLSType
(
LSType
typ);
390
399
Ipv4Address
GetLinkStateId
(
void
)
const
;
400
408
void
SetLinkStateId
(
Ipv4Address
addr);
409
418
Ipv4Address
GetAdvertisingRouter
(
void
)
const
;
419
428
void
SetAdvertisingRouter
(
Ipv4Address
rtr);
429
434
void
SetNetworkLSANetworkMask
(
Ipv4Mask
mask);
435
442
Ipv4Mask
GetNetworkLSANetworkMask
(
void
)
const
;
443
450
uint32_t
AddAttachedRouter
(
Ipv4Address
addr);
451
457
uint32_t
GetNAttachedRouters
(
void
)
const
;
458
465
Ipv4Address
GetAttachedRouter
(uint32_t n)
const
;
466
473
SPFStatus
GetStatus
(
void
)
const
;
474
480
void
SetStatus
(
SPFStatus
status);
481
486
Ptr<Node>
GetNode
(
void
)
const
;
487
492
void
SetNode
(
Ptr<Node>
node);
493
494
private
:
499
LSType
m_lsType
;
507
Ipv4Address
m_linkStateId
;
508
516
Ipv4Address
m_advertisingRtr
;
517
521
typedef
std::list<GlobalRoutingLinkRecord*>
ListOfLinkRecords_t
;
522
533
ListOfLinkRecords_t
m_linkRecords
;
534
538
Ipv4Mask
m_networkLSANetworkMask
;
539
543
typedef
std::list<Ipv4Address>
ListOfAttachedRouters_t
;
544
553
ListOfAttachedRouters_t
m_attachedRouters
;
554
561
SPFStatus
m_status
;
562
uint32_t
m_node_id
;
563
};
564
565
std::ostream&
operator<<
(std::ostream& os,
GlobalRoutingLSA
& lsa);
566
576
class
GlobalRouter
:
public
Object
577
{
578
public
:
584
static
TypeId
GetTypeId
(
void
);
585
589
GlobalRouter
();
590
591
592
void
SetRoutingProtocol
(
Ptr<Ipv4GlobalRouting>
routing);
593
Ptr<Ipv4GlobalRouting>
GetRoutingProtocol
(
void
);
594
604
Ipv4Address
GetRouterId
(
void
)
const
;
605
623
uint32_t
DiscoverLSAs
(
void
);
624
638
uint32_t
GetNumLSAs
(
void
)
const
;
639
660
bool
GetLSA
(uint32_t n,
GlobalRoutingLSA
&lsa)
const
;
661
669
void
InjectRoute
(
Ipv4Address
network,
Ipv4Mask
networkMask);
670
676
uint32_t
GetNInjectedRoutes
(
void
);
677
684
Ipv4RoutingTableEntry
*
GetInjectedRoute
(uint32_t i);
685
697
void
RemoveInjectedRoute
(uint32_t i);
698
708
bool
WithdrawRoute
(
Ipv4Address
network,
Ipv4Mask
networkMask);
709
710
private
:
711
virtual
~GlobalRouter
();
712
void
ClearLSAs
(
void
);
713
714
Ptr<NetDevice>
GetAdjacent
(
Ptr<NetDevice>
nd,
Ptr<Channel>
ch)
const
;
715
bool
FindInterfaceForDevice
(
Ptr<Node>
node,
Ptr<NetDevice>
nd, uint32_t &index)
const
;
716
Ipv4Address
FindDesignatedRouterForLink
(
Ptr<NetDevice>
ndLocal,
bool
allowRecursion)
const
;
717
bool
AnotherRouterOnLink
(
Ptr<NetDevice>
nd,
bool
allowRecursion)
const
;
718
void
ProcessBroadcastLink
(
Ptr<NetDevice>
nd,
GlobalRoutingLSA
*pLSA,
NetDeviceContainer
&c);
719
void
ProcessSingleBroadcastLink
(
Ptr<NetDevice>
nd,
GlobalRoutingLSA
*pLSA,
NetDeviceContainer
&c);
720
void
ProcessBridgedBroadcastLink
(
Ptr<NetDevice>
nd,
GlobalRoutingLSA
*pLSA,
NetDeviceContainer
&c);
721
722
void
ProcessPointToPointLink
(
Ptr<NetDevice>
ndLocal,
GlobalRoutingLSA
*pLSA);
723
void
BuildNetworkLSAs
(
NetDeviceContainer
c);
724
Ptr<BridgeNetDevice>
NetDeviceIsBridged
(
Ptr<NetDevice>
nd)
const
;
725
726
727
typedef
std::list<GlobalRoutingLSA*>
ListOfLSAs_t
;
728
ListOfLSAs_t
m_LSAs
;
729
730
Ipv4Address
m_routerId
;
731
Ptr<Ipv4GlobalRouting>
m_routingProtocol
;
732
733
typedef
std::list<Ipv4RoutingTableEntry *>
InjectedRoutes
;
734
typedef
std::list<Ipv4RoutingTableEntry *>::const_iterator
InjectedRoutesCI
;
735
typedef
std::list<Ipv4RoutingTableEntry *>::iterator
InjectedRoutesI
;
736
InjectedRoutes
m_injectedRoutes
;
// Routes we are exporting
737
738
// inherited from Object
739
virtual
void
DoDispose
(
void
);
740
744
GlobalRouter
(
GlobalRouter
& sr);
745
749
GlobalRouter
&
operator=
(
GlobalRouter
& sr);
750
};
751
752
}
// namespace ns3
753
754
#endif
/* GLOBAL_ROUTER_INTERFACE_H */
src
internet
model
global-router-interface.h
Generated on Tue May 14 2013 11:08:21 for ns-3 by
1.8.1.2