28 #include "ns3/assert.h"
29 #include "ns3/boolean.h"
30 #include "ns3/global-value.h"
32 #include "ns3/object-vector.h"
33 #include "ns3/simulator.h"
34 #include "ns3/uinteger.h"
50 "A global switch to enable all checksums for all protocols",
60 .SetGroupName(
"Network")
61 .AddConstructor<
Node>()
62 .AddAttribute(
"DeviceList",
63 "The list of devices associated to this Node.",
66 MakeObjectVectorChecker<NetDevice>())
67 .AddAttribute(
"ApplicationList",
68 "The list of applications associated to this Node.",
71 MakeObjectVectorChecker<Application>())
73 "The id (unique integer) of this Node.",
77 MakeUintegerChecker<uint32_t>())
80 "The systemId of this node: a unique integer used for parallel simulations.",
84 MakeUintegerChecker<uint32_t>());
143 device->SetNode(
this);
144 device->SetIfIndex(index);
156 "Device index " << index <<
" is out of range (only have " <<
m_devices.size()
184 "Application index " << index <<
" is out of range (only have "
226 device->Initialize();
239 uint16_t protocolType,
243 NS_LOG_FUNCTION(
this << &handler << protocolType << device << promiscuous);
276 if (i->handler.IsEqual(handler))
301 NS_LOG_FUNCTION(
this << device << packet << protocol << &from << &to << packetType);
316 device->GetAddress(),
330 NS_LOG_FUNCTION(
this << device << packet << protocol << &from << &to << packetType
333 "Received packet with erroneous context ; "
334 <<
"make sure the channels in use are correctly updating events context "
335 <<
"when transferring events from one node to another.");
336 NS_LOG_DEBUG(
"Node " <<
GetId() <<
" ReceiveFromDevice: dev " << device->GetIfIndex()
337 <<
" (type=" << device->GetInstanceTypeId().GetName() <<
") Packet UID "
343 if (!i->device || (i->device == device))
345 if (i->protocol == 0 || i->protocol == protocol)
347 if (promiscuous == i->promiscuous)
349 i->handler(device, packet, protocol, from, to, packetType);
376 if ((*i).IsEqual(listener))
a polymophic address class
void SetNode(Ptr< Node > node)
Hold a so-called 'global value'.
void GetValue(AttributeValue &value) const
Get the value.
PacketType
Packet types are used as they are in Linux.
void UnregisterProtocolHandler(ProtocolHandler handler)
uint32_t GetSystemId() const
void DoDispose() override
The dispose method.
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.
static GlobalValue g_checksumEnabled
DeviceAdditionListenerList m_deviceAdditionListeners
Device addition listeners in the node.
std::vector< Ptr< Application > > m_applications
Applications associated to this node.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t m_id
Node id for this node.
uint32_t GetNDevices() const
uint32_t GetNApplications() const
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
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.
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.
uint32_t m_sid
System id for this node.
ProtocolHandlerList m_handlers
Protocol handlers in the node.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void Construct()
Finish node's construction by setting the correct node ID.
static TypeId GetTypeId()
Get the type ID.
Time GetLocalTime() const
In the future, ns3 nodes may have clock that returned a local time different from the virtual time Si...
void RegisterDeviceAdditionListener(DeviceAdditionListener listener)
void DoInitialize() override
Initialize() implementation.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void NotifyDeviceAdded(Ptr< NetDevice > device)
Notifies all the DeviceAdditionListener about the new device added.
static bool ChecksumEnabled()
void UnregisterDeviceAdditionListener(DeviceAdditionListener listener)
std::vector< Ptr< NetDevice > > m_devices
Devices associated to this node.
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
static uint32_t Add(Ptr< Node > node)
A base class which provides memory management and object aggregation.
void Initialize()
Invoke DoInitialize on all Objects aggregated to this one.
virtual void DoInitialize()
Initialize() implementation.
void Dispose()
Dispose of this Object.
virtual void DoDispose()
Destructor implementation.
uint64_t GetUid() const
Returns the packet's Uid.
Smart pointer class similar to boost::intrusive_ptr.
static void ScheduleWithContext(uint32_t context, const Time &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static Time Now()
Return the current simulation virtual time.
static uint32_t GetContext()
Get the current simulation context.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
@ ATTR_GET
The attribute can be read.
@ ATTR_SET
The attribute can be written.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#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_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker()
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...
ObjectPtrContainerValue ObjectVectorValue
ObjectVectorValue is an alias for ObjectPtrContainerValue.
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
bool promiscuous
true if it is a promiscuous handler
uint16_t protocol
the protocol number
Ptr< NetDevice > device
the NetDevice
ProtocolHandler handler
the protocol handler