15#include "ns3/dhcp-client.h"
16#include "ns3/dhcp-server.h"
19#include "ns3/loopback-net-device.h"
21#include "ns3/net-device-queue-interface.h"
22#include "ns3/traffic-control-helper.h"
23#include "ns3/traffic-control-layer.h"
24#include "ns3/uinteger.h"
70 NS_ASSERT_MSG(node,
"DhcpClientHelper: NetDevice is not not associated with any node -> fail");
74 "DhcpHelper: NetDevice is associated"
75 " with a node without IPv4 stack installed -> fail "
76 "(maybe need to use InternetStackHelper?)");
81 interface = ipv4->AddInterface(
netDevice);
83 NS_ASSERT_MSG(interface >= 0,
"DhcpHelper: Interface index not found");
85 ipv4->SetMetric(interface, 1);
86 ipv4->SetUp(interface);
103 NS_LOG_LOGIC(
"DhcpHelper - Installing default traffic control configuration ("
112 node->AddApplication(app);
133 NS_ASSERT_MSG(node,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
137 "DhcpHelper: NetDevice is associated"
138 " with a node without IPv4 stack installed -> fail "
139 "(maybe need to use InternetStackHelper?)");
144 interface = ipv4->AddInterface(
netDevice);
146 NS_ASSERT_MSG(interface >= 0,
"DhcpHelper: Interface index not found");
149 ipv4->AddAddress(interface,
ipv4Addr);
150 ipv4->SetMetric(interface, 1);
151 ipv4->SetUp(interface);
158 !tc->GetRootQueueDiscOnDevice(
netDevice))
168 NS_LOG_LOGIC(
"DhcpHelper - Installing default traffic control configuration ("
180 NS_ABORT_MSG(
"DhcpHelper: Fixed address can not conflict with a pool: "
187 node->AddApplication(app);
197 NS_ASSERT_MSG(node,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
201 "DhcpHelper: NetDevice is associated"
202 " with a node without IPv4 stack installed -> fail "
203 "(maybe need to use InternetStackHelper?)");
208 interface = ipv4->AddInterface(
netDevice);
210 NS_ASSERT_MSG(interface >= 0,
"DhcpHelper: Interface index not found");
213 ipv4->AddAddress(interface,
ipv4Addr);
214 ipv4->SetMetric(interface, 1);
215 ipv4->SetUp(interface);
216 retval.Add(ipv4, interface);
223 !tc->GetRootQueueDiscOnDevice(
netDevice))
233 NS_LOG_LOGIC(
"DhcpHelper - Installing default traffic control configuration ("
243 if (addr.
Get() >=
iter->first.Get() && addr.
Get() <=
iter->second.Get())
245 NS_ABORT_MSG(
"DhcpHelper: Fixed address can not conflict with a pool: "
246 << addr <<
" is in [" <<
iter->first <<
", " <<
iter->second <<
"]");
holds a vector of ns3::Application pointers.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Hold a value for an Attribute.
Implements the functionality of a DHCP client.
static TypeId GetTypeId()
Get the type ID.
ObjectFactory m_serverFactory
DHCP server factory.
std::list< std::pair< Ipv4Address, Ipv4Address > > m_addressPools
list of address pools.
std::list< Ipv4Address > m_fixedAddresses
list of fixed addresses already allocated.
Ipv4InterfaceContainer InstallFixedAddress(Ptr< NetDevice > netDevice, Ipv4Address addr, Ipv4Mask mask)
Assign a fixed IP addresses to a net device.
ApplicationContainer InstallDhcpServer(Ptr< NetDevice > netDevice, Ipv4Address serverAddr, Ipv4Address poolAddr, Ipv4Mask poolMask, Ipv4Address minAddr, Ipv4Address maxAddr, Ipv4Address gateway=Ipv4Address())
Install DHCP server of a node / NetDevice.
ApplicationContainer InstallDhcpClient(Ptr< NetDevice > netDevice) const
Install DHCP client of a nodes / NetDevice.
void SetClientAttribute(std::string name, const AttributeValue &value)
Set DHCP client attributes.
void SetServerAttribute(std::string name, const AttributeValue &value)
Set DHCP server attributes.
Ptr< Application > InstallDhcpClientPriv(Ptr< NetDevice > netDevice) const
Function to install DHCP client on a node.
ObjectFactory m_clientFactory
DHCP client factory.
Implements the functionality of a DHCP server.
static TypeId GetTypeId()
Get the type ID.
Ipv4 addresses are stored in host order in this class.
uint32_t Get() const
Get the host-order 32-bit IP address.
AttributeValue implementation for Ipv4Address.
Access to the IPv4 forwarding table, interfaces, and configuration.
a class to store IPv4 address information on an interface
holds a vector of std::pair of Ptr<Ipv4> and interface index.
a class to represent an Ipv4 address mask
AttributeValue implementation for Ipv4Mask.
holds a vector of ns3::NetDevice pointers
Network device transmission queue interface.
std::size_t GetNTxQueues() const
Get the number of device transmission queues.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Smart pointer class similar to boost::intrusive_ptr.
Build a set of QueueDisc objects.
static TrafficControlHelper Default(std::size_t nTxQueues=1)
The Traffic Control layer aims at introducing an equivalent of the Linux Traffic Control infrastructu...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static unsigned int value(char c)