A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ns3::Node Class Reference

A network Node. More...

#include <node.h>

+ Inheritance diagram for ns3::Node:

Classes

struct  ProtocolHandlerEntry
 

Public Types

typedef Callback< void, Ptr
< NetDevice > > 
DeviceAdditionListener
 
typedef Callback< void, Ptr
< NetDevice >, Ptr< const
Packet >, uint16_t, const
Address &, const Address
&, NetDevice::PacketType
ProtocolHandler
 

Public Member Functions

 Node (uint32_t systemId)
 
uint32_t AddApplication (Ptr< Application > application)
 
uint32_t AddDevice (Ptr< NetDevice > device)
 
Ptr< ApplicationGetApplication (uint32_t index) const
 
Ptr< NetDeviceGetDevice (uint32_t index) const
 
uint32_t GetId (void) const
 
uint32_t GetNApplications (void) const
 
uint32_t GetNDevices (void) const
 
uint32_t GetSystemId (void) const
 
bool IsCognitiveRadio (void)
 
void RegisterDeviceAdditionListener (DeviceAdditionListener listener)
 
void RegisterProtocolHandler (ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
 
void SetCognitiveRadio (bool isCR)
 
void UnregisterDeviceAdditionListener (DeviceAdditionListener listener)
 
void UnregisterProtocolHandler (ProtocolHandler handler)
 
- Public Member Functions inherited from ns3::Object
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 
AggregateIterator GetAggregateIterator (void) const
 
virtual TypeId GetInstanceTypeId (void) const
 
template<typename T >
Ptr< T > GetObject (void) const
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 
void Initialize (void)
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 
- Public Member Functions inherited from ns3::ObjectBase
void GetAttribute (std::string name, AttributeValue &value) const
 
bool GetAttributeFailSafe (std::string name, AttributeValue &attribute) const
 
void SetAttribute (std::string name, const AttributeValue &value)
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 

Static Public Member Functions

static bool ChecksumEnabled (void)
 
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 

Protected Member Functions

virtual void DoDispose (void)
 
virtual void DoInitialize (void)
 
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void NotifyNewAggregate (void)
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 

Private Types

typedef std::vector
< DeviceAdditionListener
DeviceAdditionListenerList
 
typedef std::vector< struct
Node::ProtocolHandlerEntry
ProtocolHandlerList
 

Private Member Functions

void Construct (void)
 
bool NonPromiscReceiveFromDevice (Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from)
 
void NotifyDeviceAdded (Ptr< NetDevice > device)
 
bool PromiscReceiveFromDevice (Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType)
 
bool ReceiveFromDevice (Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from, const Address &to, NetDevice::PacketType packetType, bool promisc)
 

Private Attributes

std::vector< Ptr< Application > > m_applications
 
DeviceAdditionListenerList m_deviceAdditionListeners
 
std::vector< Ptr< NetDevice > > m_devices
 
ProtocolHandlerList m_handlers
 
uint32_t m_id
 
bool m_isCognitiveRadio
 
uint32_t m_sid
 

Detailed Description

A network Node.

This class holds together:

  • a list of NetDevice objects which represent the network interfaces of this node which are connected to other Node instances through Channel instances.
  • a list of Application objects which represent the userspace traffic generation applications which interact with the Node through the Socket API.
  • a node Id: a unique per-node identifier.
  • a system Id: a unique Id used for parallel simulations.

Every Node created is added to the NodeList automatically.

Config Paths

ns3::Node is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]

Attributes

  • DeviceList: The list of devices associated to this Node.
  • ApplicationList: The list of applications associated to this Node.
  • Id: The id (unique integer) of this Node.
  • SystemId: The systemId of this node: a unique integer used for parallel simulations.

No TraceSources are defined for this type.

Definition at line 56 of file node.h.

Member Typedef Documentation

A callback invoked whenever a device is added to a node.

Definition at line 174 of file node.h.

typedef Callback<void,Ptr<NetDevice>, Ptr<const Packet>,uint16_t,const Address &, const Address &, NetDevice::PacketType> ns3::Node::ProtocolHandler

A protocol handler

Parameters
devicea pointer to the net device which received the packet
packetthe packet received
protocolthe 16 bit protocol number associated with this packet. This protocol number is expected to be the same protocol number given to the Send method by the user on the sender side.
senderthe address of the sender
receiverthe address of the receiver; Note: this value is only valid for promiscuous mode protocol handlers. Note: If the L2 protocol does not use L2 addresses, the address reported here is the value of device->GetAddress().
packetTypetype of packet received (broadcast/multicast/unicast/otherhost); Note: this value is only valid for promiscuous mode protocol handlers.

Definition at line 145 of file node.h.

Constructor & Destructor Documentation

ns3::Node::Node ( uint32_t  systemId)
Parameters
systemIda unique integer used for parallel simulations.

Definition at line 84 of file node.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

uint32_t ns3::Node::AddDevice ( Ptr< NetDevice device)
void ns3::Node::DoDispose ( void  )
protectedvirtual

The dispose method. Subclasses must override this method and must chain up to it by calling Node::DoDispose at the end of their own DoDispose method.

Reimplemented from ns3::Object.

Definition at line 174 of file node.cc.

References ns3::Object::DoDispose(), and NS_LOG_FUNCTION.

void ns3::Node::DoInitialize ( void  )
protectedvirtual

This method is called only once by Object::Initialize. If the user calls Object::Initialize multiple times, DoInitialize is called only the first time.

Subclasses are expected to override this method and chain up to their parent's implementation once they are done. It is safe to call GetObject and AggregateObject from within this method.

Reimplemented from ns3::Object.

Definition at line 198 of file node.cc.

References ns3::Object::DoInitialize(), and NS_LOG_FUNCTION.

Ptr< Application > ns3::Node::GetApplication ( uint32_t  index) const
Parameters
index
Returns
the application associated to this requested index within this Node.

Definition at line 159 of file node.cc.

References NS_ASSERT_MSG, and NS_LOG_FUNCTION.

Referenced by ns3::EpcHelper::AddEnb(), ns3::OnOffHelper::AssignStreams(), ns3::EpcS1uDlTestCase::DoRun(), and ns3::EpcS1uUlTestCase::DoRun().

uint32_t ns3::Node::GetId ( void  ) const
Returns
the unique id of this node.

This unique id happens to be also the index of the Node into the NodeList.

Definition at line 105 of file node.cc.

References NS_LOG_FUNCTION.

Referenced by AddApplication(), AddDevice(), ns3::AcousticModemEnergyModel::ChangeState(), ns3::MobilityHelper::CourseChanged(), ns3::Ipv4GlobalRoutingHelper::Create(), ns3::GlobalRouteManagerImpl::DeleteGlobalRoutes(), ns3::GlobalRouter::DiscoverLSAs(), WifiMsduAggregatorThroughputTest::DoRun(), Ipv4FragmentationTest::DoRun(), Ipv6FragmentationTest::DoRun(), ns3::AsciiTraceHelperForDevice::EnableAsciiImpl(), ns3::AsciiTraceHelperForIpv4::EnableAsciiIpv4Impl(), ns3::InternetStackHelper::EnableAsciiIpv4Internal(), ns3::AsciiTraceHelperForIpv6::EnableAsciiIpv6Impl(), ns3::InternetStackHelper::EnableAsciiIpv6Internal(), ns3::PcapHelperForDevice::EnablePcap(), ns3::PcapHelperForIpv4::EnablePcapIpv4(), ns3::PcapHelperForIpv6::EnablePcapIpv6(), ns3::PcapHelper::GetFilenameFromDevice(), ns3::AsciiTraceHelper::GetFilenameFromDevice(), ns3::PcapHelper::GetFilenameFromInterfacePair(), ns3::AsciiTraceHelper::GetFilenameFromInterfacePair(), ns3::AcousticModemEnergyModel::HandleEnergyDepletion(), ns3::BridgeHelper::Install(), ns3::TapBridgeHelper::Install(), ns3::SpectrumAnalyzerHelper::Install(), ns3::Ipv6L3Protocol::IpForward(), ns3::Ipv6L3Protocol::IpMulticastForward(), ns3::ArpL3Protocol::Lookup(), ns3::ArpL3Protocol::Receive(), ns3::Ipv6L3Protocol::Receive(), ns3::Ipv4L3Protocol::Receive(), ns3::MpiInterface::ReceiveMessages(), ns3::aodv::RoutingProtocol::RecvReply(), ns3::aodv::RoutingProtocol::RecvRequest(), ns3::Ipv4ListRouting::RouteInput(), ns3::Ipv6ListRouting::RouteInput(), ns3::Ipv4NixVectorRouting::RouteInput(), ns3::olsr::RoutingProtocol::RouteInput(), ns3::olsr::RoutingProtocol::RouteOutput(), ns3::LoopbackNetDevice::Send(), ns3::Ipv4L3Protocol::Send(), ns3::LoopbackNetDevice::SendFrom(), ns3::aodv::RoutingProtocol::SendHello(), ns3::aodv::RoutingProtocol::SendReply(), ns3::aodv::RoutingProtocol::SendReplyByIntermediateNode(), ns3::aodv::RoutingProtocol::SendRequest(), ns3::AnimationInterface::SetConstantPosition(), ns3::AnimationInterface::SetLinkDescription(), ns3::GlobalRoutingLSA::SetNode(), ns3::AnimationInterface::SetNodeColor(), ns3::AnimationInterface::SetNodeDescription(), ns3::AnimationInterface::StartAnimation(), ns3::FdNetDevice::StartDevice(), ns3::EmuNetDevice::StartDevice(), ns3::TapBridge::StartTapDevice(), ns3::AnimationInterface::UpdateLinkDescription(), ns3::AnimationInterface::UpdateNodeColor(), and ns3::AnimationInterface::UpdateNodeDescription().

uint32_t ns3::Node::GetNApplications ( void  ) const
Returns
the number of applications associated to this Node.

Definition at line 167 of file node.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::EpcHelper::AddEnb(), and ns3::OnOffHelper::AssignStreams().

uint32_t ns3::Node::GetSystemId ( void  ) const
Returns
the system id for parallel simulations associated to this node.

Definition at line 112 of file node.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::GlobalRouteManagerImpl::InitializeRoutes(), ns3::PointToPointHelper::Install(), and ns3::MpiInterface::SendPacket().

void ns3::Node::RegisterDeviceAdditionListener ( DeviceAdditionListener  listener)
Parameters
listenerthe listener to add

Add a new listener to the list of listeners for the device-added event. When a new listener is added, it is notified of the existance of all already-added devices to make discovery of devices easier.

Definition at line 332 of file node.cc.

References NS_LOG_FUNCTION.

void ns3::Node::RegisterProtocolHandler ( ProtocolHandler  handler,
uint16_t  protocolType,
Ptr< NetDevice device,
bool  promiscuous = false 
)
Parameters
handlerthe handler to register
protocolTypethe type of protocol this handler is interested in. This protocol type is a so-called EtherType, as registered here: http://standards.ieee.org/regauth/ethertype/eth.txt the value zero is interpreted as matching all protocols.
devicethe device attached to this handler. If the value is zero, the handler is attached to all devices on this node.
promiscuouswhether to register a promiscuous mode handler

Definition at line 218 of file node.cc.

References ns3::MakeCallback(), and NS_LOG_FUNCTION.

Referenced by ns3::BridgeNetDevice::AddBridgePort(), ns3::MeshPointDevice::AddInterface(), ns3::Ipv4L3Protocol::AddInterface(), ns3::Ipv6L3Protocol::AddInterface(), and ns3::Ipv6L3Protocol::SetupLoopback().

void ns3::Node::UnregisterDeviceAdditionListener ( DeviceAdditionListener  listener)
Parameters
listenerthe listener to remove

Remove an existing listener from the list of listeners for the device-added event.

Definition at line 344 of file node.cc.

References NS_LOG_FUNCTION.

void ns3::Node::UnregisterProtocolHandler ( ProtocolHandler  handler)
Parameters
handlerthe handler to unregister

After this call returns, the input handler will never be invoked anymore.

Definition at line 252 of file node.cc.

References NS_LOG_FUNCTION.

Referenced by ns3::PacketSocket::Close().


The documentation for this class was generated from the following files: