19 #include "ns3/assert.h"
23 #include "ns3/net-device.h"
25 #include "ns3/ipv4-address-generator.h"
26 #include "ns3/simulator.h"
56 SetBase (network, mask, address);
75 "Ipv4AddressHelper::SetBase(): Inconsistent network and mask");
85 "Ipv4AddressHelper::SetBase(): Unreasonable address length");
108 "Ipv4AddressHelper::NewAddress(): Address overflow");
135 for (uint32_t i = 0; i < c.
GetN (); ++i) {
139 NS_ASSERT_MSG (node,
"Ipv4AddressHelper::Assign(): NetDevice is not not associated "
140 "with any node -> fail");
143 NS_ASSERT_MSG (ipv4,
"Ipv4AddressHelper::Assign(): NetDevice is associated"
144 " with a node without IPv4 stack installed -> fail "
145 "(maybe need to use InternetStackHelper?)");
147 int32_t
interface = ipv4->GetInterfaceForDevice (device);
150 interface = ipv4->AddInterface (device);
152 NS_ASSERT_MSG (interface >= 0,
"Ipv4AddressHelper::Assign(): "
153 "Interface index not found");
156 ipv4->AddAddress (interface, ipv4Addr);
157 ipv4->SetMetric (interface, 1);
158 ipv4->SetUp (interface);
159 retval.
Add (ipv4, interface);
170 for (uint32_t i = 0; i <
N_BITS; ++i)
180 NS_ASSERT_MSG (
false,
"Ipv4AddressHelper::NumAddressBits(): Bad Mask");
smart pointer class similar to boost::intrusive_ptr
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
a class to represent an Ipv4 address mask
#define NS_LOG_COMPONENT_DEFINE(name)
#define NS_LOG_FUNCTION_NOARGS()
Ipv4Address NewAddress(void)
Increment the IP address counter used to allocate IP addresses.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
Ipv4AddressHelper()
Construct a helper class to make life easier while doing simple IPv4 address assignment in scripts...
holds a vector of ns3::NetDevice pointers
#define NS_LOG_LOGIC(msg)
Access to the Ipv4 forwarding table, interfaces, and configuration.
static bool AddAllocated(const Ipv4Address addr)
#define NS_ASSERT_MSG(condition, message)
Ipv4 addresses are stored in host order in this class.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
a class to store IPv4 address information on an interface
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
void Add(Ipv4InterfaceContainer other)
Ptr< T > GetObject(void) const
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
uint32_t NumAddressBits(uint32_t maskbits) const