A Discrete-Event Network Simulator
API
wsn_node.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 
3 /*
4 * Copyright (c) 2020 DLTLT
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 as
8 * published by the Free Software Foundation;
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 *
19 * Corresponding author: Niki Hrovatin <niki.hrovatin@famnit.upr.si>
20 */
21 
22 #ifndef WSN_NODE_H
23 #define WSN_NODE_H
24 
25 #include <fstream>
26 #include <iostream>
27 #include <string>
28 
29 #include "ns3/outputmanager.h"
30 #include "ns3/segmentnum.h"
31 #include "ns3/outputmanager.h"
32 #include "ns3/onionmanager.h"
33 #include "ns3/onionvalidator.h"
34 
35 #include "ns3/mobility-model.h"
36 #include "ns3/core-module.h"
37 #include "ns3/network-module.h"
38 #include "ns3/internet-module.h"
39 #include "ns3/olsr-module.h"
40 #include "ns3/wifi-module.h"
41 
42 #include "ns3/trace-source-accessor.h"
43 #include "ns3/packet.h"
44 
45 namespace ns3 {
46 
61 class Wsn_node : public Application
62 {
63 public:
68  static TypeId GetTypeId (void);
69 
75  Wsn_node ();
76 
84  void Configure (void);
85  //Node Degree
86 
97  void NodeDegree (double coord_x, double coord_y);
98 
113  void SendSegment (InetSocketAddress remote, Ptr<Packet> packet, bool b_onion);
114 
126  Ptr<Packet> RecvSegment (Ptr<Socket> socket);
138  Ptr<Packet> RecvSegment (Ptr<Socket> socket, Address &from);
139 
154  Ptr<Packet> RecvSeg (Ptr<Socket> socket, Ptr<Packet> p, Address from);
155 
167  uint32_t getNodeDelay (Ipv4Address node_address);
168 
175  void OnionReceived (void);
176 
184  void CheckSentOnion (int count);
185 
194  void DisableNode ();
195 
203  void ActivateNode ();
204 
212  void NotifyTx (Ptr<const Packet> packet);
213 
221  void NotifyRx (Ptr<const Packet> packet);
222 
223 protected:
224  uint16_t m_port;
225  Ptr<OutputManager> m_outputManager;
226  Ptr<OnionValidator> m_onionValidator;
227  Ipv4Address m_address;
228  Ptr<Socket> m_socket;
229  uint16_t m_delay;
231 
232  //To manage fragments
233  uint16_t f_mss;
235  Ptr<Packet>
237  Ipv4Address f_receivingAddress = Ipv4Address::GetAny ();
238 
239  // onion state
240  int o_hopCount = 0;
241  int o_sequenceNum = 0;
242 
243  uint16_t
245 
246  //trace source
247  TracedCallback<Ptr<const Packet>> m_appTx;
248  TracedCallback<Ptr<const Packet>> m_appRx;
249 
250 private:
257  virtual void StartApplication (void);
258 
264  virtual void StopApplication (void);
265 };
266 } // namespace ns3
267 
268 #endif /* WSN_NODE_H */
ns3::Wsn_node::f_mss
uint16_t f_mss
maximum segment size
Definition: wsn_node.h:233
ns3::Wsn_node::f_segmentSize
int f_segmentSize
the size of the whole packet
Definition: wsn_node.h:234
ns3::Wsn_node::m_socket
Ptr< Socket > m_socket
listening socket
Definition: wsn_node.h:228
ns3::Wsn_node::RecvSegment
Ptr< Packet > RecvSegment(Ptr< Socket > socket)
method for receiving a segment calls ns3::Wsn_node::RecvSeg()
Definition: wsn_node.cc:249
ns3::Wsn_node::o_hopCount
int o_hopCount
track how the onion is is transiting in the network
Definition: wsn_node.h:240
ns3::OnionManager
Class that manages encryption keys and the encryption and decryption of layers of onion messagess The...
Definition: onionmanager.h:47
ns3::Wsn_node::o_sequenceNum
int o_sequenceNum
sequence number of the onion, should be same as onion_id
Definition: wsn_node.h:241
ns3
Definition: sensornode-helper.cc:26
ns3::Wsn_node::SendSegment
void SendSegment(InetSocketAddress remote, Ptr< Packet > packet, bool b_onion)
Send a packet through a TCP connection to the remote address.
Definition: wsn_node.cc:217
ns3::Wsn_node::getNodeDelay
uint32_t getNodeDelay(Ipv4Address node_address)
compute when the node should start the handshake process from the node ip address Used to not generat...
Definition: wsn_node.cc:198
ns3::Wsn_node::m_onionValidator
Ptr< OnionValidator > m_onionValidator
Pointer to the ns3::OnionValidator.
Definition: wsn_node.h:226
ns3::Wsn_node::m_appTx
TracedCallback< Ptr< const Packet > > m_appTx
traced callback for packet transmission
Definition: wsn_node.h:247
ns3::Wsn_node::m_address
Ipv4Address m_address
ns3::Ipv4Address of this node
Definition: wsn_node.h:227
ns3::Wsn_node::f_pendingPacket
Ptr< Packet > f_pendingPacket
pointer to the packet where received segment fragments are stored
Definition: wsn_node.h:236
ns3::Wsn_node::StopApplication
virtual void StopApplication(void)
Stop the application.
Definition: wsn_node.cc:97
ns3::Wsn_node::m_onionTimeout
uint16_t m_onionTimeout
timer in seconds, if elepsed and the onion was not recieved by the next receiver, then delete the oni...
Definition: wsn_node.h:244
ns3::Wsn_node::NotifyRx
void NotifyRx(Ptr< const Packet > packet)
Call to signal the receipt of a Packet at the application layer.
Definition: wsn_node.cc:82
ns3::Wsn_node::m_onionManager
OnionManager m_onionManager
The ns3::OnionManager object.
Definition: wsn_node.h:230
ns3::Wsn_node::m_outputManager
Ptr< OutputManager > m_outputManager
Pointer to the ns3::OutputManager.
Definition: wsn_node.h:225
ns3::Wsn_node::DisableNode
void DisableNode()
The method disables the node.
Definition: wsn_node.cc:135
ns3::Wsn_node::CheckSentOnion
void CheckSentOnion(int count)
The method checks if the onion was received by the next receiving node If the onion was not received ...
Definition: wsn_node.cc:321
ns3::Wsn_node::m_appRx
TracedCallback< Ptr< const Packet > > m_appRx
traced callback for packet receipt
Definition: wsn_node.h:248
ns3::Wsn_node::m_port
uint16_t m_port
port of the application
Definition: wsn_node.h:224
ns3::Wsn_node::ActivateNode
void ActivateNode()
The method re-activates a node that was disabled using the DisableNode() method.
Definition: wsn_node.cc:146
ns3::Wsn_node
The wsn node base class that manages the sending and receiving of packets and basic configuration of ...
Definition: wsn_node.h:61
ns3::Wsn_node::StartApplication
virtual void StartApplication(void)
Start the application.
Definition: wsn_node.cc:92
ns3::Wsn_node::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition: wsn_node.cc:36
ns3::Wsn_node::Wsn_node
Wsn_node()
Default constructor.
Definition: wsn_node.cc:87
ns3::Wsn_node::NotifyTx
void NotifyTx(Ptr< const Packet > packet)
Call to signal the transmission of a Packet at the application layer.
Definition: wsn_node.cc:76
ns3::Wsn_node::Configure
void Configure(void)
1.
Definition: wsn_node.cc:102
ns3::Wsn_node::OnionReceived
void OnionReceived(void)
Signal to the ns3::OnionValidator that the onion was corrctly received.
Definition: wsn_node.cc:331
ns3::Wsn_node::NodeDegree
void NodeDegree(double coord_x, double coord_y)
Retrieve the degreee this node from the OLSR routing protocol.
Definition: wsn_node.cc:163
ns3::Wsn_node::RecvSeg
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 segm...
Definition: wsn_node.cc:279
ns3::Wsn_node::f_receivingAddress
Ipv4Address f_receivingAddress
the receiving address
Definition: wsn_node.h:237
ns3::Wsn_node::m_delay
uint16_t m_delay
delay after which the handshake process will start
Definition: wsn_node.h:229