A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
node.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2006 Georgia Tech Research Corporation, INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Authors: George F. Riley<riley@ece.gatech.edu>
18 * Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19 */
20#ifndef NODE_H
21#define NODE_H
22
23#include "net-device.h"
24
25#include "ns3/callback.h"
26#include "ns3/object.h"
27#include "ns3/ptr.h"
28
29#include <vector>
30
31namespace ns3
32{
33
34class Application;
35class Packet;
36class Address;
37class Time;
38
56class Node : public Object
57{
58 public:
63 static TypeId GetTypeId();
64
65 Node();
69 Node(uint32_t systemId);
70
71 ~Node() override;
72
79 uint32_t GetId() const;
80
89 Time GetLocalTime() const;
90
95 uint32_t GetSystemId() const;
96
111 Ptr<NetDevice> GetDevice(uint32_t index) const;
116 uint32_t GetNDevices() const;
117
133
138
158 typedef Callback<void,
161 uint16_t,
162 const Address&,
163 const Address&,
180 uint16_t protocolType,
181 Ptr<NetDevice> device,
182 bool promiscuous = false);
190
210
214 static bool ChecksumEnabled();
215
216 protected:
222 void DoDispose() override;
223 void DoInitialize() override;
224
225 private:
231
241 Ptr<const Packet> packet,
242 uint16_t protocol,
243 const Address& from);
255 Ptr<const Packet> packet,
256 uint16_t protocol,
257 const Address& from,
258 const Address& to,
259 NetDevice::PacketType packetType);
273 uint16_t protocol,
274 const Address& from,
275 const Address& to,
276 NetDevice::PacketType packetType,
277 bool promisc);
278
282 void Construct();
283
289 {
292 uint16_t protocol;
294 };
295
297 typedef std::vector<Node::ProtocolHandlerEntry> ProtocolHandlerList;
299 typedef std::vector<DeviceAdditionListener> DeviceAdditionListenerList;
300
303 std::vector<Ptr<NetDevice>> m_devices;
304 std::vector<Ptr<Application>> m_applications;
307};
308
309} // namespace ns3
310
311#endif /* NODE_H */
a polymophic address class
Definition: address.h:101
Callback template class.
Definition: callback.h:438
PacketType
Packet types are used as they are in Linux.
Definition: net-device.h:300
A network Node.
Definition: node.h:57
void UnregisterProtocolHandler(ProtocolHandler handler)
Definition: node.cc:271
std::vector< DeviceAdditionListener > DeviceAdditionListenerList
Typedef for NetDevice addition listeners container.
Definition: node.h:299
uint32_t GetSystemId() const
Definition: node.cc:131
void DoDispose() override
The dispose method.
Definition: node.cc:197
bool PromiscReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Receive a packet from a device in promiscuous mode.
Definition: node.cc:294
DeviceAdditionListenerList m_deviceAdditionListeners
Device addition listeners in the node.
Definition: node.h:306
std::vector< Ptr< Application > > m_applications
Applications associated to this node.
Definition: node.h:304
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
Definition: node.cc:138
uint32_t m_id
Node id for this node.
Definition: node.h:301
uint32_t GetNDevices() const
Definition: node.cc:162
Callback< void, Ptr< NetDevice >, Ptr< const Packet >, uint16_t, const Address &, const Address &, NetDevice::PacketType > ProtocolHandler
A protocol handler.
Definition: node.h:165
uint32_t GetNApplications() const
Definition: node.cc:190
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
Definition: node.cc:180
bool ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc)
Receive a packet from a device.
Definition: node.cc:322
bool NonPromiscReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet > packet, uint16_t protocol, const Address &from)
Receive a packet from a device in non-promiscuous mode.
Definition: node.cc:306
std::vector< Node::ProtocolHandlerEntry > ProtocolHandlerList
Typedef for protocol handlers container.
Definition: node.h:297
uint32_t m_sid
System id for this node.
Definition: node.h:302
ProtocolHandlerList m_handlers
Protocol handlers in the node.
Definition: node.h:305
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Definition: node.cc:169
void Construct()
Finish node's construction by setting the correct node ID.
Definition: node.cc:105
static TypeId GetTypeId()
Get the type ID.
Definition: node.cc:55
Callback< void, Ptr< NetDevice > > DeviceAdditionListener
A callback invoked whenever a device is added to a node.
Definition: node.h:194
uint32_t GetId() const
Definition: node.cc:117
Node()
Definition: node.cc:88
Time GetLocalTime() const
In the future, ns3 nodes may have clock that returned a local time different from the virtual time Si...
Definition: node.cc:124
void RegisterDeviceAdditionListener(DeviceAdditionListener listener)
Definition: node.cc:359
void DoInitialize() override
Initialize() implementation.
Definition: node.cc:220
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
Definition: node.cc:152
~Node() override
Definition: node.cc:111
void NotifyDeviceAdded(Ptr< NetDevice > device)
Notifies all the DeviceAdditionListener about the new device added.
Definition: node.cc:385
static bool ChecksumEnabled()
Definition: node.cc:285
void UnregisterDeviceAdditionListener(DeviceAdditionListener listener)
Definition: node.cc:371
std::vector< Ptr< NetDevice > > m_devices
Devices associated to this node.
Definition: node.h:303
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
Definition: node.cc:238
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
Definition: nstime.h:839
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Protocol handler entry.
Definition: node.h:289
bool promiscuous
true if it is a promiscuous handler
Definition: node.h:293
uint16_t protocol
the protocol number
Definition: node.h:292
Ptr< NetDevice > device
the NetDevice
Definition: node.h:291
ProtocolHandler handler
the protocol handler
Definition: node.h:290