26 #include "ns3/dhcp-server.h"
27 #include "ns3/dhcp-client.h"
28 #include "ns3/uinteger.h"
29 #include "ns3/names.h"
31 #include "ns3/loopback-net-device.h"
32 #include "ns3/traffic-control-layer.h"
33 #include "ns3/traffic-control-helper.h"
34 #include "ns3/net-device-queue-interface.h"
79 NS_ASSERT_MSG (node != 0,
"DhcpClientHelper: NetDevice is not not associated with any node -> fail");
83 " with a node without IPv4 stack installed -> fail "
84 "(maybe need to use InternetStackHelper?)");
86 int32_t
interface = ipv4->GetInterfaceForDevice (netDevice);
89 interface = ipv4->AddInterface (netDevice);
91 NS_ASSERT_MSG (interface >= 0,
"DhcpHelper: Interface index not found");
93 ipv4->SetMetric (interface, 1);
94 ipv4->SetUp (interface);
100 if (tc && DynamicCast<LoopbackNetDevice> (netDevice) == 0 && tc->GetRootQueueDiscOnDevice (netDevice) == 0)
109 std::size_t nTxQueues = ndqi->GetNTxQueues ();
110 NS_LOG_LOGIC (
"DhcpHelper - Installing default traffic control configuration ("
111 << nTxQueues <<
" device queue(s))");
118 app->SetDhcpClientNetDevice (netDevice);
136 NS_ASSERT_MSG (node != 0,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
140 " with a node without IPv4 stack installed -> fail "
141 "(maybe need to use InternetStackHelper?)");
143 int32_t
interface = ipv4->GetInterfaceForDevice (netDevice);
146 interface = ipv4->AddInterface (netDevice);
148 NS_ASSERT_MSG (interface >= 0,
"DhcpHelper: Interface index not found");
151 ipv4->AddAddress (interface, ipv4Addr);
152 ipv4->SetMetric (interface, 1);
153 ipv4->SetUp (interface);
159 if (tc && DynamicCast<LoopbackNetDevice> (netDevice) == 0 && tc->GetRootQueueDiscOnDevice (netDevice) == 0)
168 std::size_t nTxQueues = ndqi->GetNTxQueues ();
169 NS_LOG_LOGIC (
"DhcpHelper - Installing default traffic control configuration ("
170 << nTxQueues <<
" device queue(s))");
177 std::list<Ipv4Address>::iterator iter;
180 if (iter->Get () >= minAddr.
Get () && iter->Get () <= maxAddr.
Get ())
182 NS_ABORT_MSG (
"DhcpHelper: Fixed address can not conflict with a pool: " << *iter <<
" is in [" << minAddr <<
", " << maxAddr <<
"]");
197 NS_ASSERT_MSG (node != 0,
"DhcpHelper: NetDevice is not not associated with any node -> fail");
201 " with a node without IPv4 stack installed -> fail "
202 "(maybe need to use InternetStackHelper?)");
204 int32_t
interface = ipv4->GetInterfaceForDevice (netDevice);
207 interface = ipv4->AddInterface (netDevice);
209 NS_ASSERT_MSG (interface >= 0,
"DhcpHelper: Interface index not found");
212 ipv4->AddAddress (interface, ipv4Addr);
213 ipv4->SetMetric (interface, 1);
214 ipv4->SetUp (interface);
215 retval.
Add (ipv4, interface);
221 if (tc && DynamicCast<LoopbackNetDevice> (netDevice) == 0 && tc->GetRootQueueDiscOnDevice (netDevice) == 0)
230 std::size_t nTxQueues = ndqi->GetNTxQueues ();
231 NS_LOG_LOGIC (
"DhcpHelper - Installing default traffic control configuration ("
232 << nTxQueues <<
" device queue(s))");
239 std::list<std::pair<Ipv4Address, Ipv4Address> >::iterator iter;
242 if (addr.
Get () >= iter->first.Get () && addr.
Get () <= iter->second.Get ())
244 NS_ABORT_MSG (
"DhcpHelper: Fixed address can not conflict with a pool: " << 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(void)
Get the type ID.
ObjectFactory m_serverFactory
DHCP server factory.
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.
std::list< std::pair< Ipv4Address, Ipv4Address > > m_addressPools
list of address pools.
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(void)
Get the type ID.
Ipv4 addresses are stored in host order in this class.
uint32_t Get(void) 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.
void Add(const Ipv4InterfaceContainer &other)
Concatenate the entries in the other container with ours.
a class to represent an Ipv4 address mask
AttributeValue implementation for Ipv4Mask.
holds a vector of ns3::NetDevice pointers
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin(void) const
Get an iterator which refers to the first NetDevice in the container.
virtual Ptr< Node > GetNode(void) const =0
Network device transmission queue interface.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
Ptr< Object > Create(void) const
Create an Object instance of the configured TypeId.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Build a set of QueueDisc objects.
QueueDiscContainer Install(NetDeviceContainer c)
static TrafficControlHelper Default(std::size_t nTxQueues=1)
Introspection did not find any typical Config paths.
#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.
Every class exported by the ns3 library is enclosed in the ns3 namespace.