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"
47 "A global switch to enable all checksums for all protocols",
56 .SetGroupName(
"Network")
57 .AddConstructor<
Node> ()
58 .AddAttribute (
"DeviceList",
"The list of devices associated to this Node.",
61 MakeObjectVectorChecker<NetDevice> ())
62 .AddAttribute (
"ApplicationList",
"The list of applications associated to this Node.",
65 MakeObjectVectorChecker<Application> ())
66 .AddAttribute (
"Id",
"The id (unique integer) of this Node.",
70 MakeUintegerChecker<uint32_t> ())
71 .AddAttribute (
"SystemId",
"The systemId of this node: a unique integer used for parallel simulations.",
75 MakeUintegerChecker<uint32_t> ())
148 " is out of range (only have " <<
m_devices.size () <<
" devices).");
174 " is out of range (only have " <<
m_applications.size () <<
" applications).");
230 uint16_t protocolType,
234 NS_LOG_FUNCTION (
this << &handler << protocolType << device << promiscuous);
266 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
269 if (i->handler.IsEqual (handler))
290 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType);
306 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType << promiscuous);
308 "make sure the channels in use are correctly updating events context " <<
309 "when transferring events from one node to another.");
312 <<
") Packet UID " << packet->
GetUid ());
315 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
318 if (i->device == 0 ||
319 (i->device != 0 && i->device == device))
321 if (i->protocol == 0 ||
322 i->protocol == protocol)
324 if (promiscuous == i->promiscuous)
326 i->handler (device, packet, protocol, from, to, packetType);
353 if ((*i).IsEqual (listener))
a polymophic address class
void SetNode(Ptr< Node > node)
AttributeValue implementation for Boolean.
Hold a so-called 'global value'.
void GetValue(AttributeValue &value) const
Get the value.
virtual void SetIfIndex(const uint32_t index)=0
virtual void SetPromiscReceiveCallback(PromiscReceiveCallback cb)=0
virtual void SetNode(Ptr< Node > node)=0
virtual Address GetAddress(void) const =0
virtual uint32_t GetIfIndex(void) const =0
virtual void SetReceiveCallback(ReceiveCallback cb)=0
PacketType
Packet types are used as they are in Linux.
static bool ChecksumEnabled(void)
void UnregisterProtocolHandler(ProtocolHandler 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.
static GlobalValue g_checksumEnabled
DeviceAdditionListenerList m_deviceAdditionListeners
Device addition listeners in the node.
uint32_t GetId(void) const
std::vector< Ptr< Application > > m_applications
Applications associated to this node.
void Construct(void)
Finish node's construction by setting the correct node ID.
uint32_t AddDevice(Ptr< NetDevice > device)
Associate a NetDevice to this node.
uint32_t m_id
Node id for this node.
uint32_t GetNApplications(void) 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.
virtual void DoDispose(void)
The dispose method.
uint32_t m_sid
System id for this node.
Time GetLocalTime(void) const
In the future, ns3 nodes may have clock that returned a local time different from the virtual time Si...
virtual void DoInitialize(void)
Initialize() implementation.
uint32_t GetNDevices(void) const
ProtocolHandlerList m_handlers
Protocol handlers in the node.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
void RegisterDeviceAdditionListener(DeviceAdditionListener listener)
static TypeId GetTypeId(void)
Get the type ID.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
uint32_t GetSystemId(void) const
void NotifyDeviceAdded(Ptr< NetDevice > device)
Notifies all the DeviceAdditionListener about the new device added.
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.
virtual TypeId GetInstanceTypeId(void) const
Get the most derived TypeId for this Object.
virtual void DoDispose(void)
Destructor implementation.
virtual void DoInitialize(void)
Initialize() implementation.
void Initialize(void)
Invoke DoInitialize on all Objects aggregated to this one.
void Dispose(void)
Dispose of this Object.
Container for a set of ns3::Object pointers.
uint64_t GetUid(void) const
Returns the packet's Uid.
static void ScheduleWithContext(uint32_t context, Time const &delay, FUNC f, Ts &&... args)
Schedule an event with the given context.
static uint32_t GetContext(void)
Get the current simulation context.
static Time Now(void)
Return the current simulation virtual time.
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.
std::string GetName(void) const
Get the name.
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...
Ptr< const AttributeChecker > MakeBooleanChecker(void)
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
#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.
Callback< R, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
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