A Discrete-Event Network Simulator
API
radvd.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 Telecom Bretagne
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  * Mehdi Benamor <benamor.mehdi@ensi.rnu.tn>
20  */
21 
22 #ifndef RADVD_H
23 #define RADVD_H
24 
25 #include "radvd-interface.h"
26 
27 #include "ns3/application.h"
28 
29 #include <map>
30 
31 namespace ns3
32 {
33 
34 class UniformRandomVariable;
35 class Socket;
36 
46 class Radvd : public Application
47 {
48  public:
53  static TypeId GetTypeId();
54 
58  Radvd();
59 
63  ~Radvd() override;
64 
68  static const uint32_t MAX_RA_DELAY_TIME = 500;
72  static const uint32_t MAX_INITIAL_RTR_ADVERTISEMENTS = 3;
76  static const uint32_t MAX_INITIAL_RTR_ADVERT_INTERVAL = 16000;
80  static const uint32_t MIN_DELAY_BETWEEN_RAS = 3000;
81 
86  void AddConfiguration(Ptr<RadvdInterface> routerInterface);
87 
96  int64_t AssignStreams(int64_t stream);
97 
98  protected:
102  void DoDispose() override;
103 
104  private:
106  typedef std::list<Ptr<RadvdInterface>> RadvdInterfaceList;
108  typedef std::list<Ptr<RadvdInterface>>::iterator RadvdInterfaceListI;
110  typedef std::list<Ptr<RadvdInterface>>::const_iterator RadvdInterfaceListCI;
111 
113  typedef std::map<uint32_t, EventId> EventIdMap;
115  typedef std::map<uint32_t, EventId>::iterator EventIdMapI;
117  typedef std::map<uint32_t, EventId>::const_iterator EventIdMapCI;
118 
120  typedef std::map<uint32_t, Ptr<Socket>> SocketMap;
122  typedef std::map<uint32_t, Ptr<Socket>>::iterator SocketMapI;
124  typedef std::map<uint32_t, Ptr<Socket>>::const_iterator SocketMapCI;
125 
129  void StartApplication() override;
130 
134  void StopApplication() override;
135 
142  void Send(Ptr<RadvdInterface> config,
144  bool reschedule = false);
145 
150  void HandleRead(Ptr<Socket> socket);
151 
156 
161 
166 
171 
176 
181 };
182 
183 } /* namespace ns3 */
184 
185 #endif /* RADVD_H */
The base class for all ns3 applications.
Definition: application.h:62
Describes an IPv6 address.
Definition: ipv6-address.h:49
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
Router advertisement daemon.
Definition: radvd.h:47
std::map< uint32_t, EventId > EventIdMap
Container: interface number, EventId.
Definition: radvd.h:113
EventIdMap m_solicitedEventIds
Event ID map for solicited RAs.
Definition: radvd.h:175
Ptr< UniformRandomVariable > m_jitter
Variable to provide jitter in advertisement interval.
Definition: radvd.h:180
void DoDispose() override
Dispose the instance.
Definition: radvd.cc:87
std::map< uint32_t, EventId >::const_iterator EventIdMapCI
Container Const Iterator: interface number, EventId.
Definition: radvd.h:117
void Send(Ptr< RadvdInterface > config, Ipv6Address dst=Ipv6Address::GetAllNodesMulticast(), bool reschedule=false)
Send a packet.
Definition: radvd.cc:191
~Radvd() override
Destructor.
Definition: radvd.cc:75
std::map< uint32_t, Ptr< Socket > > SocketMap
Container: interface number, Socket.
Definition: radvd.h:120
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
Definition: radvd.h:155
static const uint32_t MAX_INITIAL_RTR_ADVERTISEMENTS
Default value for maximum initial RA advertisements.
Definition: radvd.h:72
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
Definition: radvd.cc:314
std::map< uint32_t, Ptr< Socket > >::iterator SocketMapI
Container Iterator: interface number, Socket.
Definition: radvd.h:122
std::list< Ptr< RadvdInterface > > RadvdInterfaceList
Container: Ptr to RadvdInterface.
Definition: radvd.h:106
static const uint32_t MAX_RA_DELAY_TIME
Default value for maximum delay of RA (ms)
Definition: radvd.h:68
static const uint32_t MAX_INITIAL_RTR_ADVERT_INTERVAL
Default value for maximum initial RA advertisements interval (ms)
Definition: radvd.h:76
static const uint32_t MIN_DELAY_BETWEEN_RAS
Default value for minimum delay between RA advertisements (ms)
Definition: radvd.h:80
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: radvd.cc:183
EventIdMap m_unsolicitedEventIds
Event ID map for unsolicited RAs.
Definition: radvd.h:170
std::list< Ptr< RadvdInterface > >::iterator RadvdInterfaceListI
Container Iterator: Ptr to RadvdInterface.
Definition: radvd.h:108
static TypeId GetTypeId()
Get the type ID.
Definition: radvd.cc:53
std::map< uint32_t, Ptr< Socket > >::const_iterator SocketMapCI
Container Const Iterator: interface number, Socket.
Definition: radvd.h:124
SocketMap m_sendSockets
Raw socket to send RA.
Definition: radvd.h:160
void StopApplication() override
Stop the application.
Definition: radvd.cc:153
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
Definition: radvd.cc:176
RadvdInterfaceList m_configurations
List of configuration for interface.
Definition: radvd.h:165
void StartApplication() override
Start the application.
Definition: radvd.cc:104
std::map< uint32_t, EventId >::iterator EventIdMapI
Container Iterator: interface number, EventId.
Definition: radvd.h:115
std::list< Ptr< RadvdInterface > >::const_iterator RadvdInterfaceListCI
Container Const Iterator: Ptr to RadvdInterface.
Definition: radvd.h:110
Radvd()
Constructor.
Definition: radvd.cc:70
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.