A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
ipv6-address-helper.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2008-2009 Strasbourg University
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Sebastien Vincent <vincent@clarinet.u-strasbg.fr>
7
* modified by Tom Henderson for ns-3.14 release
8
*/
9
10
#ifndef IPV6_ADDRESS_HELPER_H
11
#define IPV6_ADDRESS_HELPER_H
12
13
#include "
ipv6-interface-container.h
"
14
15
#include "ns3/ipv6-address.h"
16
#include "ns3/net-device-container.h"
17
18
#include <vector>
19
20
namespace
ns3
21
{
22
23
/**
24
* \ingroup ipv6Helpers
25
*
26
* \brief Helper class to auto-assign global IPv6 unicast addresses
27
*
28
* Assign global unicast IPv6 addresses based on \RFC{4291} definition.
29
*
30
* | n bits | 64-n bits | 64 bits |
31
* +-------------------------+-----------+----------------------------+
32
* | global routing prefix | subnet ID | interface ID |
33
* +-------------------------+-----------+----------------------------+
34
* <-------------network---------------->
35
*
36
* 11111111111111111111111111000000000000
37
* <---prefix of length n--->
38
*
39
* This class handles the following quantities.
40
* 1) The "network" which covers the 64 bit union of the global routing
41
* prefix and the subnet ID
42
* 2) the "prefix" length "n" which demarcates the global routing prefix
43
* and the subnet ID
44
* 3) the "base" which is the initial 64-bit interface ID.
45
*
46
* The names "network", "prefix" and "base" are chosen to be consistent
47
* with a similar address helper for IPv4.
48
*
49
* This helper class allows users to set or reset the network and
50
* interface components, and call "NewAddress ()" to sequentially increment
51
* the interface ID, and call "NewNetwork ()" to allocate a new subnet
52
* (until the subnet ID quantity rolls over). A call to NewNetwork ()
53
* that causes the subnet ID to roll over will trigger an assertion.
54
*
55
* By default, the prefix is 32 bits and the network is '2001:db8::/32'
56
* (\RFC{5156} section 2.6 Documentation prefix). The prefix may range
57
* from length 0 to 64, with the value 64 having a special meaning that
58
* no subnet ID boundary is enforced (equivalent to value 0).
59
*
60
* There are two variants of interface ID supported (\RFC{4291}, Sec. 2.5.1)
61
* The default is a "local" scope, but a "universal" scoped ID may be
62
* formed by calling "NewAddress (Address addr)" with a 48-bit MAC address.
63
* If this method is called, the addressed returned will include a
64
* modified EUI-64-format identifier created from the MAC address as
65
* specified in \RFC{4291}.
66
*
67
* BEWARE: the underlying implementation acts as a Singleton.
68
* In other terms, two different instances of Ipv6AddressHelper will
69
* pick IPv6 numbers from the same pool. Changing the network in one of them
70
* will also change the network in the other instances.
71
*/
72
class
Ipv6AddressHelper
73
{
74
public
:
75
/**
76
* \brief Constructor.
77
*/
78
Ipv6AddressHelper
();
79
80
/**
81
* \brief Constructor.
82
* \param network The IPv6 network
83
* \param prefix The prefix
84
* \param base The base interface ID
85
*/
86
Ipv6AddressHelper
(
Ipv6Address
network,
87
Ipv6Prefix
prefix,
88
Ipv6Address
base =
Ipv6Address
(
"::1"
));
89
90
/**
91
* \brief Set the base network number, network prefix, and base interface ID
92
*
93
* \param network The IPv6 network
94
* \param prefix The prefix
95
* \param base The base interface ID
96
*/
97
void
SetBase
(
Ipv6Address
network,
Ipv6Prefix
prefix,
Ipv6Address
base =
Ipv6Address
(
"::1"
));
98
99
/**
100
* \brief Allocate a new network.
101
*
102
* This method will cause the subnet prefix to increment, for future
103
* network IDs, and resets the interface ID to the previously used
104
* base.
105
*/
106
void
NewNetwork
();
107
108
/**
109
* \brief Allocate a new Ipv6Address.
110
*
111
* If a Mac48Address is passed in, an Ipv6 autoconfigured address
112
* according to the current subnet prefix is returned. If something
113
* other than Mac48 address is passed in, the program will terminate.
114
*
115
* \param addr address used to generate the interface ID of the IPv6 address
116
* \return newly created Ipv6Address
117
*/
118
Ipv6Address
NewAddress
(
Address
addr);
119
120
/**
121
* \brief Allocate a new Ipv6Address with interface ID equal to the
122
* next one in the underlying generator.
123
*
124
* \return newly created Ipv6Address
125
*/
126
Ipv6Address
NewAddress
();
127
128
/**
129
* \brief Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
130
* \param c netdevice container
131
* \return newly created Ipv6InterfaceContainer
132
*/
133
Ipv6InterfaceContainer
Assign
(
const
NetDeviceContainer
& c);
134
135
/**
136
* \brief Allocate an Ipv6InterfaceContainer, and control whether the
137
* interfaces have addresses auto-assigned to them
138
*
139
* \param c netdevice container
140
* \param withConfiguration a vector of values for which, for a
141
* given device, true : interface automatically addressed,
142
* false : no automatic address
143
* \return newly created Ipv6InterfaceContainer
144
*/
145
Ipv6InterfaceContainer
Assign
(
const
NetDeviceContainer
& c, std::vector<bool> withConfiguration);
146
147
/**
148
* \brief Allocate an Ipv6InterfaceContainer, and control whether the
149
* interfaces have addresses auto-assigned to them
150
*
151
* \param c netdevice container
152
* \param withConfiguration a vector of values for which, for a
153
* given device, true : interface automatically addressed,
154
* false : no automatic address
155
* \param onLink a vector of values for which, for a
156
* given device, true : on-link property added,
157
* false : network is not on-link
158
* Meaningful only if the address is automatically assigned.
159
* \return newly created Ipv6InterfaceContainer
160
*/
161
Ipv6InterfaceContainer
Assign
(
const
NetDeviceContainer
& c,
162
std::vector<bool> withConfiguration,
163
std::vector<bool> onLink);
164
165
/**
166
* \brief Allocate an Ipv6InterfaceContainer but do not assign any IPv6 addresses
167
*
168
* This method is used when IPv6 address assignment may occur later
169
* (such as dynamic address assignment)
170
*
171
* Equivalent to AssignWithoutAddress (c, std::vector<bool> of false);
172
*
173
* \param c netdevice container
174
* \return newly created Ipv6InterfaceContainer
175
*/
176
Ipv6InterfaceContainer
AssignWithoutAddress
(
const
NetDeviceContainer
& c);
177
178
/**
179
* \brief Allocate an Ipv6InterfaceContainer with auto-assigned addresses,
180
* but do not set the on-link property for the network.
181
*
182
* This method will assign a valid global address to the interface but
183
* the routing will not consider the network as "on-link".
184
*
185
* \param c netdevice container
186
* \return newly created Ipv6InterfaceContainer
187
*/
188
Ipv6InterfaceContainer
AssignWithoutOnLink
(
const
NetDeviceContainer
& c);
189
190
private
:
191
Ipv6Address
m_network
;
//!< network address
192
Ipv6Prefix
m_prefix
;
//!< prefix length
193
Ipv6Address
m_address
;
//!< host address
194
Ipv6Address
m_base
;
//!< host base address
195
};
196
197
}
/* namespace ns3 */
198
199
#endif
/* IPV6_ADDRESS_STATIC_H */
ns3::Address
a polymophic address class
Definition
address.h:90
ns3::Ipv6AddressHelper
Helper class to auto-assign global IPv6 unicast addresses.
Definition
ipv6-address-helper.h:73
ns3::Ipv6AddressHelper::AssignWithoutAddress
Ipv6InterfaceContainer AssignWithoutAddress(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer but do not assign any IPv6 addresses.
Definition
ipv6-address-helper.cc:293
ns3::Ipv6AddressHelper::SetBase
void SetBase(Ipv6Address network, Ipv6Prefix prefix, Ipv6Address base=Ipv6Address("::1"))
Set the base network number, network prefix, and base interface ID.
Definition
ipv6-address-helper.cc:59
ns3::Ipv6AddressHelper::m_base
Ipv6Address m_base
host base address
Definition
ipv6-address-helper.h:194
ns3::Ipv6AddressHelper::NewNetwork
void NewNetwork()
Allocate a new network.
Definition
ipv6-address-helper.cc:168
ns3::Ipv6AddressHelper::m_network
Ipv6Address m_network
network address
Definition
ipv6-address-helper.h:191
ns3::Ipv6AddressHelper::m_address
Ipv6Address m_address
host address
Definition
ipv6-address-helper.h:193
ns3::Ipv6AddressHelper::AssignWithoutOnLink
Ipv6InterfaceContainer AssignWithoutOnLink(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses, but do not set the on-link property ...
Definition
ipv6-address-helper.cc:301
ns3::Ipv6AddressHelper::m_prefix
Ipv6Prefix m_prefix
prefix length
Definition
ipv6-address-helper.h:192
ns3::Ipv6AddressHelper::Assign
Ipv6InterfaceContainer Assign(const NetDeviceContainer &c)
Allocate an Ipv6InterfaceContainer with auto-assigned addresses.
Definition
ipv6-address-helper.cc:209
ns3::Ipv6AddressHelper::Ipv6AddressHelper
Ipv6AddressHelper()
Constructor.
Definition
ipv6-address-helper.cc:31
ns3::Ipv6AddressHelper::NewAddress
Ipv6Address NewAddress()
Allocate a new Ipv6Address with interface ID equal to the next one in the underlying generator.
Definition
ipv6-address-helper.cc:118
ns3::Ipv6Address
Describes an IPv6 address.
Definition
ipv6-address.h:38
ns3::Ipv6InterfaceContainer
Keep track of a set of IPv6 interfaces.
Definition
ipv6-interface-container.h:29
ns3::Ipv6Prefix
Describes an IPv6 prefix.
Definition
ipv6-address.h:444
ns3::NetDeviceContainer
holds a vector of ns3::NetDevice pointers
Definition
net-device-container.h:32
ipv6-interface-container.h
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
internet
helper
ipv6-address-helper.h
Generated on Fri Nov 8 2024 13:59:00 for ns-3 by
1.11.0