25 #include "ns3/packet.h"
26 #include "ns3/simulator.h"
27 #include "ns3/object-vector.h"
28 #include "ns3/uinteger.h"
30 #include "ns3/assert.h"
31 #include "ns3/global-value.h"
32 #include "ns3/boolean.h"
33 #include "ns3/simulator.h"
42 "A global switch to enable all checksums for all protocols",
44 MakeBooleanChecker ());
51 .AddConstructor<Node> ()
52 .AddAttribute (
"DeviceList",
"The list of devices associated to this Node.",
55 MakeObjectVectorChecker<NetDevice> ())
56 .AddAttribute (
"ApplicationList",
"The list of applications associated to this Node.",
59 MakeObjectVectorChecker<Application> ())
60 .AddAttribute (
"Id",
"The id (unique integer) of this Node.",
64 MakeUintegerChecker<uint32_t> ())
65 .AddAttribute (
"SystemId",
"The systemId of this node: a unique integer used for parallel simulations.",
69 MakeUintegerChecker<uint32_t> ())
122 device->SetNode (
this);
123 device->SetIfIndex (index);
135 " is out of range (only have " <<
m_devices.size () <<
" devices).");
151 application->SetNode (
this);
161 " is out of range (only have " <<
m_applications.size () <<
" applications).");
189 application->Dispose ();
203 device->Initialize ();
209 application->Initialize ();
217 uint16_t protocolType,
221 NS_LOG_FUNCTION (
this << &handler << protocolType << device << promiscuous);
253 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
256 if (i->handler.IsEqual (handler))
277 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType);
293 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType << promiscuous);
295 "make sure the channels in use are correctly updating events context " <<
296 "when transfering events from one node to another.");
298 << device->GetIfIndex () <<
" (type=" << device->GetInstanceTypeId ().GetName ()
299 <<
") Packet UID " << packet->
GetUid ());
302 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
305 if (i->device == 0 ||
306 (i->device != 0 && i->device == device))
308 if (i->protocol == 0 ||
309 i->protocol == protocol)
311 if (promiscuous == i->promiscuous)
313 i->handler (device, packet, protocol, from, to, packetType);
340 if ((*i).IsEqual (listener))
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberContainer)
uint32_t AddApplication(Ptr< Application > application)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
uint32_t GetNApplications(void) const
virtual void DoInitialize(void)
DeviceAdditionListenerList m_deviceAdditionListeners
static bool ChecksumEnabled(void)
uint64_t GetUid(void) const
void NotifyDeviceAdded(Ptr< NetDevice > device)
static uint32_t GetContext(void)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual void DoDispose(void)
std::vector< Ptr< NetDevice > > m_devices
#define NS_LOG_FUNCTION_NOARGS()
hold a so-called 'global value'.
uint32_t GetSystemId(void) const
void UnregisterProtocolHandler(ProtocolHandler handler)
a polymophic address class
GlobalValue g_checksumEnabled
Ptr< Application > GetApplication(uint32_t index) const
virtual void DoDispose(void)
bool PromiscReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
Hold an unsigned integer type.
static uint32_t Add(Ptr< Node > node)
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
Ptr< NetDevice > GetDevice(uint32_t index) const
Callback< R > MakeCallback(R(T::*memPtr)(void), OBJ objPtr)
static void ScheduleWithContext(uint32_t context, Time const &time, MEM mem_ptr, OBJ obj)
uint32_t GetNDevices(void) const
ProtocolHandlerList m_handlers
void RegisterDeviceAdditionListener(DeviceAdditionListener listener)
std::vector< Ptr< Application > > m_applications
void RegisterProtocolHandler(ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
#define NS_ASSERT_MSG(condition, message)
static TypeId GetTypeId(void)
bool ReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc)
uint32_t AddDevice(Ptr< NetDevice > device)
uint32_t GetId(void) const
void UnregisterDeviceAdditionListener(DeviceAdditionListener listener)
#define NS_LOG_DEBUG(msg)
bool NonPromiscReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from)
a base class which provides memory management and object aggregation
contain a set of ns3::Object pointers.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual void DoInitialize(void)
void GetValue(AttributeValue &value) const