A Discrete-Event Network Simulator
API
ns3::Wsn_node Class Reference

The wsn node base class that manages the sending and receiving of packets and basic configuration of nodes. More...

#include "wsn_node.h"

+ Inheritance diagram for ns3::Wsn_node:
+ Collaboration diagram for ns3::Wsn_node:

Public Member Functions

 Wsn_node ()
 Default constructor. More...
 
void ActivateNode ()
 The method re-activates a node that was disabled using the DisableNode() method. More...
 
void CheckSentOnion (int count)
 The method checks if the onion was received by the next receiving node If the onion was not received then abort the current onion and schedule the sending of another onion with equal parametrs as the aborted onion. More...
 
void Configure (void)
 1. More...
 
void DisableNode ()
 The method disables the node. More...
 
uint32_t getNodeDelay (Ipv4Address node_address)
 compute when the node should start the handshake process from the node ip address Used to not generate a network congestion if all nodes will strat the handshake at the same time More...
 
void NodeDegree (double coord_x, double coord_y)
 Retrieve the degreee this node from the OLSR routing protocol. More...
 
void NotifyRx (Ptr< const Packet > packet)
 Call to signal the receipt of a Packet at the application layer. More...
 
void NotifyTx (Ptr< const Packet > packet)
 Call to signal the transmission of a Packet at the application layer. More...
 
void OnionReceived (void)
 Signal to the ns3::OnionValidator that the onion was corrctly received. More...
 
Ptr< Packet > RecvSeg (Ptr< Socket > socket, Ptr< Packet > p, Address from)
 method for receiving packets able to merge segment fragments if a packet was split into multiple segments due to being larger than the MSS Use the packet tag, to merge packet fragments into a single packet. More...
 
Ptr< Packet > RecvSegment (Ptr< Socket > socket)
 method for receiving a segment calls ns3::Wsn_node::RecvSeg() More...
 
Ptr< Packet > RecvSegment (Ptr< Socket > socket, Address &from)
 method for receiving a segment calls ns3::Wsn_node::RecvSeg() More...
 
void SendSegment (InetSocketAddress remote, Ptr< Packet > packet, bool b_onion)
 Send a packet through a TCP connection to the remote address. More...
 

Static Public Member Functions

static TypeId GetTypeId (void)
 Register this type. More...
 

Protected Attributes

uint16_t f_mss
 maximum segment size More...
 
Ptr< Packet > f_pendingPacket
 pointer to the packet where received segment fragments are stored More...
 
Ipv4Address f_receivingAddress = Ipv4Address::GetAny ()
 the receiving address More...
 
int f_segmentSize
 the size of the whole packet More...
 
Ipv4Address m_address
 ns3::Ipv4Address of this node More...
 
TracedCallback< Ptr< const Packet > > m_appRx
 traced callback for packet receipt More...
 
TracedCallback< Ptr< const Packet > > m_appTx
 traced callback for packet transmission More...
 
uint16_t m_delay
 delay after which the handshake process will start More...
 
OnionManager m_onionManager
 The ns3::OnionManager object. More...
 
uint16_t m_onionTimeout
 timer in seconds, if elepsed and the onion was not recieved by the next receiver, then delete the onion More...
 
Ptr< OnionValidatorm_onionValidator
 Pointer to the ns3::OnionValidator. More...
 
Ptr< OutputManagerm_outputManager
 Pointer to the ns3::OutputManager. More...
 
uint16_t m_port
 port of the application More...
 
Ptr< Socket > m_socket
 listening socket More...
 
int o_hopCount = 0
 track how the onion is is transiting in the network More...
 
int o_sequenceNum = 0
 sequence number of the onion, should be same as onion_id More...
 

Private Member Functions

virtual void StartApplication (void)
 Start the application. More...
 
virtual void StopApplication (void)
 Stop the application. More...
 

Detailed Description

The wsn node base class that manages the sending and receiving of packets and basic configuration of nodes.

Definition at line 61 of file wsn_node.h.

Constructor & Destructor Documentation

◆ Wsn_node()

ns3::Wsn_node::Wsn_node ( )

Default constructor.

Definition at line 87 of file wsn_node.cc.

Member Function Documentation

◆ ActivateNode()

void ns3::Wsn_node::ActivateNode ( )

The method re-activates a node that was disabled using the DisableNode() method.

Definition at line 146 of file wsn_node.cc.

◆ CheckSentOnion()

void ns3::Wsn_node::CheckSentOnion ( int  count)

The method checks if the onion was received by the next receiving node If the onion was not received then abort the current onion and schedule the sending of another onion with equal parametrs as the aborted onion.

Checking onion.

Definition at line 321 of file wsn_node.cc.

References m_onionValidator, and m_outputManager.

Referenced by SendSegment().

+ Here is the caller graph for this function:

◆ Configure()

void ns3::Wsn_node::Configure ( void  )

1.

configure basic attributes of nodes

  1. create socket and listen for connections
  2. get node position in the form of x and y coordinates

Definition at line 102 of file wsn_node.cc.

References m_address, m_outputManager, m_port, m_socket, NodeDegree(), and ns3::OLSR.

Referenced by ns3::Sink::StartApplication(), and ns3::SensorNode::StartApplication().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ DisableNode()

void ns3::Wsn_node::DisableNode ( )

The method disables the node.

The node is unreachable for other nodes and is not collaborating in routing.

Definition at line 135 of file wsn_node.cc.

◆ getNodeDelay()

uint32_t ns3::Wsn_node::getNodeDelay ( Ipv4Address  node_address)

compute when the node should start the handshake process from the node ip address Used to not generate a network congestion if all nodes will strat the handshake at the same time

Parameters
[in]node_addressthe ipv4 address
Returns
return the delay in milliseconds

Definition at line 198 of file wsn_node.cc.

References m_delay.

Referenced by ns3::SensorNode::StartApplication().

+ Here is the caller graph for this function:

◆ GetTypeId()

TypeId ns3::Wsn_node::GetTypeId ( void  )
static

Register this type.

Returns
The object TypeId.

Definition at line 36 of file wsn_node.cc.

References f_mss, m_appRx, m_appTx, m_delay, m_onionTimeout, m_onionValidator, m_outputManager, and m_port.

◆ NodeDegree()

void ns3::Wsn_node::NodeDegree ( double  coord_x,
double  coord_y 
)

Retrieve the degreee this node from the OLSR routing protocol.

Works only if using the OLSR protocol. We refer to the degreee of the current node as the number of nodes that are in the one-hop neighbourhood of the current node with respect to the multi-hop communication.

Parameters
[in]coord_xx coordinate of the current node
[out]coord_yy coordinate of the current node

Get one hop neighbours:

Definition at line 163 of file wsn_node.cc.

References m_address, and m_outputManager.

Referenced by Configure().

+ Here is the caller graph for this function:

◆ NotifyRx()

void ns3::Wsn_node::NotifyRx ( Ptr< const Packet >  packet)

Call to signal the receipt of a Packet at the application layer.

Definition at line 82 of file wsn_node.cc.

References m_appRx.

Referenced by ns3::SensorNode::ReceivePacket(), and ns3::Sink::ReceivePacket().

+ Here is the caller graph for this function:

◆ NotifyTx()

void ns3::Wsn_node::NotifyTx ( Ptr< const Packet >  packet)

Call to signal the transmission of a Packet at the application layer.

Definition at line 76 of file wsn_node.cc.

References m_appTx.

Referenced by ns3::SensorNode::ReceivePacket(), and ns3::Sink::SendOnion().

+ Here is the caller graph for this function:

◆ OnionReceived()

void ns3::Wsn_node::OnionReceived ( void  )

Signal to the ns3::OnionValidator that the onion was corrctly received.

Definition at line 331 of file wsn_node.cc.

References m_onionValidator.

Referenced by ns3::SensorNode::ReceivePacket(), and ns3::Sink::ReceivePacket().

+ Here is the caller graph for this function:

◆ RecvSeg()

Ptr< Packet > ns3::Wsn_node::RecvSeg ( Ptr< Socket >  socket,
Ptr< Packet >  p,
Address  from 
)

method for receiving packets able to merge segment fragments if a packet was split into multiple segments due to being larger than the MSS Use the packet tag, to merge packet fragments into a single packet.

Parameters
[in]socketthe receiving socket
[in]packetpointer to the receiving packet
[in,out]fromextract the sender IP from the receiving socket
Returns
return pointer to packet if the whole packet is received OR return NULL value if only packet fragment is received

Definition at line 279 of file wsn_node.cc.

References f_pendingPacket, f_receivingAddress, f_segmentSize, and ns3::SegmentNum::GetSegNum().

Referenced by RecvSegment().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RecvSegment() [1/2]

Ptr< Packet > ns3::Wsn_node::RecvSegment ( Ptr< Socket >  socket)

method for receiving a segment calls ns3::Wsn_node::RecvSeg()

Parameters
[in]socketthe receiving socket
Returns
the result of the ns3::Wsn_node::RecvSeg() function

Definition at line 249 of file wsn_node.cc.

References RecvSeg().

Referenced by ns3::SensorNode::ReceivePacket(), and ns3::Sink::ReceivePacket().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RecvSegment() [2/2]

Ptr< Packet > ns3::Wsn_node::RecvSegment ( Ptr< Socket >  socket,
Address &  from 
)

method for receiving a segment calls ns3::Wsn_node::RecvSeg()

Parameters
[in]socketthe receiving socket
[in,out]fromextract the sender IP from the receiving socket
Returns
the result of the ns3::Wsn_node::RecvSeg() function

Definition at line 262 of file wsn_node.cc.

References RecvSeg().

+ Here is the call graph for this function:

◆ SendSegment()

void ns3::Wsn_node::SendSegment ( InetSocketAddress  remote,
Ptr< Packet >  packet,
bool  b_onion 
)

Send a packet through a TCP connection to the remote address.

Set b_onion to true to send an onion message. If b_onion is true, the method sets a callback after m_onionTimeout seconds The callback triggers the function ns3::Wsn_node::CheckSentOnion(). If the packe size is larger than the MSS. Then add a tag to the packet, which specifies the size of the whole packet. The tag is used by ns3::Wsn_node::RecvSeg() to reconstruct a packet that was split into multiple segments.

Parameters
[in]remotethe receiving address
[in]packetthe packet to send
[in]b_onionboolean value, set to true if sending an onion message. Adds the packet TAG to the packet

Definition at line 217 of file wsn_node.cc.

References CheckSentOnion(), f_mss, m_onionTimeout, m_onionValidator, and o_hopCount.

Referenced by ns3::SensorNode::Handshake(), ns3::SensorNode::ReceivePacket(), and ns3::Sink::SendOnion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ StartApplication()

void ns3::Wsn_node::StartApplication ( void  )
privatevirtual

Start the application.

Reimplemented in ns3::SensorNode, and ns3::Sink.

Definition at line 92 of file wsn_node.cc.

◆ StopApplication()

void ns3::Wsn_node::StopApplication ( void  )
privatevirtual

Stop the application.

Reimplemented in ns3::SensorNode, and ns3::Sink.

Definition at line 97 of file wsn_node.cc.

Member Data Documentation

◆ f_mss

uint16_t ns3::Wsn_node::f_mss
protected

maximum segment size

Definition at line 233 of file wsn_node.h.

Referenced by GetTypeId(), and SendSegment().

◆ f_pendingPacket

Ptr<Packet> ns3::Wsn_node::f_pendingPacket
protected

pointer to the packet where received segment fragments are stored

Definition at line 236 of file wsn_node.h.

Referenced by RecvSeg().

◆ f_receivingAddress

Ipv4Address ns3::Wsn_node::f_receivingAddress = Ipv4Address::GetAny ()
protected

the receiving address

Definition at line 237 of file wsn_node.h.

Referenced by RecvSeg().

◆ f_segmentSize

int ns3::Wsn_node::f_segmentSize
protected

the size of the whole packet

Definition at line 234 of file wsn_node.h.

Referenced by RecvSeg().

◆ m_address

Ipv4Address ns3::Wsn_node::m_address
protected

◆ m_appRx

TracedCallback<Ptr<const Packet> > ns3::Wsn_node::m_appRx
protected

traced callback for packet receipt

Definition at line 248 of file wsn_node.h.

Referenced by GetTypeId(), and NotifyRx().

◆ m_appTx

TracedCallback<Ptr<const Packet> > ns3::Wsn_node::m_appTx
protected

traced callback for packet transmission

Definition at line 247 of file wsn_node.h.

Referenced by GetTypeId(), and NotifyTx().

◆ m_delay

uint16_t ns3::Wsn_node::m_delay
protected

delay after which the handshake process will start

Definition at line 229 of file wsn_node.h.

Referenced by getNodeDelay(), GetTypeId(), and ns3::Sink::StartApplication().

◆ m_onionManager

◆ m_onionTimeout

uint16_t ns3::Wsn_node::m_onionTimeout
protected

timer in seconds, if elepsed and the onion was not recieved by the next receiver, then delete the onion

Definition at line 244 of file wsn_node.h.

Referenced by GetTypeId(), and SendSegment().

◆ m_onionValidator

Ptr<OnionValidator> ns3::Wsn_node::m_onionValidator
protected

◆ m_outputManager

◆ m_port

uint16_t ns3::Wsn_node::m_port
protected

port of the application

Definition at line 224 of file wsn_node.h.

Referenced by Configure(), GetTypeId(), ns3::SensorNode::Handshake(), ns3::SensorNode::ReceivePacket(), and ns3::Sink::SendOnion().

◆ m_socket

◆ o_hopCount

int ns3::Wsn_node::o_hopCount = 0
protected

track how the onion is is transiting in the network

Definition at line 240 of file wsn_node.h.

Referenced by SendSegment().

◆ o_sequenceNum

int ns3::Wsn_node::o_sequenceNum = 0
protected

sequence number of the onion, should be same as onion_id

Definition at line 241 of file wsn_node.h.

Referenced by ns3::SensorNode::ReceivePacket(), and ns3::Sink::ReceivePacket().


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