26 #include "ns3/packet.h" 27 #include "ns3/simulator.h" 28 #include "ns3/object-vector.h" 29 #include "ns3/uinteger.h" 31 #include "ns3/assert.h" 32 #include "ns3/global-value.h" 33 #include "ns3/boolean.h" 45 "A global switch to enable all checksums for all protocols",
54 .SetGroupName(
"Network")
55 .AddConstructor<
Node> ()
56 .AddAttribute (
"DeviceList",
"The list of devices associated to this Node.",
59 MakeObjectVectorChecker<NetDevice> ())
60 .AddAttribute (
"ApplicationList",
"The list of applications associated to this Node.",
63 MakeObjectVectorChecker<Application> ())
64 .AddAttribute (
"Id",
"The id (unique integer) of this Node.",
68 MakeUintegerChecker<uint32_t> ())
69 .AddAttribute (
"SystemId",
"The systemId of this node: a unique integer used for parallel simulations.",
73 MakeUintegerChecker<uint32_t> ())
133 device->SetNode (
this);
134 device->SetIfIndex (index);
146 " is out of range (only have " <<
m_devices.size () <<
" devices).");
172 " is out of range (only have " <<
m_applications.size () <<
" applications).");
214 device->Initialize ();
228 uint16_t protocolType,
232 NS_LOG_FUNCTION (
this << &handler << protocolType << device << promiscuous);
264 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
267 if (i->handler.IsEqual (handler))
288 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType);
304 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType << promiscuous);
306 "make sure the channels in use are correctly updating events context " <<
307 "when transferring events from one node to another.");
309 << device->GetIfIndex () <<
" (type=" << device->GetInstanceTypeId ().GetName ()
310 <<
") Packet UID " << packet->
GetUid ());
313 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
316 if (i->device == 0 ||
317 (i->device != 0 && i->device == device))
319 if (i->protocol == 0 ||
320 i->protocol == protocol)
322 if (promiscuous == i->promiscuous)
324 i->handler (device, packet, protocol, from, to, packetType);
351 if ((*i).IsEqual (listener))
void Dispose(void)
Dispose of this Object.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
virtual void DoInitialize(void)
Initialize() implementation.
uint64_t GetUid(void) const
Returns the packet's Uid.
Simulation virtual time values and global simulation resolution.
void GetValue(AttributeValue &value) const
Get the value.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
AttributeValue implementation for Boolean.
uint32_t GetId(void) const
virtual void DoInitialize(void)
Initialize() implementation.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
NS_ASSERT_MSG(false, "Ipv4AddressGenerator::MaskToIndex(): Impossible")
DeviceAdditionListenerList m_deviceAdditionListeners
Device addition listeners in the node.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static bool ChecksumEnabled(void)
void NotifyDeviceAdded(Ptr< NetDevice > device)
Notifies all the DeviceAdditionListener about the new device added.
static uint32_t GetContext(void)
Get the current simulation context.
ProtocolHandler handler
the protocol handler
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
std::vector< Ptr< NetDevice > > m_devices
Devices associated to this node.
virtual void DoDispose(void)
Destructor implementation.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Hold a so-called 'global value'.
void UnregisterProtocolHandler(ProtocolHandler handler)
a polymophic address class
The attribute can be read.
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.
static GlobalValue g_checksumEnabled
A global switch to enable all checksums for all protocols.
virtual void DoDispose(void)
The dispose method.
Ptr< NetDevice > device
the NetDevice
Hold an unsigned integer type.
static uint32_t Add(Ptr< Node > node)
Ptr< Application > GetApplication(uint32_t index) const
Retrieve the index-th Application associated to this node.
uint16_t protocol
the protocol number
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
Time GetLocalTime(void) const
In the future, ns3 nodes may have clock that returned a local time different from the virtual time Si...
ProtocolHandlerList m_handlers
Protocol handlers in the node.
void RegisterDeviceAdditionListener(DeviceAdditionListener listener)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeBooleanChecker(void)
uint32_t GetSystemId(void) const
The attribute can be written.
void SetNode(Ptr< Node > node)
std::vector< Ptr< Application > > m_applications
Applications associated to this node.
static Time Now(void)
Return the current simulation virtual time.
uint32_t m_id
Node id for this node.
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
static TypeId GetTypeId(void)
Get the type ID.
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.
static void ScheduleWithContext(uint32_t context, Time const &delay, MEM mem_ptr, OBJ obj)
Schedule an event with the given context.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
void UnregisterDeviceAdditionListener(DeviceAdditionListener listener)
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Time Seconds(double value)
Construct a Time in the indicated unit.
uint32_t GetNApplications(void) const
A base class which provides memory management and object aggregation.
PacketType
Packet types are used as they are in Linux.
Container for a set of ns3::Object pointers.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
void Construct(void)
Finish node's construction by setting the correct node ID.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
uint32_t GetNDevices(void) const
bool promiscuous
true if it is a promiscuous handler
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.