A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
onionvalidator.cc
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
3
4
/*
5
* Copyright (c) 2020 DLTLT
6
*
7
* This program is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License version 2 as
9
* published by the Free Software Foundation;
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
*
20
* Corresponding author: Niki Hrovatin <niki.hrovatin@famnit.upr.si>
21
*/
22
23
24
#include "
onionvalidator.h
"
25
26
namespace
ns3
{
27
28
//Zagotovi, da se registrira TypeId
29
NS_OBJECT_ENSURE_REGISTERED (OnionValidator);
30
31
NS_LOG_COMPONENT_DEFINE (
"oniionvalidator"
);
32
33
TypeId
34
OnionValidator::GetTypeId
(
void
)
35
{
36
static
TypeId tid =
37
TypeId (
"ns3::OnionValidator"
).SetParent<Object> ().AddConstructor<OnionValidator> ();
38
return
tid;
39
}
40
41
OnionValidator::OnionValidator
()
42
{
43
}
44
45
OnionValidator::~OnionValidator
()
46
{
47
}
48
50
51
void
52
OnionValidator::StartOnion
(
int
seq_n)
53
{
54
m_onionSeq
= seq_n;
55
}
56
57
58
bool
59
OnionValidator::OnionStatus
(
void
)
60
{
61
62
if
(
m_onionSeq
== 0)
63
{
64
return
false
;
65
}
66
else
67
{
68
return
true
;
69
}
70
}
71
72
/*
73
Check if onion at hop was received, othervise abort sending
74
75
*/
76
77
bool
78
OnionValidator::CheckOnionReceived
(
int
hop)
79
{
80
81
if
(hop == this->
m_hopCount
)
82
{
83
//abort sending the onion
84
m_onionSeq
= 0;
// 0 is sequence 0 null value!!! onion will be deleted
85
return
false
;
86
}
87
return
true
;
88
}
89
90
//changes state of the onion status
91
int
92
OnionValidator::OnionHopCount
(
void
)
93
{
94
return
this->
m_hopCount
;
95
}
96
97
//Get the onion sequence number
98
int
99
OnionValidator::GetOnionSeq
(
void
)
100
{
101
return
m_onionSeq
;
102
}
103
104
//signals that the onion was completely received
105
void
106
OnionValidator::OnionReceived
(
void
)
107
{
108
this->
m_hopCount
++;
109
}
110
111
}
// namespace ns3
ns3
Definition:
sensornode-helper.cc:26
ns3::OnionValidator::GetOnionSeq
int GetOnionSeq(void)
Return the current onion sequence number (the onionId)
Definition:
onionvalidator.cc:99
ns3::OnionValidator::m_onionSeq
int m_onionSeq
the onionId of the onion currently transiting the network
Definition:
onionvalidator.h:131
ns3::OnionValidator::OnionReceived
void OnionReceived(void)
The onion was correctly received, increment the hop count.
Definition:
onionvalidator.cc:106
ns3::OnionValidator::m_hopCount
int m_hopCount
a sequence number incremented each time a node correctly receives an onion message
Definition:
onionvalidator.h:133
ns3::OnionValidator::CheckOnionReceived
bool CheckOnionReceived(int hop)
Called by the sensor nodes when the m_onionTimeout elapses IF m_hopCount is equal to hop then the oni...
Definition:
onionvalidator.cc:78
ns3::OnionValidator::~OnionValidator
~OnionValidator()
Default destructor.
Definition:
onionvalidator.cc:45
ns3::OnionValidator::OnionValidator
OnionValidator()
Default constructor.
Definition:
onionvalidator.cc:41
ns3::OnionValidator::GetTypeId
static TypeId GetTypeId(void)
Definition:
onionvalidator.cc:34
ns3::OnionValidator::OnionStatus
bool OnionStatus(void)
Called by the sink node to check if the onion is still running or is aborted.
Definition:
onionvalidator.cc:59
onionvalidator.h
ns3::OnionValidator::OnionHopCount
int OnionHopCount(void)
Return the current hop sequence number.
Definition:
onionvalidator.cc:92
ns3::OnionValidator::StartOnion
void StartOnion(int seq_n)
Called by the sink node, set up the m_onionSeq to the onionId value for keeping track of the onion.
Definition:
onionvalidator.cc:52
src
onion_routing_wsn
managers
onionvalidator.cc
Generated on Mon Feb 7 2022 13:31:58 for ns-3 by
1.8.17