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

The application of the sensor node. More...

#include "sensornode.h"

+ Inheritance diagram for ns3::SensorNode:
+ Collaboration diagram for ns3::SensorNode:

Public Member Functions

 SensorNode ()
 Default constructor. More...
 
virtual ~SensorNode ()
 Default destructor. More...
 
void Accept (Ptr< Socket > socket, const ns3::Address &from)
 Accept new TCP connections. More...
 
uint32_t DeserializeIpv4ToInt (uint8_t *buff)
 Convert an IPV4 address given as a buffer. More...
 
void ProcessOnionBody (protomessage::ProtoPacket_OnionBody *onionbody)
 If the onion body contains the aggregated value, then aggregate the sensor (dummy) value to the value carried in the onion body. More...
 
uint32_t ProcessOnionHead (protomessage::ProtoPacket_OnionHead *onionHead)
 Decrypt the outer layer of the onion head, obtain the information of the next IP address, reasemble the onion head by including padding if required. More...
 
void ReceivePacket (Ptr< Socket > socket)
 Executed when a new onion is received. More...
 
- Public Member Functions inherited from ns3::Wsn_node
 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...
 
- Static Public Member Functions inherited from ns3::Wsn_node
static TypeId GetTypeId (void)
 Register this type. More...
 

Private Member Functions

void Handshake (void)
 Construct a new protobuf object containing the node publickey and send it to the sink node. More...
 
virtual void StartApplication (void)
 1.Start the application run ns3::Wsn_node::Configure() 2.Generate new encryption keys 3.Schedule the execution of ns3::SensorNode::Handshake() after delay milliseconds, the delay is computed based on the node ip address 4.Set callback at new socket connection
More...
 
virtual void StopApplication (void)
 Stop the application. More...
 

Private Attributes

uint32_t m_sensorValue = 20
 dummy reading of a sensor equipped on the node More...
 
Ipv4Address m_sinkAddress
 address of the sink node More...
 

Additional Inherited Members

- Protected Attributes inherited from ns3::Wsn_node
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...
 

Detailed Description

The application of the sensor node.

Definition at line 46 of file sensornode.h.

Constructor & Destructor Documentation

◆ SensorNode()

ns3::SensorNode::SensorNode ( )

Default constructor.

Definition at line 45 of file sensornode.cc.

◆ ~SensorNode()

ns3::SensorNode::~SensorNode ( )
virtual

Default destructor.

Definition at line 49 of file sensornode.cc.

References ns3::Wsn_node::m_socket.

Member Function Documentation

◆ Accept()

void ns3::SensorNode::Accept ( Ptr< Socket >  socket,
const ns3::Address &  from 
)

Accept new TCP connections.

Parameters
[in]socket
[in]fromsending address

Definition at line 207 of file sensornode.cc.

References ReceivePacket().

Referenced by StartApplication().

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

◆ DeserializeIpv4ToInt()

uint32_t ns3::SensorNode::DeserializeIpv4ToInt ( uint8_t *  buff)

Convert an IPV4 address given as a buffer.

Parameters
[in]buffpointer to an array containing an IpV4 address
Returns
an IpV4 address as an unisgned integer of 32b

Definition at line 192 of file sensornode.cc.

Referenced by ProcessOnionHead().

+ Here is the caller graph for this function:

◆ GetTypeId()

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

Register this type.

Returns
The object TypeId.

Definition at line 32 of file sensornode.cc.

References m_sinkAddress.

◆ Handshake()

void ns3::SensorNode::Handshake ( void  )
private

Construct a new protobuf object containing the node publickey and send it to the sink node.

Definition at line 57 of file sensornode.cc.

References ns3::OnionManager::GetPKtoString(), ns3::Wsn_node::m_onionManager, ns3::Wsn_node::m_port, m_sinkAddress, protomessage::ProtoPacket::mutable_h_shake(), ns3::Wsn_node::SendSegment(), and protomessage::ProtoPacket_Handshake::set_publickey().

Referenced by StartApplication().

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

◆ ProcessOnionBody()

void ns3::SensorNode::ProcessOnionBody ( protomessage::ProtoPacket_OnionBody onionbody)

If the onion body contains the aggregated value, then aggregate the sensor (dummy) value to the value carried in the onion body.

Parameters
[in]onionBodypionter to the protobuf object holding informations of the onion body

Definition at line 178 of file sensornode.cc.

References protomessage::ProtoPacket_OnionBody::aggregatedvalue(), protomessage::ProtoPacket_OnionBody::has_aggregatedvalue(), m_sensorValue, and protomessage::ProtoPacket_OnionBody::set_aggregatedvalue().

Referenced by ReceivePacket().

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

◆ ProcessOnionHead()

uint32_t ns3::SensorNode::ProcessOnionHead ( protomessage::ProtoPacket_OnionHead onionHead)

Decrypt the outer layer of the onion head, obtain the information of the next IP address, reasemble the onion head by including padding if required.

Parameters
[in]onionHeadpionter to the protobuf object holding informations of the onion head
Returns
an IpV4 address as an unisgned integer of 32b

Definition at line 136 of file sensornode.cc.

References DeserializeIpv4ToInt(), ns3::OnionManager::GetPK(), ns3::OnionManager::GetSK(), protomessage::ProtoPacket_OnionHead::has_padding(), ns3::orLayer::innerLayer, ns3::orLayer::innerLayerLen, ns3::Wsn_node::m_onionManager, ns3::orLayer::nextHopIP, protomessage::ProtoPacket_OnionHead::onion_message(), protomessage::ProtoPacket_OnionHead::padding(), ns3::OnionRouting::PeelOnion(), protomessage::ProtoPacket_OnionHead::set_onion_message(), protomessage::ProtoPacket_OnionHead::set_padding(), ns3::OnionManager::StringToUchar(), and ns3::OnionManager::UcharToString().

Referenced by ReceivePacket().

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

◆ ReceivePacket()

void ns3::SensorNode::ReceivePacket ( Ptr< Socket >  socket)

Executed when a new onion is received.

Repeatedly call ns3::Wsn_node::RecvSegment() until the whole packet is received. Then, check if the onion is valid by comparing the onionID of the onion and the onion sequence number in the ns3::OnionValidator::GetOnionSeq(). If the onion is not valid then delete the onion. Otherwise: Signal that the onion was received. Process the onion head and retrieve the next hop ip value. (ns3::SensorNode::ProcessOnionHead()) Processs the onion body. (ns3::SensorNode::ProcessOnionBody()) Send the onion meesage to the next hop ip.

Parameters
[in]socketthe incoming connection

Log details about the onion

Definition at line 79 of file sensornode.cc.

References protomessage::ProtoPacket_OnionHead::ByteSizeLong(), protomessage::ProtoPacket_OnionBody::ByteSizeLong(), ns3::SerializationWrapper::GetData(), ns3::Wsn_node::m_address, ns3::Wsn_node::m_onionValidator, ns3::Wsn_node::m_outputManager, ns3::Wsn_node::m_port, protomessage::ProtoPacket::mutable_o_body(), protomessage::ProtoPacket::mutable_o_head(), ns3::Wsn_node::NotifyRx(), ns3::Wsn_node::NotifyTx(), ns3::Wsn_node::o_sequenceNum, protomessage::ProtoPacket_OnionHead::onionid(), ns3::Wsn_node::OnionReceived(), ProcessOnionBody(), ProcessOnionHead(), ns3::Wsn_node::RecvSegment(), ns3::Wsn_node::SendSegment(), and ns3::SerializationWrapper::SetData().

Referenced by Accept().

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

◆ StartApplication()

void ns3::SensorNode::StartApplication ( void  )
privatevirtual

1.Start the application run ns3::Wsn_node::Configure() 2.Generate new encryption keys 3.Schedule the execution of ns3::SensorNode::Handshake() after delay milliseconds, the delay is computed based on the node ip address 4.Set callback at new socket connection

Reimplemented from ns3::Wsn_node.

Definition at line 214 of file sensornode.cc.

References Accept(), ns3::Wsn_node::Configure(), ns3::OnionManager::GenerateNewKeyPair(), ns3::Wsn_node::getNodeDelay(), Handshake(), ns3::Wsn_node::m_address, ns3::Wsn_node::m_onionManager, and ns3::Wsn_node::m_socket.

+ Here is the call graph for this function:

◆ StopApplication()

void ns3::SensorNode::StopApplication ( void  )
privatevirtual

Stop the application.

Reimplemented from ns3::Wsn_node.

Definition at line 232 of file sensornode.cc.

References ns3::Wsn_node::m_socket.

Member Data Documentation

◆ m_sensorValue

uint32_t ns3::SensorNode::m_sensorValue = 20
private

dummy reading of a sensor equipped on the node

Definition at line 162 of file sensornode.h.

Referenced by ProcessOnionBody().

◆ m_sinkAddress

Ipv4Address ns3::SensorNode::m_sinkAddress
private

address of the sink node

Definition at line 160 of file sensornode.h.

Referenced by GetTypeId(), and Handshake().


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