ns3::Node Class Reference
[Node]

A network Node. More...

#include <node.h>

Inheritance diagram for ns3::Node:
Inheritance graph
[legend]
Collaboration diagram for ns3::Node:
Collaboration graph
[legend]

List of all members.

Classes

struct  ProtocolHandlerEntry

Public Types

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

Public Member Functions

 Node ()
 Node (uint32_t systemId)
virtual ~Node ()
uint32_t GetId (void) const
uint32_t GetSystemId (void) const
uint32_t AddDevice (Ptr< NetDevice > device)
Ptr< NetDeviceGetDevice (uint32_t index) const
uint32_t GetNDevices (void) const
uint32_t AddApplication (Ptr< Application > application)
Ptr< ApplicationGetApplication (uint32_t index) const
uint32_t GetNApplications (void) const
void RegisterProtocolHandler (ProtocolHandler handler, uint16_t protocolType, Ptr< NetDevice > device, bool promiscuous=false)
void UnregisterProtocolHandler (ProtocolHandler handler)

Static Public Member Functions

static TypeId GetTypeId (void)
 This method returns the TypeId associated to ns3::Node.

Protected Member Functions

virtual void DoDispose (void)

Private Types

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

Private Member Functions

virtual void NotifyDeviceAdded (Ptr< NetDevice > device)
bool NonPromiscReceiveFromDevice (Ptr< NetDevice > device, Ptr< const Packet >, uint16_t protocol, const Address &from)
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)
void Construct (void)

Private Attributes

uint32_t m_id
uint32_t m_sid
std::vector< Ptr< NetDevice > > m_devices
std::vector< Ptr< Application > > m_applications
ProtocolHandlerList m_handlers

Detailed Description

A network Node.

This class holds together:

Every Node created is added to the NodeList automatically.

Definition at line 55 of file node.h.


Member Typedef Documentation

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

A protocol handler

Parameters:
device a pointer to the net device which received the packet
packet the packet received
protocol the 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.
sender the address of the sender
receiver the address of the receiver; Note: this value is only valid for promiscuous mode protocol handlers.
packetType type of packet received (broadcast/multicast/unicast/otherhost); Note: this value is only valid for promiscuous mode protocol handlers.

Definition at line 149 of file node.h.

typedef std::vector<struct Node::ProtocolHandlerEntry> ns3::Node::ProtocolHandlerList [private]

Definition at line 206 of file node.h.


Constructor & Destructor Documentation

ns3::Node::Node (  ) 

Must be invoked by subclasses only.

Definition at line 60 of file node.cc.

References Construct().

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

Must be invoked by subclasses only.

Definition at line 67 of file node.cc.

References Construct().

ns3::Node::~Node (  )  [virtual]

Definition at line 80 of file node.cc.


Member Function Documentation

uint32_t ns3::Node::AddApplication ( Ptr< Application application  ) 
Parameters:
application Application to associate to this node.
Returns:
the index of the Application within the Node's list of Application.

Associated this Application to this Node. This method is called automatically from Application::Application so the user has little reasons to call this method directly.

Definition at line 120 of file node.cc.

References m_applications.

uint32_t ns3::Node::AddDevice ( Ptr< NetDevice device  ) 
Parameters:
device NetDevice to associate to this node.
Returns:
the index of the NetDevice into the Node's list of NetDevice.

Associate this device to this node.

Definition at line 96 of file node.cc.

References m_devices, ns3::MakeCallback(), NonPromiscReceiveFromDevice(), and NotifyDeviceAdded().

void ns3::Node::Construct ( void   )  [private]

Definition at line 75 of file node.cc.

References ns3::NodeList::Add(), and m_id.

Referenced by Node().

void ns3::Node::DoDispose ( void   )  [protected, virtual]

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 141 of file node.cc.

References m_applications, and m_devices.

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 128 of file node.cc.

References m_applications, and NS_ASSERT_MSG.

Ptr< NetDevice > ns3::Node::GetDevice ( uint32_t  index  )  const
Parameters:
index the index of the requested NetDevice
Returns:
the requested NetDevice associated to this Node.

The indexes used by the GetDevice method start at one and end at GetNDevices ()

Definition at line 107 of file node.cc.

References m_devices, and NS_ASSERT_MSG.

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 84 of file node.cc.

References m_id.

Referenced by ReceiveFromDevice().

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

Definition at line 135 of file node.cc.

References m_applications.

uint32_t ns3::Node::GetNDevices ( void   )  const
Returns:
the number of NetDevice instances associated to this Node.

Definition at line 114 of file node.cc.

References m_devices.

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

Definition at line 90 of file node.cc.

References m_sid.

TypeId ns3::Node::GetTypeId ( void   )  [static]

This method returns the TypeId associated to ns3::Node.

This object is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]

Attributes defined for this type:

No TraceSources defined for this type.

Reimplemented from ns3::Object.

Definition at line 39 of file node.cc.

References ns3::TypeId::AddAttribute(), ns3::TypeId::ATTR_GET, m_applications, m_devices, m_id, ns3::MakeObjectVectorAccessor(), and ns3::TypeId::SetParent().

bool ns3::Node::NonPromiscReceiveFromDevice ( Ptr< NetDevice device,
Ptr< const Packet packet,
uint16_t  protocol,
const Address from 
) [private]

Definition at line 233 of file node.cc.

References NS_LOG_FUNCTION, and ReceiveFromDevice().

Referenced by AddDevice().

void ns3::Node::NotifyDeviceAdded ( Ptr< NetDevice device  )  [private, virtual]
Parameters:
device the device added to this Node.

This method is invoked whenever a user calls Node::AddDevice.

Definition at line 163 of file node.cc.

Referenced by AddDevice().

bool ns3::Node::PromiscReceiveFromDevice ( Ptr< NetDevice device,
Ptr< const Packet packet,
uint16_t  protocol,
const Address from,
const Address to,
NetDevice::PacketType  packetType 
) [private]

Definition at line 225 of file node.cc.

References NS_LOG_FUNCTION, and ReceiveFromDevice().

Referenced by RegisterProtocolHandler().

bool ns3::Node::ReceiveFromDevice ( Ptr< NetDevice device,
Ptr< const Packet packet,
uint16_t  protocol,
const Address from,
const Address to,
NetDevice::PacketType  packetType,
bool  promisc 
) [private]

Definition at line 241 of file node.cc.

References GetId(), m_handlers, and NS_LOG_DEBUG.

Referenced by NonPromiscReceiveFromDevice(), and PromiscReceiveFromDevice().

void ns3::Node::RegisterProtocolHandler ( ProtocolHandler  handler,
uint16_t  protocolType,
Ptr< NetDevice device,
bool  promiscuous = false 
)
Parameters:
handler the handler to register
protocolType the 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.
device the device attached to this handler. If the value is zero, the handler is attached to all devices on this node.
promiscuous whether to register a promiscuous mode handler

Definition at line 167 of file node.cc.

References ns3::Node::ProtocolHandlerEntry::device, ns3::Node::ProtocolHandlerEntry::handler, m_devices, m_handlers, ns3::MakeCallback(), NS_LOG_WARN, PromiscReceiveFromDevice(), ns3::Node::ProtocolHandlerEntry::promiscuous, and ns3::Node::ProtocolHandlerEntry::protocol.

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

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

Definition at line 211 of file node.cc.

References m_handlers.


Member Data Documentation

std::vector<Ptr<Application> > ns3::Node::m_applications [private]

Definition at line 210 of file node.h.

Referenced by AddApplication(), DoDispose(), GetApplication(), GetNApplications(), and GetTypeId().

std::vector<Ptr<NetDevice> > ns3::Node::m_devices [private]

Definition at line 209 of file node.h.

Referenced by AddDevice(), DoDispose(), GetDevice(), GetNDevices(), GetTypeId(), and RegisterProtocolHandler().

Definition at line 211 of file node.h.

Referenced by ReceiveFromDevice(), RegisterProtocolHandler(), and UnregisterProtocolHandler().

uint32_t ns3::Node::m_id [private]

Definition at line 207 of file node.h.

Referenced by Construct(), GetId(), and GetTypeId().

uint32_t ns3::Node::m_sid [private]

Definition at line 208 of file node.h.

Referenced by GetSystemId().


The documentation for this class was generated from the following files:
Generated on Thu Dec 3 14:12:04 2009 for NS-3 by  doxygen 1.6.3