|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
19 #include "ns3/assert.h"
23 #include "ns3/net-device.h"
24 #include "ns3/loopback-net-device.h"
26 #include "ns3/ipv4-address-generator.h"
27 #include "ns3/simulator.h"
28 #include "ns3/traffic-control-helper.h"
29 #include "ns3/traffic-control-layer.h"
30 #include "ns3/net-device-queue-interface.h"
79 "Ipv4AddressHelper::SetBase(): Inconsistent network and mask");
89 "Ipv4AddressHelper::SetBase(): Unreasonable address length");
112 "Ipv4AddressHelper::NewAddress(): Address overflow");
139 for (uint32_t i = 0; i < c.
GetN (); ++i) {
143 NS_ASSERT_MSG (node,
"Ipv4AddressHelper::Assign(): NetDevice is not not associated "
144 "with any node -> fail");
147 NS_ASSERT_MSG (ipv4,
"Ipv4AddressHelper::Assign(): NetDevice is associated"
148 " with a node without IPv4 stack installed -> fail "
149 "(maybe need to use InternetStackHelper?)");
151 int32_t
interface = ipv4->GetInterfaceForDevice (device);
154 interface = ipv4->AddInterface (device);
156 NS_ASSERT_MSG (interface >= 0,
"Ipv4AddressHelper::Assign(): "
157 "Interface index not found");
160 ipv4->AddAddress (interface, ipv4Addr);
161 ipv4->SetMetric (interface, 1);
162 ipv4->SetUp (interface);
163 retval.
Add (ipv4, interface);
169 if (tc && DynamicCast<LoopbackNetDevice> (device) == 0 && tc->GetRootQueueDiscOnDevice (device) == 0)
178 std::size_t nTxQueues = ndqi->GetNTxQueues ();
179 NS_LOG_LOGIC (
"Installing default traffic control configuration ("
180 << nTxQueues <<
" device queue(s))");
195 for (uint32_t i = 0; i <
N_BITS; ++i)
205 NS_ASSERT_MSG (
false,
"Ipv4AddressHelper::NumAddressBits(): Bad Mask");
holds a vector of ns3::NetDevice pointers
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ipv4Address NewNetwork(void)
Increment the network number and reset the IP address counter to the base value provided in the SetBa...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t Get(void) const
Get the host-order 32-bit IP mask.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
uint32_t m_address
address
const uint32_t N_BITS
number of bits in a IPv4 address
uint32_t Get(void) const
Get the host-order 32-bit IP address.
Ipv4 addresses are stored in host order in this class.
Ipv4AddressHelper()
Construct a helper class to make life easier while doing simple IPv4 address assignment in scripts.
uint32_t NumAddressBits(uint32_t maskbits) const
Returns the number of address bits (hostpart) for a given netmask.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Access to the IPv4 forwarding table, interfaces, and configuration.
QueueDiscContainer Install(NetDeviceContainer c)
a class to store IPv4 address information on an interface
virtual Ptr< Node > GetNode(void) const =0
holds a vector of std::pair of Ptr<Ipv4> and interface index.
uint32_t m_mask
network mask
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
uint32_t m_base
base address
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
static bool AddAllocated(const Ipv4Address addr)
Add the Ipv4Address to the list of IPv4 entries.
Network device transmission queue interface.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
uint32_t m_network
network address
Introspection did not find any typical Config paths.
Build a set of QueueDisc objects.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
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 represent an Ipv4 address mask
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
uint32_t m_max
maximum allowed address
static TrafficControlHelper Default(std::size_t nTxQueues=1)
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Ipv4Address NewAddress(void)
Increment the IP address counter used to allocate IP addresses.
uint32_t m_shift
shift, equivalent to the number of bits in the hostpart