A Discrete-Event Network Simulator
API
qkd-key-association-link-entry.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2020 DOTFEESA www.tk.etf.unsa.ba
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Emir Dervisevic <emir.dervisevic@etf.unsa.ba>
19  * Miralem Mehic <miralem.mehic@ieee.org>
20  */
21 #include "ns3/log.h"
22 #include "ns3/address.h"
23 #include "ns3/node.h"
24 #include "ns3/nstime.h"
25 #include "ns3/simulator.h"
26 #include "ns3/uinteger.h"
27 #include "ns3/trace-source-accessor.h"
28 #include <iostream>
29 #include <fstream>
30 #include <string>
31 
32 #include "ns3/qkd-key-association-link-entry.h"
33 
34 namespace ns3 {
35 
36  NS_LOG_COMPONENT_DEFINE ("QKDKeyAssociationLinkEntry");
37 
38  NS_OBJECT_ENSURE_REGISTERED (QKDKeyAssociationLinkEntry);
39 
40  TypeId
42  {
43  static TypeId tid = TypeId ("ns3::QKDKeyAssociationLinkEntry")
44  .SetParent<Object> ()
45  .SetGroupName ("QKDKeyAssociationLinkEntry")
46  .AddConstructor<QKDKeyAssociationLinkEntry> ()
47  ;
48  return tid;
49  }
50 
51  TypeId
53  {
54  return GetTypeId ();
55  }
56 
58  m_valid = false;
59  }
60 
62  uint32_t local_qkd_node_id,
63  uint32_t remote_qkd_node_id,
64  uint32_t nextHop,
65  uint32_t hops,
66  uint32_t type, //Virtual (multi-hop) - value 1 or Direct - value 0.
67  Ipv4Address kmsSrcAddress,
68  Ipv4Address kmsDstAddress,
69  Ptr<QKDBuffer> srcBuffer
70  )
71  : m_qkdl_local_qkdn_id (local_qkd_node_id),
72  m_qkdl_remote_qkdn_id (remote_qkd_node_id),
73  m_qkdl_type (type),
74  m_virt_next_hop (nextHop),
75  m_kmsSrcAddress (kmsSrcAddress),
76  m_kmsDstAddress (kmsDstAddress),
77  m_hops (hops),
78  m_srcQKDBuffer(srcBuffer)
79  {
83  m_qkdl_performance_skr = 0; //init value
84  m_qkdl_enable = true;
85  m_valid = true;
86 
87  NS_LOG_FUNCTION(this
88  << "CREATE NEW KEY ASSOCIATION ENTRY!"
89  << m_qkdl_id
92  << m_virt_next_hop
93  << m_hops
97  );
98  }
99 
101  UUID qkd_id,
102  uint32_t local_qkd_node_id,
103  uint32_t remote_qkd_node_id,
104  uint32_t nextHop,
105  uint32_t hops,
106  uint32_t type, //Virtual (multi-hop) - value 1 or Direct - value 0.
107  Ipv4Address kmsSrcAddress,
108  Ipv4Address kmsDstAddress,
109  Ptr<QKDBuffer> srcBuffer
110  )
111  : m_qkdl_id (qkd_id),
112  m_qkdl_local_qkdn_id (local_qkd_node_id),
113  m_qkdl_remote_qkdn_id (remote_qkd_node_id),
114  m_qkdl_type (type),
115  m_virt_next_hop (nextHop),
116  m_kmsSrcAddress (kmsSrcAddress),
117  m_kmsDstAddress (kmsDstAddress),
118  m_hops (hops),
119  m_srcQKDBuffer(srcBuffer)
120  {
123  m_qkdl_performance_skr = 0; //init value
124  m_qkdl_enable = true;
125  m_valid = true;
126 
127  NS_LOG_FUNCTION(this
128  << "CREATE NEW KEY ASSOCIATION ENTRY!"
129  << m_qkdl_id
132  << m_virt_next_hop
133  << m_hops
134  << m_kmsSrcAddress
135  << m_kmsDstAddress
137  );
138  }
139 
141 
142  bool
144 
145  NS_LOG_FUNCTION(this << appId << m_qkdl_applications.size());
146 
147  std::vector<UUID>::iterator it = std::find(
148  m_qkdl_applications.begin(),
149  m_qkdl_applications.end(),
150  appId
151  );
152 
153  if(it == m_qkdl_applications.end()) {
154  NS_LOG_FUNCTION(this << "No SAE application found with UUID " << appId);
155  return false;
156  }
157  NS_LOG_FUNCTION(this << "SAE application with UUID " << appId << " FOUND!");
158  return true;
159  }
160 
161  void
163 
164  NS_LOG_FUNCTION(this << m_qkdl_applications.size());
165 
166  for(std::vector<UUID>::size_type i = 0; i != m_qkdl_applications.size(); i++) {
167  NS_LOG_FUNCTION(this << i << ": " << m_qkdl_applications[i]);
168  }
169  }
170 
171  void
173  m_qkdl_applications.push_back(appId);
174  }
175 
176  void
178  {
179  NS_LOG_FUNCTION(this
180  << m_qkdl_id
183  << m_virt_next_hop
184  << m_hops
185  << "apps:" << m_qkdl_applications.size()
186  << m_kmsSrcAddress
187  << m_kmsDstAddress
189  );
190  }
191 
192  void
194  {
195  *stream->GetStream ()
196  << m_qkdl_id << "\t"
197  << m_qkdl_local_qkdn_id << "\t"
198  << m_qkdl_remote_qkdn_id << "\t"
199  << m_virt_next_hop << "\t"
200  << m_hops << "\t"
201  << "apps:" << m_qkdl_applications.size() << "\t"
202  << m_kmsSrcAddress << "\t"
203  << m_kmsDstAddress << "\t"
204  << m_qkdl_performance_skr << "\n"
205  ;
206  }
207 
208  void
210  m_update_status_interval = statusInterval;
211  }
212 
213  double
215  return (double) m_update_status_interval;
216  }
217 
218  double
221  if (std::isnan(m_qkdl_performance_skr)) return 0;
222  return (double) m_qkdl_performance_skr;
223  }
224 
225  void
227  if (std::isnan(m_qkdl_performance_skr))
229  else
230  m_qkdl_performance_skr = value;
232  }
233 
234  double
237  if (std::isnan(m_qkdl_performance_expected_consumption)) return 0;
239  }
240 
241  void
245  else
248  }
249 
250  double
253  if (std::isnan(m_qkdl_performance_eskr)) return 0;
254  return (double) m_qkdl_performance_eskr;
255  }
256 
257  void
259  if (std::isnan(m_qkdl_performance_eskr))
261  else
262  m_qkdl_performance_eskr = value;
264  }
265 
266 } // namespace ns3
Ipv4 addresses are stored in host order in this class.
Definition: ipv4-address.h:41
A base class which provides memory management and object aggregation.
Definition: object.h:88
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:74
Introspection did not find any typical Config paths.
uint32_t m_virt_next_hop
Ipv4Address m_kmsSrcAddress
Ipv4Address m_kmsDstAddress
uint32_t m_qkdl_remote_qkdn_id
double GetEffectiveSKR()
virtual TypeId GetInstanceTypeId(void) const
Get the type ID for the instance.
void SetExpectedConsumption(double value)
void PrintRegistryInfo()
Print registry info.
bool m_valid
double m_qkdl_performance_eskr
QKDKeyAssociationLinkEntry()
uint32_t m_hops
double GetSKR()
double m_qkdl_performance_skr
std::vector< UUID > m_qkdl_applications
double GetExpectedConsumption()
bool m_qkdl_enable
void SetUpdateStatusInterval(double statusInterval)
double m_qkdl_performance_expected_consumption
double GetUpdateStatusInterval()
void SetSKR(double value)
void PrintSAEApplications()
~QKDKeyAssociationLinkEntry()
void Print(Ptr< OutputStreamWrapper > stream) const
Print routing table entry.
static TypeId GetTypeId(void)
Get the type ID.
bool CheckSAEApplicationExists(UUID saeId)
void UpdateQKDApplications(UUID saeId)
double m_update_status_interval
void SetEffectiveSKR(double value)
uint32_t m_qkdl_local_qkdn_id
UUID m_qkdl_id
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Universally unique identifier (UUID)
Definition: uuid.h:35
static UUID Random()
Generate random UUID4 (randomly or pseudo-randomly generated version)
Definition: uuid.cc:148
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.