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 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
8 * Mehdi Benamor <benamor.mehdi@ensi.rnu.tn>
9 */
10
11#ifndef RADVD_H
12#define RADVD_H
13
14#include "radvd-interface.h"
15
16#include "ns3/application.h"
17
18#include <map>
19
20namespace ns3
21{
22
23class UniformRandomVariable;
24class Socket;
25
26/**
27 * \ingroup internet-apps
28 * \defgroup radvd Radvd
29 */
30
31/**
32 * \ingroup radvd
33 * \brief Router advertisement daemon.
34 */
35class Radvd : public Application
36{
37 public:
38 /**
39 * \brief Get the type ID.
40 * \return type ID
41 */
42 static TypeId GetTypeId();
43
44 /**
45 * \brief Constructor.
46 */
47 Radvd();
48
49 /**
50 * \brief Destructor.
51 */
52 ~Radvd() override;
53
54 /**
55 * \brief Default value for maximum delay of RA (ms)
56 */
57 static const uint32_t MAX_RA_DELAY_TIME = 500;
58 /**
59 * \brief Default value for maximum initial RA advertisements
60 */
62 /**
63 * \brief Default value for maximum initial RA advertisements interval (ms)
64 */
66 /**
67 * \brief Default value for minimum delay between RA advertisements (ms)
68 */
69 static const uint32_t MIN_DELAY_BETWEEN_RAS = 3000;
70
71 /**
72 * \brief Add configuration for an interface;
73 * \param routerInterface configuration
74 */
75 void AddConfiguration(Ptr<RadvdInterface> routerInterface);
76
77 int64_t AssignStreams(int64_t stream) override;
78
79 protected:
80 void DoDispose() override;
81
82 private:
83 void StartApplication() override;
84 void StopApplication() override;
85
86 /// Container: Ptr to RadvdInterface
87 typedef std::list<Ptr<RadvdInterface>> RadvdInterfaceList;
88 /// Container Iterator: Ptr to RadvdInterface
89 typedef std::list<Ptr<RadvdInterface>>::iterator RadvdInterfaceListI;
90 /// Container Const Iterator: Ptr to RadvdInterface
91 typedef std::list<Ptr<RadvdInterface>>::const_iterator RadvdInterfaceListCI;
92
93 /// Container: interface number, EventId
94 typedef std::map<uint32_t, EventId> EventIdMap;
95 /// Container Iterator: interface number, EventId
96 typedef std::map<uint32_t, EventId>::iterator EventIdMapI;
97 /// Container Const Iterator: interface number, EventId
98 typedef std::map<uint32_t, EventId>::const_iterator EventIdMapCI;
99
100 /// Container: interface number, Socket
101 typedef std::map<uint32_t, Ptr<Socket>> SocketMap;
102 /// Container Iterator: interface number, Socket
103 typedef std::map<uint32_t, Ptr<Socket>>::iterator SocketMapI;
104 /// Container Const Iterator: interface number, Socket
105 typedef std::map<uint32_t, Ptr<Socket>>::const_iterator SocketMapCI;
106
107 /**
108 * \brief Send a packet.
109 * \param config interface configuration
110 * \param dst destination address (default ff02::1)
111 * \param reschedule if true another send will be reschedule (periodic)
112 */
113 void Send(Ptr<RadvdInterface> config,
115 bool reschedule = false);
116
117 /**
118 * \brief Handle received packet, especially router solicitation
119 * \param socket socket to read data from
120 */
121 void HandleRead(Ptr<Socket> socket);
122
123 /**
124 * \brief Raw socket to receive RS.
125 */
127
128 /**
129 * \brief Raw socket to send RA.
130 */
132
133 /**
134 * \brief List of configuration for interface.
135 */
137
138 /**
139 * \brief Event ID map for unsolicited RAs.
140 */
142
143 /**
144 * \brief Event ID map for solicited RAs.
145 */
147
148 /**
149 * \brief Variable to provide jitter in advertisement interval
150 */
152};
153
154} /* namespace ns3 */
155
156#endif /* RADVD_H */
The base class for all ns3 applications.
Definition application.h:51
Describes an IPv6 address.
static Ipv6Address GetAllNodesMulticast()
Get the "all nodes multicast" address.
Smart pointer class similar to boost::intrusive_ptr.
Router advertisement daemon.
Definition radvd.h:36
std::map< uint32_t, Ptr< Socket > >::iterator SocketMapI
Container Iterator: interface number, Socket.
Definition radvd.h:103
std::map< uint32_t, EventId > EventIdMap
Container: interface number, EventId.
Definition radvd.h:94
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:172
EventIdMap m_solicitedEventIds
Event ID map for solicited RAs.
Definition radvd.h:146
Ptr< UniformRandomVariable > m_jitter
Variable to provide jitter in advertisement interval.
Definition radvd.h:151
void DoDispose() override
Destructor implementation.
Definition radvd.cc:76
void Send(Ptr< RadvdInterface > config, Ipv6Address dst=Ipv6Address::GetAllNodesMulticast(), bool reschedule=false)
Send a packet.
Definition radvd.cc:180
~Radvd() override
Destructor.
Definition radvd.cc:64
std::list< Ptr< RadvdInterface > >::iterator RadvdInterfaceListI
Container Iterator: Ptr to RadvdInterface.
Definition radvd.h:89
std::map< uint32_t, Ptr< Socket > > SocketMap
Container: interface number, Socket.
Definition radvd.h:101
Ptr< Socket > m_recvSocket
Raw socket to receive RS.
Definition radvd.h:126
static const uint32_t MAX_INITIAL_RTR_ADVERTISEMENTS
Default value for maximum initial RA advertisements.
Definition radvd.h:61
std::map< uint32_t, Ptr< Socket > >::const_iterator SocketMapCI
Container Const Iterator: interface number, Socket.
Definition radvd.h:105
void HandleRead(Ptr< Socket > socket)
Handle received packet, especially router solicitation.
Definition radvd.cc:303
std::map< uint32_t, EventId >::iterator EventIdMapI
Container Iterator: interface number, EventId.
Definition radvd.h:96
std::list< Ptr< RadvdInterface > > RadvdInterfaceList
Container: Ptr to RadvdInterface.
Definition radvd.h:87
static const uint32_t MAX_RA_DELAY_TIME
Default value for maximum delay of RA (ms)
Definition radvd.h:57
static const uint32_t MAX_INITIAL_RTR_ADVERT_INTERVAL
Default value for maximum initial RA advertisements interval (ms)
Definition radvd.h:65
static const uint32_t MIN_DELAY_BETWEEN_RAS
Default value for minimum delay between RA advertisements (ms)
Definition radvd.h:69
EventIdMap m_unsolicitedEventIds
Event ID map for unsolicited RAs.
Definition radvd.h:141
static TypeId GetTypeId()
Get the type ID.
Definition radvd.cc:42
SocketMap m_sendSockets
Raw socket to send RA.
Definition radvd.h:131
void StopApplication() override
Application specific shutdown code.
Definition radvd.cc:142
std::list< Ptr< RadvdInterface > >::const_iterator RadvdInterfaceListCI
Container Const Iterator: Ptr to RadvdInterface.
Definition radvd.h:91
void AddConfiguration(Ptr< RadvdInterface > routerInterface)
Add configuration for an interface;.
Definition radvd.cc:165
std::map< uint32_t, EventId >::const_iterator EventIdMapCI
Container Const Iterator: interface number, EventId.
Definition radvd.h:98
RadvdInterfaceList m_configurations
List of configuration for interface.
Definition radvd.h:136
void StartApplication() override
Application specific startup code.
Definition radvd.cc:93
Radvd()
Constructor.
Definition radvd.cc:59
a unique identifier for an interface.
Definition type-id.h:48
Every class exported by the ns3 library is enclosed in the ns3 namespace.