The application of the sink node. The node that generates onion messagess. More...
#include "sink.h"
Inheritance diagram for ns3::Sink:
Collaboration diagram for ns3::Sink:Public Member Functions | |
| Sink () | |
| Default constructor. More... | |
| virtual | ~Sink () |
| Default destructor. More... | |
| void | Accept (Ptr< Socket > socket, const ns3::Address &from) |
| Accept new TCP connections. More... | |
| void | CheckOnion (void) |
Each five seconds call the ns3::OnionValidator and check if at least one onion message is alive Otherwise the onion was aborted, decrease the value of m_repeateCount and schedule a new execution of the function ns3::Sink::SinkTasks() More... | |
| void | Setup (uint16_t *onionPathlengths, uint16_t numOnionLengths, int repeateTimes) |
| Setup sink node parameters after the application installation. More... | |
| void | SinkTasks () |
Schedule the creation of a new onion based on the path length specified in m_onionPathLengths If all onions specified in m_onionPathLengths were executed for m_repeateTimes Then end the simulation. 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 | PrepareOnion (int *route, int routeLen) |
Method that constructs the onion head from route and routeLen parameters. More... | |
| void | ReceivePacket (Ptr< Socket > socket) |
Recieve a new packet from socket Check if the packet is a handshake packet or a packet containing an onion message. More... | |
| void | RecvHandshake (protomessage::ProtoPacket_Handshake *handshake_data, InetSocketAddress from) |
| When receiving a new handshake with a node. More... | |
| void | RecvOnion (protomessage::ProtoPacket_OnionBody *onion_body) |
| Triggered when an onion message is received back at the sink node Data about the message is captured and a new onion message is scheduled. More... | |
| void | SelectRoute (int *route, int routeLen) |
The method builds the path of the onion message by randomly selecting sensor nodes from the m_nodeManager structure. More... | |
| void | SendOnion (uint32_t firstHop, int routeLen, unsigned char *cipher, int cipherLen) |
| The method constructs the onion message as a protobuf object. More... | |
| virtual void | StartApplication (void) |
1.Start the application run ns3::Wsn_node::Configure() 2.Generate new encryption keys 3.Set callback at new socket connection 4.Schedule the execution of ns3::Sink::SinkTasks() after m_onionDelay milliseconds 5.Schedule the execution of ns3::Sink::CheckOnion() after m_onionDelay milliseconds and 5 seconds More... | |
| virtual void | StopApplication (void) |
| Stop the application. More... | |
Private Attributes | |
| enum BodyOptions | m_bodyOptions |
| uint16_t | m_bodySize |
| uint32_t | m_decoyNum |
| dummy decoy value used to obfuscate the value carried in the onion body More... | |
| bool | m_fixedOnionSize |
| maintain the onion size fixed by adding padding (after layer decryption) More... | |
| std::map< uint32_t, std::string > | m_nodeManager |
| hashmap to manage data about nodes in the WSN// pair <IP,publickey> More... | |
| uint16_t | m_numnodes |
| The number of sensor nodes in the simulation. More... | |
| uint16_t | m_numOnionLengths |
| size of the array m_onionPathsLengths More... | |
| uint32_t | m_onionDelay |
| The sink will start sending onion messagess after OnionDelay seconds. More... | |
| int | m_onionId = 1 |
| onion ID incremented each time a new onion is issued More... | |
| int | m_onionLengthIndex = 0 |
| index of the current onion path length More... | |
| uint16_t * | m_onionPathLengths |
| array holding onion path lengths More... | |
| std::stringstream | m_onionStream |
| a string stream holding the onion represented as a string More... | |
| std::string | m_publickey |
| the encryption key: publickey More... | |
| int | m_repeateCount = 0 |
| how many times the onion was sent at the current path length More... | |
| int | m_repeateTimes |
| Integer specifying the number of times to generate the onion message for each value in the m_onionPathsLengths. More... | |
| std::string | m_secretkey |
| the encryption key: secretkey 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< OnionValidator > | m_onionValidator |
| Pointer to the ns3::OnionValidator. More... | |
| Ptr< OutputManager > | m_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... | |
The application of the sink node. The node that generates onion messagess.
|
virtual |
| void ns3::Sink::Accept | ( | Ptr< Socket > | socket, |
| const ns3::Address & | from | ||
| ) |
Accept new TCP connections.
| [in] | socket | |
| [in] | from | sending address |
Definition at line 87 of file sink.cc.
References ReceivePacket().
Referenced by StartApplication().
Here is the call graph for this function:
Here is the caller graph for this function:| void ns3::Sink::CheckOnion | ( | void | ) |
Each five seconds call the ns3::OnionValidator and check if at least one onion message is alive Otherwise the onion was aborted, decrease the value of m_repeateCount and schedule a new execution of the function ns3::Sink::SinkTasks()
Definition at line 330 of file sink.cc.
References ns3::Wsn_node::m_onionValidator, m_repeateCount, and SinkTasks().
Referenced by StartApplication().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Register this type.
Definition at line 32 of file sink.cc.
References ns3::Aggregate, ns3::AggregateAndFixed, ns3::FixedSize, m_bodyOptions, m_bodySize, m_fixedOnionSize, m_numnodes, m_onionDelay, and ns3::NO_Body.
|
private |
Method that constructs the onion head from route and routeLen parameters.
The method constructs two arrays keys , ipRoute containing respectively encryption keys and IP addreses of sensor nodes in the m_nodeManager structure at indexes specified by the route array. The onion head is constructed by calling ns3::OnionRouting::BuildOnion().
| [in,out] | route | pointer to an array of length routeLen cointaining indexes of sensor nodes in the m_nodeManager structure. |
| [in] | routeLen | length of the array route |
Definition at line 230 of file sink.cc.
References ns3::OnionRouting::BuildOnion(), ns3::OnionManager::IpToBuff(), ns3::Wsn_node::m_address, m_nodeManager, ns3::Wsn_node::m_onionManager, m_publickey, ns3::OnionRouting::OnionLength(), SendOnion(), and ns3::OnionManager::StringToUchar().
Referenced by SinkTasks().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Recieve a new packet from socket Check if the packet is a handshake packet or a packet containing an onion message.
| [in] | socket | the receiving tcp socket |
Definition at line 95 of file sink.cc.
References ns3::SerializationWrapper::GetData(), protomessage::ProtoPacket::has_h_shake(), ns3::Wsn_node::m_address, m_onionId, protomessage::ProtoPacket::mutable_h_shake(), protomessage::ProtoPacket::mutable_o_body(), protomessage::ProtoPacket::mutable_o_head(), ns3::Wsn_node::NotifyRx(), ns3::Wsn_node::o_sequenceNum, protomessage::ProtoPacket_OnionHead::onionid(), ns3::Wsn_node::OnionReceived(), RecvHandshake(), RecvOnion(), and ns3::Wsn_node::RecvSegment().
Referenced by Accept().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
When receiving a new handshake with a node.
The sink node stores the sensor node IP address and publickey (PK) in std::map structure m_nodeManager , where IP is the key and PK is the value
| [in] | handshake_data | pointer to the protobuf object holding message data |
| [in] | from | the IP address of the sensor node |
Definition at line 142 of file sink.cc.
References m_nodeManager, ns3::Wsn_node::m_outputManager, and protomessage::ProtoPacket_Handshake::publickey().
Referenced by ReceivePacket().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Triggered when an onion message is received back at the sink node Data about the message is captured and a new onion message is scheduled.
| [in] | onion_body | pointer to the protobuf object holding onion data |
Definition at line 154 of file sink.cc.
References ns3::Wsn_node::m_outputManager, and SinkTasks().
Referenced by ReceivePacket().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
The method builds the path of the onion message by randomly selecting sensor nodes from the m_nodeManager structure.
The path can have loops, but the same node cannot be placed in two consequent postions in the onion message path. The onion path must be of length >= 3.
| [in,out] | route | pointer to an array of length routeLen |
| [in] | routeLen | length of the array route |
Definition at line 202 of file sink.cc.
References m_nodeManager.
Referenced by SinkTasks().
Here is the caller graph for this function:
|
private |
The method constructs the onion message as a protobuf object.
The method sends the onion message to the sesor node at the firstHop address The method sets the tracking of the onion by calling ns3::OnionValidator::StartOnion()
| [in] | firstHop | IP address of the first sensor node in the onion path |
| [in] | routeLen | length of the onion path |
| [in,out] | cipher | pointer to the ciphertext of the onion head |
| [in] | cipherLen | length in the number of bytes of the cipher |
Definition at line 272 of file sink.cc.
References ns3::Aggregate, ns3::AggregateAndFixed, protomessage::ProtoPacket_OnionHead::ByteSizeLong(), protomessage::ProtoPacket_OnionBody::ByteSizeLong(), ns3::FixedSize, ns3::Wsn_node::m_address, m_bodyOptions, m_bodySize, m_decoyNum, m_fixedOnionSize, m_onionId, ns3::Wsn_node::m_onionManager, 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::NO_Body, ns3::Wsn_node::NotifyTx(), ns3::Wsn_node::SendSegment(), protomessage::ProtoPacket_OnionBody::set_aggregatedvalue(), protomessage::ProtoPacket_OnionHead::set_onion_message(), protomessage::ProtoPacket_OnionHead::set_onionid(), protomessage::ProtoPacket_OnionHead::set_padding(), protomessage::ProtoPacket_OnionBody::set_padding(), and ns3::OnionManager::UcharToString().
Referenced by PrepareOnion().
Here is the call graph for this function:
Here is the caller graph for this function:| void ns3::Sink::Setup | ( | uint16_t * | onionPathlengths, |
| uint16_t | numOnionLengths, | ||
| int | repeateTimes | ||
| ) |
Setup sink node parameters after the application installation.
| [in] | onionPathLengths | pointer to the array where each value is representing the number of hops the onion will travel to return back to the sink node issuer of the onion. |
| [in] | numOnionLengths | number of cells of the array onionPathLengths |
| [in] | repeateTimes | integer specifying the number of times to generate the onion message for each value of the array onionPathsLengths |
Definition at line 73 of file sink.cc.
References m_numOnionLengths, m_onionPathLengths, and m_repeateTimes.
| void ns3::Sink::SinkTasks | ( | ) |
Schedule the creation of a new onion based on the path length specified in m_onionPathLengths If all onions specified in m_onionPathLengths were executed for m_repeateTimes Then end the simulation.
Definition at line 163 of file sink.cc.
References m_nodeManager, m_numOnionLengths, m_onionLengthIndex, m_onionPathLengths, ns3::Wsn_node::m_outputManager, m_repeateCount, m_repeateTimes, PrepareOnion(), and SelectRoute().
Referenced by CheckOnion(), RecvOnion(), and StartApplication().
Here is the call graph for this function:
Here is the caller graph for this function:
|
privatevirtual |
1.Start the application run ns3::Wsn_node::Configure() 2.Generate new encryption keys 3.Set callback at new socket connection 4.Schedule the execution of ns3::Sink::SinkTasks() after m_onionDelay milliseconds 5.Schedule the execution of ns3::Sink::CheckOnion() after m_onionDelay milliseconds and 5 seconds
Reimplemented from ns3::Wsn_node.
Definition at line 346 of file sink.cc.
References Accept(), CheckOnion(), ns3::Wsn_node::Configure(), ns3::OnionManager::GenerateNewKeyPair(), ns3::OnionManager::GetPKtoString(), ns3::OnionManager::GetSKtoString(), ns3::Wsn_node::m_delay, m_numnodes, m_onionDelay, ns3::Wsn_node::m_onionManager, m_publickey, m_secretkey, ns3::Wsn_node::m_socket, and SinkTasks().
Here is the call graph for this function:
|
privatevirtual |
Stop the application.
Reimplemented from ns3::Wsn_node.
Definition at line 367 of file sink.cc.
References ns3::Wsn_node::m_socket.
|
private |
Definition at line 214 of file sink.h.
Referenced by GetTypeId(), and SendOnion().
|
private |
Definition at line 215 of file sink.h.
Referenced by GetTypeId(), and SendOnion().
|
private |
dummy decoy value used to obfuscate the value carried in the onion body
Definition at line 210 of file sink.h.
Referenced by SendOnion().
|
private |
maintain the onion size fixed by adding padding (after layer decryption)
Definition at line 213 of file sink.h.
Referenced by GetTypeId(), and SendOnion().
|
private |
hashmap to manage data about nodes in the WSN// pair <IP,publickey>
Definition at line 209 of file sink.h.
Referenced by PrepareOnion(), RecvHandshake(), SelectRoute(), and SinkTasks().
|
private |
The number of sensor nodes in the simulation.
Definition at line 206 of file sink.h.
Referenced by GetTypeId(), and StartApplication().
|
private |
size of the array m_onionPathsLengths
Definition at line 222 of file sink.h.
Referenced by Setup(), and SinkTasks().
|
private |
The sink will start sending onion messagess after OnionDelay seconds.
Definition at line 207 of file sink.h.
Referenced by GetTypeId(), and StartApplication().
|
private |
onion ID incremented each time a new onion is issued
Definition at line 225 of file sink.h.
Referenced by ReceivePacket(), and SendOnion().
|
private |
index of the current onion path length
Definition at line 220 of file sink.h.
Referenced by SinkTasks().
|
private |
array holding onion path lengths
Definition at line 221 of file sink.h.
Referenced by Setup(), and SinkTasks().
|
private |
|
private |
the encryption key: publickey
Definition at line 231 of file sink.h.
Referenced by PrepareOnion(), and StartApplication().
|
private |
how many times the onion was sent at the current path length
Definition at line 219 of file sink.h.
Referenced by CheckOnion(), and SinkTasks().
|
private |
Integer specifying the number of times to generate the onion message for each value in the m_onionPathsLengths.
Definition at line 218 of file sink.h.
Referenced by Setup(), and SinkTasks().
|
private |
the encryption key: secretkey
Definition at line 232 of file sink.h.
Referenced by StartApplication().