A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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
31namespace ns3
32{
33
34class UniformRandomVariable;
35class Socket;
36
37/**
38 * \ingroup internet-apps
39 * \defgroup radvd Radvd
40 */
41
42/**
43 * \ingroup radvd
44 * \brief Router advertisement daemon.
45 */
46class Radvd : public Application
47{
48 public:
49 /**
50 * \brief Get the type ID.
51 * \return type ID
52 */
53 static TypeId GetTypeId();
54
55 /**
56 * \brief Constructor.
57 */
58 Radvd();
59
60 /**
61 * \brief Destructor.
62 */
63 ~Radvd() override;
64
65 /**
66 * \brief Default value for maximum delay of RA (ms)
67 */
68 static const uint32_t MAX_RA_DELAY_TIME = 500;
69 /**
70 * \brief Default value for maximum initial RA advertisements
71 */
73 /**
74 * \brief Default value for maximum initial RA advertisements interval (ms)
75 */
77 /**
78 * \brief Default value for minimum delay between RA advertisements (ms)
79 */
80 static const uint32_t MIN_DELAY_BETWEEN_RAS = 3000;
81
82 /**
83 * \brief Add configuration for an interface;
84 * \param routerInterface configuration
85 */
86 void AddConfiguration(Ptr<RadvdInterface> routerInterface);
87
88 int64_t AssignStreams(int64_t stream) override;
89
90 protected:
91 void DoDispose() override;
92
93 private:
94 void StartApplication() override;
95 void StopApplication() override;
96
97 /// Container: Ptr to RadvdInterface
98 typedef std::list<Ptr<RadvdInterface>> RadvdInterfaceList;
99 /// Container Iterator: Ptr to RadvdInterface
100 typedef std::list<Ptr<RadvdInterface>>::iterator RadvdInterfaceListI;
101 /// Container Const Iterator: Ptr to RadvdInterface
102 typedef std::list<Ptr<RadvdInterface>>::const_iterator RadvdInterfaceListCI;
103
104 /// Container: interface number, EventId
105 typedef std::map<uint32_t, EventId> EventIdMap;
106 /// Container Iterator: interface number, EventId
107 typedef std::map<uint32_t, EventId>::iterator EventIdMapI;
108 /// Container Const Iterator: interface number, EventId
109 typedef std::map<uint32_t, EventId>::const_iterator EventIdMapCI;
110
111 /// Container: interface number, Socket
112 typedef std::map<uint32_t, Ptr<Socket>> SocketMap;
113 /// Container Iterator: interface number, Socket
114 typedef std::map<uint32_t, Ptr<Socket>>::iterator SocketMapI;
115 /// Container Const Iterator: interface number, Socket
116 typedef std::map<uint32_t, Ptr<Socket>>::const_iterator SocketMapCI;
117
118 /**
119 * \brief Send a packet.
120 * \param config interface configuration
121 * \param dst destination address (default ff02::1)
122 * \param reschedule if true another send will be reschedule (periodic)
123 */
124 void Send(Ptr<RadvdInterface> config,
126 bool reschedule = false);
127
128 /**
129 * \brief Handle received packet, especially router solicitation
130 * \param socket socket to read data from
131 */
132 void HandleRead(Ptr<Socket> socket);
133
134 /**
135 * \brief Raw socket to receive RS.
136 */
138
139 /**
140 * \brief Raw socket to send RA.
141 */
143
144 /**
145 * \brief List of configuration for interface.
146 */
148
149 /**
150 * \brief Event ID map for unsolicited RAs.
151 */
153
154 /**
155 * \brief Event ID map for solicited RAs.
156 */
158
159 /**
160 * \brief Variable to provide jitter in advertisement interval
161 */
163};
164
165} /* namespace ns3 */
166
167#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.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Router advertisement daemon.
Definition: radvd.h:47
std::map< uint32_t, Ptr< Socket > >::iterator SocketMapI
Container Iterator: interface number, Socket.
Definition: radvd.h:114
std::map< uint32_t, EventId > EventIdMap
Container: interface number, EventId.
Definition: radvd.h:105
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this Application object.
Definition: radvd.cc:183
EventIdMap m_solicitedEventIds
Event ID map for solicited RAs.
Definition: radvd.h:157
Ptr< UniformRandomVariable > m_jitter
Variable to provide jitter in advertisement interval.
Definition: radvd.h:162
void DoDispose() override
Destructor implementation.
Definition: radvd.cc:87
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::list< Ptr< RadvdInterface > >::iterator RadvdInterfaceListI
Container Iterator: Ptr to RadvdInterface.
Definition: radvd.h:100
std::map< uint32_t, Ptr< Socket > > SocketMap
Container: interface number, Socket.
Definition: radvd.h:112
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
Definition: radvd.h:137
static const uint32_t MAX_INITIAL_RTR_ADVERTISEMENTS
Default value for maximum initial RA advertisements.
Definition: radvd.h:72
std::map< uint32_t, Ptr< Socket > >::const_iterator SocketMapCI
Container Const Iterator: interface number, Socket.
Definition: radvd.h:116
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
Definition: radvd.cc:314
std::map< uint32_t, EventId >::iterator EventIdMapI
Container Iterator: interface number, EventId.
Definition: radvd.h:107
std::list< Ptr< RadvdInterface > > RadvdInterfaceList
Container: Ptr to RadvdInterface.
Definition: radvd.h:98
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
EventIdMap m_unsolicitedEventIds
Event ID map for unsolicited RAs.
Definition: radvd.h:152
static TypeId GetTypeId()
Get the type ID.
Definition: radvd.cc:53
SocketMap m_sendSockets
Raw socket to send RA.
Definition: radvd.h:142
void StopApplication() override
Application specific shutdown code.
Definition: radvd.cc:153
std::list< Ptr< RadvdInterface > >::const_iterator RadvdInterfaceListCI
Container Const Iterator: Ptr to RadvdInterface.
Definition: radvd.h:102
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
Definition: radvd.cc:176
std::map< uint32_t, EventId >::const_iterator EventIdMapCI
Container Const Iterator: interface number, EventId.
Definition: radvd.h:109
RadvdInterfaceList m_configurations
List of configuration for interface.
Definition: radvd.h:147
void StartApplication() override
Application specific startup code.
Definition: radvd.cc:104
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.