A Discrete-Event Network Simulator
API
dhcp-client.cc
Go to the documentation of this file.
1/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2/*
3 * Copyright (c) 2011 UPB
4 * Copyright (c) 2017 NITK Surathkal
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Author: Radu Lupu <rlupu@elcom.pub.ro>
20 * Ankit Deepak <adadeepak8@gmail.com>
21 * Deepti Rajagopal <deeptir96@gmail.com>
22 *
23 *
24 */
25
26#include "ns3/ipv4.h"
27#include "ns3/log.h"
28#include "ns3/ipv4-static-routing-helper.h"
29#include "ns3/random-variable-stream.h"
30#include "ns3/pointer.h"
31#include "ns3/string.h"
32#include "ns3/ipv4-routing-table-entry.h"
33#include "dhcp-client.h"
34#include "dhcp-header.h"
35
36namespace ns3 {
37
38NS_LOG_COMPONENT_DEFINE ("DhcpClient");
40
41TypeId
43{
44 static TypeId tid = TypeId ("ns3::DhcpClient")
46 .AddConstructor<DhcpClient> ()
47 .SetGroupName ("Internet-Apps")
48 .AddAttribute ("RTRS", "Time for retransmission of Discover message",
49 TimeValue (Seconds (5)),
52 .AddAttribute ("Collect", "Time for which offer collection starts",
53 TimeValue (Seconds (5)),
56 .AddAttribute ("ReRequest", "Time after which request will be resent to next server",
57 TimeValue (Seconds (10)),
60 .AddAttribute ("Transactions",
61 "The possible value of transaction numbers",
62 StringValue ("ns3::UniformRandomVariable[Min=0.0|Max=1000000.0]"),
64 MakePointerChecker<RandomVariableStream> ())
65 .AddTraceSource ("NewLease",
66 "Get a NewLease",
68 "ns3::Ipv4Address::TracedCallback")
69 .AddTraceSource ("ExpireLease",
70 "A lease expires",
72 "ns3::Ipv4Address::TracedCallback");
73 return tid;
74}
75
77{
78 NS_LOG_FUNCTION (this);
80 m_socket = 0;
86 m_timeout = EventId ();
88 m_firstBoot = true;
89}
90
92{
93 NS_LOG_FUNCTION (this << netDevice);
94 m_device = netDevice;
96 m_socket = 0;
102 m_timeout = EventId ();
104 m_firstBoot = true;
105}
106
108{
109 NS_LOG_FUNCTION (this);
110}
111
113{
114 return m_device;
115}
116
117
119{
120 m_device = netDevice;
121}
122
124{
125 return m_server;
126}
127
128void
130{
131 NS_LOG_FUNCTION (this);
132
133 m_device = 0;
134
135 // Stop all the timers
141 m_timeout.Cancel ();
143
145}
146
147int64_t
149{
150 NS_LOG_FUNCTION (this << stream);
151 m_ran->SetStream (stream);
152 return 1;
153}
154
155void
157{
158 NS_LOG_FUNCTION (this);
159
160 m_remoteAddress = Ipv4Address ("255.255.255.255");
161 m_myAddress = Ipv4Address ("0.0.0.0");
162 m_gateway = Ipv4Address ("0.0.0.0");
163 Ptr<Ipv4> ipv4 = GetNode ()->GetObject<Ipv4> ();
164 uint32_t ifIndex = ipv4->GetInterfaceForDevice (m_device);
165
166 // We need to cleanup the type from the stored chaddr, or later we'll fail to compare it.
167 // Moreover, the length is always 16, because chaddr is 16 bytes.
168 Address myAddress = m_device->GetAddress ();
169 NS_LOG_INFO ("My address is " << myAddress);
170 uint8_t addr[Address::MAX_SIZE];
171 std::memset (addr, 0, Address::MAX_SIZE);
172 uint32_t len = myAddress.CopyTo (addr);
173 NS_ASSERT_MSG (len <= 16, "DHCP client can not handle a chaddr larger than 16 bytes");
174 m_chaddr.CopyFrom (addr, 16);
175 NS_LOG_INFO ("My m_chaddr is " << m_chaddr);
176
177 bool found = false;
178 for (uint32_t i = 0; i < ipv4->GetNAddresses (ifIndex); i++)
179 {
180 if (ipv4->GetAddress (ifIndex, i).GetLocal () == m_myAddress)
181 {
182 found = true;
183 }
184 }
185 if (!found)
186 {
187 ipv4->AddAddress (ifIndex, Ipv4InterfaceAddress (Ipv4Address ("0.0.0.0"),Ipv4Mask ("/0")));
188 }
189 if (!m_socket)
190 {
191 TypeId tid = TypeId::LookupByName ("ns3::UdpSocketFactory");
196 m_socket->Bind (local);
197 }
199
200 if (m_firstBoot)
201 {
202 m_device->AddLinkChangeCallback (MakeCallback (&DhcpClient::LinkStateHandler, this));
203 m_firstBoot = false;
204 }
205 Boot ();
206
207}
208
209void
211{
212 NS_LOG_FUNCTION (this);
213
214 // Stop all the timers
220 m_timeout.Cancel ();
222
223 Ptr<Ipv4> ipv4 = GetNode ()->GetObject<Ipv4> ();
224
225 int32_t ifIndex = ipv4->GetInterfaceForDevice (m_device);
226 for (uint32_t i = 0; i < ipv4->GetNAddresses (ifIndex); i++)
227 {
228 if (ipv4->GetAddress (ifIndex,i).GetLocal () == m_myAddress)
229 {
230 ipv4->RemoveAddress (ifIndex, i);
231 break;
232 }
233 }
234
236 m_socket->Close ();
237}
238
240{
241 NS_LOG_FUNCTION (this);
242
243 if (m_device->IsLinkUp ())
244 {
245 NS_LOG_INFO ("Link up at " << Simulator::Now ().As (Time::S));
248 }
249 else
250 {
251 NS_LOG_INFO ("Link down at " << Simulator::Now ().As (Time::S)); //reinitialization
252
253 // Stop all the timers
259 m_timeout.Cancel ();
261
262 m_socket->SetRecvCallback (MakeNullCallback<void, Ptr<Socket> > ()); //stop receiving on this socket !!!
263
264 Ptr<Ipv4> ipv4MN = GetNode ()->GetObject<Ipv4> ();
265 int32_t ifIndex = ipv4MN->GetInterfaceForDevice (m_device);
266
267 for (uint32_t i = 0; i < ipv4MN->GetNAddresses (ifIndex); i++)
268 {
269 if (ipv4MN->GetAddress (ifIndex,i).GetLocal () == m_myAddress)
270 {
271 ipv4MN->RemoveAddress (ifIndex, i);
272 break;
273 }
274 }
275
276 Ipv4StaticRoutingHelper ipv4RoutingHelper;
277 Ptr<Ipv4StaticRouting> staticRouting = ipv4RoutingHelper.GetStaticRouting (ipv4MN);
278 uint32_t i;
279 for (i = 0; i < staticRouting->GetNRoutes (); i++)
280 {
281 if (staticRouting->GetRoute (i).GetGateway () == m_gateway)
282 {
283 staticRouting->RemoveRoute (i);
284 break;
285 }
286 }
287
288 m_state = 0;
289 m_myAddress = Ipv4Address ("0.0.0.0");
290 m_gateway = Ipv4Address ("0.0.0.0");
291 }
292}
293
295{
296 NS_LOG_FUNCTION (this << socket);
297
298 Address from;
299 Ptr<Packet> packet = m_socket->RecvFrom (from);
300 DhcpHeader header;
301 if (packet->RemoveHeader (header) == 0)
302 {
303 return;
304 }
305 if (header.GetChaddr () != m_chaddr)
306 {
307 return;
308 }
309 if (m_state == WAIT_OFFER && header.GetType () == DhcpHeader::DHCPOFFER)
310 {
311 OfferHandler (header);
312 }
313 if (m_state == WAIT_ACK && header.GetType () == DhcpHeader::DHCPACK)
314 {
316 AcceptAck (header,from);
317 }
318 if (m_state == WAIT_ACK && header.GetType () == DhcpHeader::DHCPNACK)
319 {
321 Boot ();
322 }
323}
324
326{
327 NS_LOG_FUNCTION (this);
328
329 DhcpHeader header;
330 Ptr<Packet> packet;
331 packet = Create<Packet> ();
332 header.ResetOpt ();
333 m_tran = (uint32_t) (m_ran->GetValue ());
334 header.SetTran (m_tran);
336 header.SetTime ();
337 header.SetChaddr (m_chaddr);
338 packet->AddHeader (header);
339
340 if ((m_socket->SendTo (packet, 0, InetSocketAddress (Ipv4Address ("255.255.255.255"), DHCP_PEER_PORT))) >= 0)
341 {
342 NS_LOG_INFO ("DHCP DISCOVER sent" );
343 }
344 else
345 {
346 NS_LOG_INFO ("Error while sending DHCP DISCOVER to " << m_remoteAddress);
347 }
349 m_offered = false;
351}
352
354{
355 NS_LOG_FUNCTION (this << header);
356
357 m_offerList.push_back (header);
358 if (m_offered == false)
359 {
361 m_offered = true;
363 }
364}
365
367{
368 NS_LOG_FUNCTION (this);
369
370 if (m_offerList.empty ())
371 {
372 Boot ();
373 return;
374 }
375
376 DhcpHeader header = m_offerList.front ();
377 m_offerList.pop_front ();
378 m_lease = Time (Seconds (header.GetLease ()));
379 m_renew = Time (Seconds (header.GetRenew ()));
380 m_rebind = Time (Seconds (header.GetRebind ()));
381 m_offeredAddress = header.GetYiaddr ();
382 m_myMask = Ipv4Mask (header.GetMask ());
383 m_server = header.GetDhcps ();
384 m_gateway = header.GetRouter ();
385 m_offerList.clear ();
386 m_offered = false;
387 Request ();
388}
389
391{
392 NS_LOG_FUNCTION (this);
393
394 DhcpHeader header;
395 Ptr<Packet> packet;
396 if (m_state != REFRESH_LEASE)
397 {
398 packet = Create<Packet> ();
399 header.ResetOpt ();
401 header.SetTime ();
402 header.SetTran (m_tran);
403 header.SetReq (m_offeredAddress);
404 header.SetChaddr (m_chaddr);
405 packet->AddHeader (header);
406 m_socket->SendTo (packet, 0, InetSocketAddress (Ipv4Address ("255.255.255.255"), DHCP_PEER_PORT));
409 }
410 else
411 {
412 uint32_t addr = m_myAddress.Get ();
413 packet = Create<Packet> ((uint8_t*)&addr, sizeof(addr));
414 header.ResetOpt ();
415 m_tran = (uint32_t) (m_ran->GetValue ());
416 header.SetTran (m_tran);
417 header.SetTime ();
419 header.SetReq (m_myAddress);
421 header.SetChaddr (m_chaddr);
422 packet->AddHeader (header);
424 {
425 NS_LOG_INFO ("DHCP REQUEST sent");
426 }
427 else
428 {
429 NS_LOG_INFO ("Error while sending DHCP REQ to " << m_remoteAddress);
430 }
432 }
433}
434
436{
437 NS_LOG_FUNCTION (this << header << from);
438
441 m_timeout.Cancel ();
442
443 NS_LOG_INFO ("DHCP ACK received");
444 Ptr<Ipv4> ipv4 = GetNode ()->GetObject<Ipv4> ();
445 int32_t ifIndex = ipv4->GetInterfaceForDevice (m_device);
446
448 {
449 for (uint32_t i = 0; i < ipv4->GetNAddresses (ifIndex); i++)
450 {
451 if (ipv4->GetAddress (ifIndex,i).GetLocal () == m_myAddress)
452 {
453 NS_LOG_LOGIC ("Got a new address (" << m_offeredAddress << "), removing old one: " << m_myAddress);
454 ipv4->RemoveAddress (ifIndex, i);
455 break;
456 }
457 }
458
459 ipv4->AddAddress (ifIndex, Ipv4InterfaceAddress (m_offeredAddress, m_myMask));
460 ipv4->SetUp (ifIndex);
461 }
462
464 m_socket->Connect (remote);
466 {
468 if (m_myAddress != Ipv4Address ("0.0.0.0"))
469 {
471 }
472 }
474 Ipv4StaticRoutingHelper ipv4RoutingHelper;
475 Ptr<Ipv4StaticRouting> staticRouting = ipv4RoutingHelper.GetStaticRouting (ipv4);
476 if (m_gateway == Ipv4Address ("0.0.0.0"))
477 {
479 }
480
481 staticRouting->SetDefaultRoute (m_gateway, ifIndex, 0);
482
484 NS_LOG_INFO ("Current DHCP Server is " << m_remoteAddress);
485
486 m_offerList.clear ();
491}
492
494{
495 NS_LOG_FUNCTION (this);
496
500 m_timeout.Cancel ();
501
502 Ptr<Ipv4> ipv4MN = GetNode ()->GetObject<Ipv4> ();
503 int32_t ifIndex = ipv4MN->GetInterfaceForDevice (m_device);
504
505 for (uint32_t i = 0; i < ipv4MN->GetNAddresses (ifIndex); i++)
506 {
507 if (ipv4MN->GetAddress (ifIndex,i).GetLocal () == m_myAddress)
508 {
509 ipv4MN->RemoveAddress (ifIndex, i);
510 break;
511 }
512 }
514 Ipv4StaticRoutingHelper ipv4RoutingHelper;
515 Ptr<Ipv4StaticRouting> staticRouting = ipv4RoutingHelper.GetStaticRouting (ipv4MN);
516 uint32_t i;
517 for (i = 0; i < staticRouting->GetNRoutes (); i++)
518 {
519 if (staticRouting->GetRoute (i).GetGateway () == m_gateway)
520 {
521 staticRouting->RemoveRoute (i);
522 break;
523 }
524 }
526}
527
528} // Namespace ns3
a polymophic address class
Definition: address.h:91
uint32_t CopyFrom(const uint8_t *buffer, uint8_t len)
Definition: address.cc:101
uint32_t CopyTo(uint8_t buffer[MAX_SIZE]) const
Copy the address bytes into a buffer.
Definition: address.cc:82
The base class for all ns3 applications.
Definition: application.h:61
virtual void DoDispose(void)
Destructor implementation.
Definition: application.cc:83
Ptr< Node > GetNode() const
Definition: application.cc:104
EventId m_requestEvent
Address refresh event.
Definition: dhcp-client.h:172
Ipv4Address m_gateway
Address of the gateway.
Definition: dhcp-client.h:171
Ipv4Mask m_myMask
Mask of the address assigned.
Definition: dhcp-client.h:169
Time m_rebind
Store the rebind time of address.
Definition: dhcp-client.h:181
void SetDhcpClientNetDevice(Ptr< NetDevice > netDevice)
Set the NetDevice DHCP should work on.
Definition: dhcp-client.cc:118
void Select(void)
Selects an OFFER from m_offerList.
Definition: dhcp-client.cc:366
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: dhcp-client.cc:148
uint32_t m_tran
Stores the current transaction number to be used.
Definition: dhcp-client.h:188
void RemoveAndStart()
Remove the current DHCP information and restart the process.
Definition: dhcp-client.cc:493
virtual void StopApplication(void)
Application specific shutdown code.
Definition: dhcp-client.cc:210
Ptr< Socket > m_socket
Socket for remote communication.
Definition: dhcp-client.h:164
void LinkStateHandler(void)
Handles changes in LinkState.
Definition: dhcp-client.cc:239
bool m_firstBoot
First boot (used to add the link state change callback)
Definition: dhcp-client.h:162
Time m_collect
Time for which client should collect offers.
Definition: dhcp-client.h:185
Address m_chaddr
chaddr of the interface (stored as an Address for convenience).
Definition: dhcp-client.h:168
@ WAIT_OFFER
State of a client that waits for the offer.
Definition: dhcp-client.h:99
@ WAIT_ACK
State of a client that waits for acknowledgment.
Definition: dhcp-client.h:101
@ REFRESH_LEASE
State of a client that needs to refresh the lease.
Definition: dhcp-client.h:100
Ptr< NetDevice > m_device
NetDevice pointer.
Definition: dhcp-client.h:163
EventId m_timeout
The timeout period.
Definition: dhcp-client.h:177
virtual void DoDispose(void)
Destructor implementation.
Definition: dhcp-client.cc:129
Ptr< RandomVariableStream > m_ran
Uniform random variable for transaction ID.
Definition: dhcp-client.h:183
EventId m_rebindEvent
Message rebind event.
Definition: dhcp-client.h:175
static const int DHCP_PEER_PORT
DHCP server port.
Definition: dhcp-client.h:104
std::list< DhcpHeader > m_offerList
Stores all the offers given to the client.
Definition: dhcp-client.h:187
void Boot(void)
Sends DHCP DISCOVER and changes the client state to WAIT_OFFER.
Definition: dhcp-client.cc:325
Ipv4Address m_server
Address of the DHCP server.
Definition: dhcp-client.h:170
EventId m_nextOfferEvent
Message next offer event.
Definition: dhcp-client.h:176
bool m_offered
Specify if the client has got any offer.
Definition: dhcp-client.h:186
virtual ~DhcpClient()
Definition: dhcp-client.cc:107
void Request(void)
Sends the DHCP REQUEST message and changes the client state to WAIT_ACK.
Definition: dhcp-client.cc:390
Ipv4Address GetDhcpServer(void)
Get the IPv4Address of current DHCP server.
Definition: dhcp-client.cc:123
void OfferHandler(DhcpHeader header)
Stores DHCP offers in m_offerList.
Definition: dhcp-client.cc:353
TracedCallback< const Ipv4Address & > m_expiry
Trace of lease expire.
Definition: dhcp-client.h:190
Ptr< NetDevice > GetDhcpClientNetDevice(void)
Get the the NetDevice DHCP should work on.
Definition: dhcp-client.cc:112
TracedCallback< const Ipv4Address & > m_newLease
Trace of new lease.
Definition: dhcp-client.h:189
virtual void StartApplication(void)
Application specific startup code.
Definition: dhcp-client.cc:156
uint8_t m_state
State of the DHCP client.
Definition: dhcp-client.h:161
EventId m_discoverEvent
Message retransmission event.
Definition: dhcp-client.h:173
EventId m_refreshEvent
Message refresh event.
Definition: dhcp-client.h:174
Ipv4Address m_myAddress
Address assigned to the client.
Definition: dhcp-client.h:167
Time m_rtrs
Defining the time for retransmission.
Definition: dhcp-client.h:184
Time m_nextoffer
Time to try the next offer (if request gets no reply)
Definition: dhcp-client.h:182
Ipv4Address m_remoteAddress
Initially set to 255.255.255.255 to start DHCP.
Definition: dhcp-client.h:165
void NetHandler(Ptr< Socket > socket)
Handles incoming packets from the network.
Definition: dhcp-client.cc:294
void AcceptAck(DhcpHeader header, Address from)
Receives the DHCP ACK and configures IP address of the client.
Definition: dhcp-client.cc:435
Ipv4Address m_offeredAddress
Address offered to the client.
Definition: dhcp-client.h:166
Time m_renew
Store the renew time of address.
Definition: dhcp-client.h:180
static TypeId GetTypeId(void)
Get the type ID.
Definition: dhcp-client.cc:42
EventId m_collectEvent
Offer collection event.
Definition: dhcp-client.h:178
Time m_lease
Store the lease time of address.
Definition: dhcp-client.h:179
BOOTP header with DHCP messages supports the following options: Subnet Mask (1), Address Request (50)...
Definition: dhcp-header.h:82
void SetTime()
Set the time when message is sent.
Definition: dhcp-header.cc:106
Ipv4Address GetDhcps(void) const
Get the information about the DHCP server.
Definition: dhcp-header.cc:152
void ResetOpt()
Reset the BOOTP options.
Definition: dhcp-header.cc:247
uint32_t GetRebind(void) const
Return the Rebind time of the address.
Definition: dhcp-header.cc:242
void SetType(uint8_t type)
Set the type of BOOTP and DHCP messages.
Definition: dhcp-header.cc:74
@ DHCPACK
Code for DHCP ACK.
Definition: dhcp-header.h:120
@ DHCPOFFER
Code for DHCP Offer.
Definition: dhcp-header.h:118
@ DHCPDISCOVER
Code for DHCP Discover.
Definition: dhcp-header.h:117
@ DHCPREQ
Code for DHCP Request.
Definition: dhcp-header.h:119
@ DHCPNACK
Code for DHCP NACK.
Definition: dhcp-header.h:121
void SetTran(uint32_t tran)
Set the transaction ID.
Definition: dhcp-header.cc:96
uint32_t GetMask(void) const
Return the mask of the network.
Definition: dhcp-header.cc:182
uint8_t GetType(void) const
Return the type of DHCP message.
Definition: dhcp-header.cc:85
uint32_t GetLease(void) const
Return the lease time of the IPv4Address.
Definition: dhcp-header.cc:212
Ipv4Address GetRouter(void) const
Return the Ipv4Address of gateway to be used.
Definition: dhcp-header.cc:197
void SetReq(Ipv4Address addr)
Set the Ipv4Address requested by the client.
Definition: dhcp-header.cc:157
Ipv4Address GetYiaddr(void) const
Get the IPv4Address of the client.
Definition: dhcp-header.cc:137
Address GetChaddr(void)
Get the Address of the client.
Definition: dhcp-header.cc:125
void SetChaddr(Address addr)
Set the Address of the device.
Definition: dhcp-header.cc:111
uint32_t GetRenew(void) const
Return the Renewal time of the address.
Definition: dhcp-header.cc:227
An identifier for simulation events.
Definition: event-id.h:54
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
an Inet address class
Ipv4Address GetIpv4(void) const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
uint32_t Get(void) const
Get the host-order 32-bit IP address.
static Ipv4Address GetAny(void)
Access to the IPv4 forwarding table, interfaces, and configuration.
Definition: ipv4.h:77
a class to store IPv4 address information on an interface
a class to represent an Ipv4 address mask
Definition: ipv4-address.h:256
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
Definition: object.h:470
uint32_t RemoveHeader(Header &header)
Deserialize and remove the header from the internal buffer.
Definition: packet.cc:280
void AddHeader(const Header &header)
Add header to this packet.
Definition: packet.cc:256
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
void SetStream(int64_t stream)
Specifies the stream number for the RngStream.
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:555
static Time Now(void)
Return the current simulation virtual time.
Definition: simulator.cc:195
virtual Ptr< Packet > RecvFrom(uint32_t maxSize, uint32_t flags, Address &fromAddress)=0
Read a single packet from the socket and retrieve the sender address.
virtual bool SetAllowBroadcast(bool allowBroadcast)=0
Configure whether broadcast datagram transmissions are allowed.
virtual int Connect(const Address &address)=0
Initiate a connection to a remote host.
virtual void BindToNetDevice(Ptr< NetDevice > netdevice)
Bind a socket to specific device.
Definition: socket.cc:330
virtual int Close(void)=0
Close a socket.
void SetRecvCallback(Callback< void, Ptr< Socket > > receivedData)
Notify application when new data is available to be read.
Definition: socket.cc:128
static Ptr< Socket > CreateSocket(Ptr< Node > node, TypeId tid)
This method wraps the creation of sockets that is performed on a given node by a SocketFactory specif...
Definition: socket.cc:71
virtual int Bind(const Address &address)=0
Allocate a local endpoint for this socket.
virtual int SendTo(Ptr< Packet > p, uint32_t flags, const Address &toAddress)=0
Send data to a specified peer.
Hold variables of type string.
Definition: string.h:41
@ S
second
Definition: nstime.h:115
AttributeValue implementation for Time.
Definition: nstime.h:1309
a unique identifier for an interface.
Definition: type-id.h:59
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Definition: type-id.cc:829
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
Definition: assert.h:88
Ptr< const AttributeAccessor > MakePointerAccessor(T1 a1)
Definition: pointer.h:227
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Definition: nstime.h:1310
Callback< R, Args... > MakeNullCallback(void)
Definition: callback.h:697
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:206
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
Definition: log.h:290
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Definition: log.h:282
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1245
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:794
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
Definition: callback.h:661
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:522