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"
43 "A global switch to enable all checksums for all protocols",
45 MakeBooleanChecker ());
52 .AddConstructor<Node> ()
53 .AddAttribute (
"DeviceList",
"The list of devices associated to this Node.",
56 MakeObjectVectorChecker<NetDevice> ())
57 .AddAttribute (
"ApplicationList",
"The list of applications associated to this Node.",
60 MakeObjectVectorChecker<Application> ())
61 .AddAttribute (
"Id",
"The id (unique integer) of this Node.",
65 MakeUintegerChecker<uint32_t> ())
66 .AddAttribute (
"SystemId",
"The systemId of this node: a unique integer used for parallel simulations.",
70 MakeUintegerChecker<uint32_t> ())
123 device->SetNode (
this);
124 device->SetIfIndex (index);
136 " is out of range (only have " <<
m_devices.size () <<
" devices).");
152 application->SetNode (
this);
162 " is out of range (only have " <<
m_applications.size () <<
" applications).");
190 application->Dispose ();
204 device->Initialize ();
210 application->Initialize ();
218 uint16_t protocolType,
222 NS_LOG_FUNCTION (
this << &handler << protocolType << device << promiscuous);
254 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
257 if (i->handler.IsEqual (handler))
278 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType);
294 NS_LOG_FUNCTION (
this << device << packet << protocol << &from << &to << packetType << promiscuous);
296 "make sure the channels in use are correctly updating events context " <<
297 "when transfering events from one node to another.");
299 << device->GetIfIndex () <<
" (type=" << device->GetInstanceTypeId ().GetName ()
300 <<
") Packet UID " << packet->
GetUid ());
303 for (ProtocolHandlerList::iterator i =
m_handlers.begin ();
306 if (i->device == 0 ||
307 (i->device != 0 && i->device == device))
309 if (i->protocol == 0 ||
310 i->protocol == protocol)
312 if (promiscuous == i->promiscuous)
314 i->handler (device, packet, protocol, from, to, packetType);
341 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)
This method is called only once by Object::Initialize.
DeviceAdditionListenerList m_deviceAdditionListeners
static bool ChecksumEnabled(void)
uint64_t GetUid(void) const
A packet is allocated a new uid when it is created empty or with zero-filled payload.
void NotifyDeviceAdded(Ptr< NetDevice > device)
static uint32_t GetContext(void)
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
std::vector< Ptr< NetDevice > > m_devices
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
hold a so-called 'global value'.
uint32_t GetSystemId(void) const
void UnregisterProtocolHandler(ProtocolHandler handler)
a polymophic address class
The attribute can be read.
GlobalValue g_checksumEnabled
Ptr< Application > GetApplication(uint32_t index) const
virtual void DoDispose(void)
The dispose method.
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)
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)
Schedule an event with the given context.
uint32_t GetNDevices(void) const
ProtocolHandlerList m_handlers
NS_LOG_COMPONENT_DEFINE("Node")
void RegisterDeviceAdditionListener(DeviceAdditionListener listener)
The attribute can be written.
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)
void Initialize(void)
This method calls the virtual DoInitialize method on all the objects aggregated to this object...
bool NonPromiscReceiveFromDevice(Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from)
a base class which provides memory management and object aggregation
PacketType
Packet types are used as they are in Linux.
contain a set of ns3::Object pointers.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
void GetValue(AttributeValue &value) const