A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
qkd-app-014.h
Go to the documentation of this file.
1/*
2 * Copyright(c) 2020 DOTFEESA www.tk.etf.unsa.ba
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 *
7 *
8 * Author: Emir Dervisevic <emir.dervisevic@etf.unsa.ba>
9 * Miralem Mehic <miralem.mehic@ieee.org>
10 */
11#ifndef QKD014_SEND_H
12#define QKD014_SEND_H
13
14#include "ns3/application.h"
15#include "ns3/event-id.h"
16#include "ns3/ptr.h"
17#include "ns3/traced-callback.h"
18#include "ns3/address.h"
19#include "ns3/core-module.h"
20#include "ns3/applications-module.h"
21#include "ns3/core-module.h"
22#include "http.h"
23#include "qkd-app-header.h"
24#include "ns3/qkd-encryptor.h"
25#include "ns3/app-key.h"
26#include <unordered_map>
27#include <string>
28
29#include <iostream>
30#include <sstream>
31#include <unistd.h>
32
33namespace ns3 {
34
35class Address;
36class Socket;
37class Packet;
38
39/**
40 * @ingroup applications
41 * @defgroup qkd QKDApp014
42 *
43 * The QKDApp014 application implements communication
44 * to Local Key Management System and it establish secure
45 * communciation with counter-part QKDApp014.
46 */
47
48/**
49 * @ingroup qkd
50 *
51 * @brief Establish secure communication on application lavel to use the key and test LKSM
52 *
53 * This application was written to complement simple application to consume keys
54 * so a generic QKDApp014 name was selected. The application(Alice) implements sockets for
55 * connection with counter-party application(Bob) and implements sockets for
56 * communication with local key management system. At the moment, application follows
57 * ETSI QKD 014 standardization exchanging HTTP requests/responses to obtain details about
58 * the key from its local key management system. Obtained keys from Get key response are stored
59 * in temporary memory on master QKDApp014(Alice) in JSON data structure, from where they are moved
60 * to an application key buffer when confirmation of keys from peer application(Bob) is recieved.
61 * Keys obtained from Get key with key IDs are directly stored to the application key buffer and
62 * confirmation message for keys is sent to its peer application(Alice). Application(Alice) use
63 * keys from the application key buffer to apply security services on its data. QKD application
64 * header is then added to the protected data and sent to peer application. Slave QKD
65 * application(Bob) will process recieved protected packet based on information in QKD header
66 * and keys from the application key buffer. Communication between peers needed to negotiate keys
67 * was not included in ETSI014, and this application use HTTP messages for this purpose.
68 *
69 */
70class QKDApp014 : public Application
71{
72public:
73 /**
74 * @brief Get the type ID.
75 * @return the object TypeId
76 */
77 static TypeId GetTypeId();
78 QKDApp014();
79 ~QKDApp014() override;
80
81 /**
82 * @brief QKD App states(App)
83 * States that refer to QKDApp014 data transmision!
84 */
94
95 void Setup(
96 std::string socketType,
97 std::string appId,
98 std::string remoteAppId,
99 const Address& appAddress,
101 const Address& kmAddress,
104 std::string type
105 );
106
107 void Setup(
108 std::string socketType,
109 std::string appId,
110 std::string remoteAppId,
111 const Address& appAddress,
113 const Address& kmAddress,
114 std::string type
115 );
116
117
118 /**
119 * @brief Initialize key stores at application layer
120 */
121 void InitKeyStores();
122
123 /**
124 * @brief Get key from key store
125 * @param keyType key type(encryption or authentication)
126 * @param keyId key identifier(optional)
127 */
128 Ptr<AppKey> GetLocalKey(std::string keyType, std::string keyId = "");
129
130 /**
131 * @brief Print status information on key stores
132 */
133 void PrintStoreStats();
134
135 /**
136 * @brief Checks the state of the key stores
137 *
138 * Function checks ste state of the application key stores
139 * and submits get_key request if neccessary.
140 */
141 void ManageStores();
142
143 /**
144 * @brief Checks the conditions to change the application state
145 *
146 * Based on the states of the key stores, the application
147 * will change its states between READY and WAIT.
148 */
149 void CheckAppState();
150
151 /**
152 * @brief returns application state
153 * @return State application state
154 */
155 State GetState() const {
156 return m_state;
157 }
158
159 /**
160 * @brief set application state
161 * @param state application state
162 */
163 void SetState(State state){
164 m_state = state;
165 }
166
167 /**
168 * @brief Get status from local KMS
169 *
170 * Method defined by the ETSI QKD 014 document
171 */
172 void GetStatusFromKMS();
173
174 /**
175 * @brief Get keys from local KMS
176 * @param keyType key type(encryption or authentication)
177 *
178 * Method defined by the ETSI QKD 014 document
179 */
180 void GetKeysFromKMS(std::string keyType);
181
182 /**
183 * @brief Get keys identified with given IDs from local KMS
184 * @param keyIds key identifiers in JSON key_Ids string format
185 *
186 * Method defined by the ETSI QKD 014 document
187 */
188 void GetKeyWithKeyIDs(std::string keyIds);
189
190 /**
191 * @brief Callback function after the connection to the KMS has failed
192 * @param socket the connected socket
193 */
195
196 /**
197 * @brief Callback function after the connection to the KMS is complete
198 * @param socket the connected socket
199 */
201
202 /**
203 * @brief Callback function after the connection to the APP has failed
204 * @param socket the connected socket
205 */
207
208 /**
209 * @brief Callback function after the connection to the APP is complete
210 * @param socket the connected socket
211 */
213
214 /**
215 * @brief Callback function after the signaling connection to the APP has
216 * @param socket the connected socket
217 */
219
220 /**
221 * @brief Callback function after the signaling connection to the APP is complete
222 * @param socket the connected socket
223 */
225
226 /**
227 * @brief Callback function to notify that data to KMS has been sent
228 * @param socket the connected socket
229 * @param uint32_t amount of data sent
230 */
232
233 /**
234 * @brief Handle a packet received by the QKD application from KMS application
235 * @param socket the receiving socket
236 */
237 void HandleReadFromKMS(Ptr<Socket> socket);
238
239 /**
240 * @brief Handle a connection close from KMS
241 * @param socket the connected socket
242 */
244
245 /**
246 * @brief Handle a connection error from KMS
247 * @param socket the connected socket
248 */
250
251 /**
252 * @brief Handle an incoming connection from KMS
253 * @param s the incoming connection socket
254 * @param from the address the connection is from
255 */
256 void HandleAcceptFromKMS(Ptr<Socket> s, const Address& from);
257
258 /**
259 * @brief Handle a packet received by the QKD application from peer QKD application
260 * @param socket the receiving socket
261 */
262 void HandleReadFromApp(Ptr<Socket> socket);
263
264 /**
265 * @brief Handle a connection close from peer QKD application
266 * @param socket the connected socket
267 */
269
270 /**
271 * @brief Handle a connection error from peer QKD application
272 * @param socket the connected socket
273 */
275
276 /**
277 * @brief Handle an incoming connection from peer QKD application
278 * @param s the incoming connection socket
279 * @param from the address the connection is from
280 */
281 void HandleAcceptFromApp(Ptr<Socket> s, const Address& from);
282
283 /**
284 * @brief Handle a signaling packet received by the QKD application from peer QKD application
285 * @param socket the receiving socket
286 */
288
289 /**
290 * @brief Handle a signaling connection close from peer QKD application
291 * @param socket the connected socket
292 */
294
295 /**
296 * @brief Handle a signaling connection error from peer QKD application
297 * @param socket the connected socket
298 */
300
301 /**
302 * @brief Handle a signaling incoming connection from peer QKD application
303 * @param s the incoming connection socket
304 * @param from the address the connection is from
305 */
307
308 /**
309 * @brief Callback function after the connection for response from KMS has been received
310 * @param socket the connected socket
311 * @param address address of the KMS
312 */
313 bool ConnectionRequestedFromKMS(Ptr<Socket> socket, const Address &address);
314
315 /**
316 * @brief Callback function after the connection for response from KMS has been received
317 * @param socket the connected socket
318 * @param address address of the KMS
319 */
320 bool ConnectionRequestedFromApp(Ptr<Socket> socket, const Address &address);
321
322 /**
323 * @brief Callback function after the connection for response from KMS has been received
324 * @param socket the connected socket
325 * @param address address of the KMS
326 */
327 bool ConnectionRequestedSignalingFromApp(Ptr<Socket> socket, const Address &address);
328
329 /**
330 * @brief Check for tcp segmentation of packets received
331 * @param packet
332 * @param address address of the KMS
333 * @param socket the connected socket
334 */
335 void HttpPacketReceived(const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
336
337 /**
338 * @brief Check for tcp segmentation of signaling packets received from KMS
339 * @param packet
340 * @param address address of the KMS
341 * @param socket the connected socket
342 */
343 void QAppPacketReceived(const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
344
345 /**
346 * @brief Process response from KMS application
347 * @param header received HTTP header
348 * @param packet received packet
349 * @param socket the receiving socket
350 */
351 void ProcessResponseFromKMS(HTTPMessage& header, Ptr<Packet> packet, Ptr<Socket> socket);
352
353 /**
354 * @brief Process signaling packets from peer QKD application
355 * @param header HTTP packet header
356 * @param packet received packet
357 * @param socket the receiving socket
358 */
360
361 /**
362 * @brief Process data packets from peer QKD application
363 * @param header QKDApp014 packet header
364 * @param packet received packet
365 * @param socket the receiving socket
366 */
367 void ProcessDataPacket(QKDAppHeader header, Ptr<Packet> packet, Ptr<Socket> socket);
368
369 /**
370 * @brief Prepare send socket to communicate with KMS Application
371 */
372 void PrepareSocketToKMS();
373
374 /**
375 * @brief Prepare send socket to communicate with QKD Application
376 */
377 void PrepareSocketToApp();
378
379 /**
380 * @brief Schedule action to performe
381 * @param time eventTime
382 * @param string eventAction
383 */
384 void ScheduleAction(Time t, std::string action);
385
386
387
388 /**
389 * @brief Set encryption and authentication type
390 * @param ecryptionType encryption type
391 * @param authenticationType authentication type
392 */
397 );
398
399 /**
400 * @brief Get key size for defined encryption algorithm
401 * @return uint32_t key size
402 */
404
405 /**
406 * @brief Get key size for defined authentication algorithm
407 * @return uint32_t key size
408 */
410
411 /**
412 * @brief Returns the current state of the application in string format.
413 * @return string current state of the application.
414 */
415 std::string GetAppStateString() const;
416
417 /**
418 * @brief Returns the given application state in string format.
419 * @param state An arbitrary state of an application.
420 * @return string given state equivalently expressed in string format.
421 */
422 static std::string GetAppStateString(State state);
423
424 /**
425 * @brief Get the application ID
426 * @return uint32_t application ID
427 */
428 std::string GetId(){
429 return m_id;
430 }
431
432 /**
433 * @brief Get ipv4 address of source
434 * @return ipv4 address
435 */
437
438 /**
439 * @brief Get ipv4 address of destination
440 * @return ipv4 address
441 */
443
444 /**
445 * @brief Get ipv4 address of local KMS
446 * @return ipv4 address
447 */
449
450protected:
451 void DoDispose() override;
452
453private:
454
455 /**
456 * @brief Read http uri in vector
457 * @param s uri string
458 * @return vector of uri parameters
459 */
460 std::vector<std::string> ReadUri(std::string s);
461
462 /**
463 * @brief Convert ipv4 address in string
464 * @param address ipv4 address
465 * @return string ipv4 address
466 */
467 std::string IpToString(Ipv4Address address);
468
469 /**
470 * @brief Adds HTTP request to kms queue to properly map response later
471 * @param input key type
472 */
473 void PushHttpKmsRequest(std::string input);
474
475 /**
476 * @brief Adds HTTP request to app queue to properly map response later
477 * @param keyIds vector of key ids
478 */
479 void PushHttpAppRequest(std::vector<std::string> keyIds);
480
481 /**
482 * @brief Pop HTTP request from kms queue
483 * @return string key type
484 *
485 * It deletes request from queue!
486 */
487 std::string PopHttpKmsRequest();
488
489 /**
490 * @brief Pop HTTP request from app queue
491 * @return vector of strings key ids
492 *
493 * It deletes request from queue!
494 */
495 std::vector<std::string> PopHttpAppRequest();
496
497 /**
498 * @brief Create encryption key id field for the QKDApp header
499 * @param keyId key ID used to create encryption key id field
500 * @return string key ID prepared to be added to the field
501 */
502 std::string CreateKeyIdField(std::string keyId);
503
504 /**
505 * @brief Read key ID from the encryption key ID field of the QKDApp header
506 * @param keyId key ID from the encryption key ID field
507 * @return string read key ID
508 */
509 std::string ReadKeyIdField(std::string keyId);
510
511
512 /**
513 * @brief Hashing for the Address class
514 */
516 {
517 /**
518 * @brief operator()
519 * @param x the address of which calculate the hash
520 * @return the hash of x
521 *
522 * Should this method go in address.h?
523 *
524 * It calculates the hash taking the uint32_t hash value of the ipv4 address.
525 * It works only for InetSocketAddresses(Ipv4 version)
526 */
527 size_t operator()(const Address &x) const
528 {
531 return std::hash<uint32_t>()(a.GetIpv4().Get());
532 }
533 };
534
535 /**
536 * @brief Start application
537 */
538 void StartApplication() override;
539
540 /**
541 * @brief Stop application
542 */
543 void StopApplication() override;
544
545 /**
546 * @brief Schedule event to send data
547 */
548 void ScheduleTx();
549
550 /**
551 * @brief Send protected data
552 *
553 * App014 encrypts the data with obtained keys
554 * and sends this encrypted data to the peer.
555 */
556 void SendDataPacket();
557
558
559 /**
560 * @brief Transition tree of the application. Change states and take actions!
561 */
562 void AppTransitionTree();
563
564 /**
565 * @brief Change the state of the application. Fires the `AppStateTransition` trace source.
566 * @param state The new application state.
567 */
568 void SwitchAppState(State state);
569
570 /**
571 * @brief Get the packet payload content
572 * @param msgLength length of random string to generate
573 * @return string random string
574 */
575 std::string GetPacketContent(uint32_t msgLength = 0);
576
577 /**
578 * @brief Implementation of send KEY_IDS notification
579 * @param keyIds key identifiers
580 * @param statusCode http status code of response(default status is Ok)
581 *
582 * Master App014(Alice) sends key IDs of obtained keys from KMS
583 * that will be used for encryption of outgoing messages. Slave App014
584 *(Bob) agree or disagree on proposed key IDs.
585 */
586 void SendKeyIds(std::vector<std::string> keyIds, HTTPMessage::HttpStatus statusCode = HTTPMessage::Ok);
587
588
589 //Sockets
590 std::string m_socketType;
596
597 //Addresses
598 Address m_peer; //!< peer address
599 Address m_local; //!< local address
600 Address m_kms; //!< local kms address
602
603 //HTTP mappings
604 std::vector<std::string> m_kmsHttpReqQueue;
605 std::vector<std::vector<std::string> > m_appHttpReqQueue;
606
607 //App params
608 static uint32_t m_applicationCounts; //!< application count
609 TypeId m_tid; //!< tid
610 State m_state; //!< application state
611 uint32_t m_master; //!< is master App014
612 std::string m_dstId; //!< destination application id
613 std::string m_id; //!< source application id
614 uint32_t m_size; //!< data packet size
615 DataRate m_rate; //!< data rate
616
617 //Stores
618 std::map<std::string, Ptr<AppKey>> m_commonStore; //<! temporary/inbound key store
619 std::map<std::string, Ptr<AppKey>> m_encStore; //<! encryption key store
620 std::map<std::string, Ptr<AppKey>> m_authStore; //<! authentication key store
621
622 Time m_waitInsufficient; //!< time wait before submitting new get_key after error
623
624 //Crypto params
625 uint32_t m_numberOfKeysKMS; //!< number of keys to fetch per request
626 uint32_t m_useCrypto; //!< execute crypo algorithms
627 uint32_t m_encryption; //!< encryption type
628 uint32_t m_authentication; //!< authentication type
629 uint32_t m_authTagSize; //!< length of the authentication tag in bits
630 uint32_t m_aesLifetime; //!< key lifetime in bytes
631
635
636 //Traces
637 TracedCallback<Ptr<Packet> > m_encryptionTrace; //!< trace callback for encryption
638 TracedCallback<Ptr<Packet> > m_decryptionTrace; //!< trace callback for decryption
639 TracedCallback<Ptr<Packet>, std::string > m_authenticationTrace; //!< trace callback for authentication
640 TracedCallback<Ptr<Packet>, std::string > m_deauthenticationTrace; //!< trace callback for authentication check
641
642 /// Traced Callback: transmitted data packets.
644 /// Traced Callback: transmitted signaling packets.
646 /// Traced Callback: transmitted packets to KMS.
648 /// Traced Callback: received data packets.
650 /// Traced Callback: received signaling packets.
652 /// Traced Callback: received packets from KMS.
654 ///Traced Callback: missed send packet call.
656 /// The `StateTransition` trace source.
658
659 std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_kms; //!< Buffer for received packets(fragmentation)
660 std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_QKDApp014; //!< Buffer for received packets(fragmentation)
661
662 bool m_internalAppWait; //Indicate if the longer wait is required(used after GetKey error!)
665
666 std::multimap<std::string, std::string> m_transitionMatrix; //!< transition map of protocol states
667
668};
669
670
671} // namespace ns3
672
673#endif /* QKD_SINK_H */
a polymophic address class
Definition address.h:90
The base class for all ns3 applications.
Definition application.h:51
Class for representing data rates.
Definition data-rate.h:78
An identifier for simulation events.
Definition event-id.h:45
The basic class to represent both HTTP requests and responses.
Definition http.h:77
an Inet address class
static bool IsMatchingType(const Address &address)
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
Ipv4 addresses are stored in host order in this class.
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:66
Establish secure communication on application lavel to use the key and test LKSM.
Definition qkd-app-014.h:71
void SetState(State state)
set application state
void AppTransitionTree()
Transition tree of the application.
uint32_t m_master
is master App014
void HandleAcceptFromKMS(Ptr< Socket > s, const Address &from)
Handle an incoming connection from KMS.
std::string PopHttpKmsRequest()
Pop HTTP request from kms queue.
TracedCallback< const std::string &, Ptr< const Packet > > m_rxKmsTrace
Traced Callback: received packets from KMS.
Ptr< Socket > m_dataSocketApp
void HandleReadFromKMS(Ptr< Socket > socket)
Handle a packet received by the QKD application from KMS application.
std::map< std::string, Ptr< AppKey > > m_authStore
void QAppPacketReceived(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for tcp segmentation of signaling packets received from KMS.
Ptr< QKDEncryptor > m_encryptor
encryptor
std::vector< std::string > m_kmsHttpReqQueue
void ConnectionSignalingToAppSucceeded(Ptr< Socket > socket)
Callback function after the signaling connection to the APP is complete.
void SwitchAppState(State state)
Change the state of the application.
TracedCallback< const std::string &, Ptr< const Packet > > m_txTrace
Traced Callback: transmitted data packets.
std::string CreateKeyIdField(std::string keyId)
Create encryption key id field for the QKDApp header.
void ProcessDataPacket(QKDAppHeader header, Ptr< Packet > packet, Ptr< Socket > socket)
Process data packets from peer QKD application.
void HandlePeerCloseSignalingFromApp(Ptr< Socket > socket)
Handle a signaling connection close from peer QKD application.
void ConnectionSignalingToAppFailed(Ptr< Socket > socket)
Callback function after the signaling connection to the APP has.
bool ConnectionRequestedFromApp(Ptr< Socket > socket, const Address &address)
Callback function after the connection for response from KMS has been received.
TracedCallback< const std::string &, Ptr< const Packet > > m_rxSigTrace
Traced Callback: received signaling packets.
State GetState() const
returns application state
TracedCallback< const std::string &, Ptr< const Packet > > m_txKmsTrace
Traced Callback: transmitted packets to KMS.
std::string GetPacketContent(uint32_t msgLength=0)
Get the packet payload content.
Ipv4Address GetPeerIp()
Get ipv4 address of destination.
void HandlePeerErrorFromKMS(Ptr< Socket > socket)
Handle a connection error from KMS.
Ptr< Socket > m_signalingSocketApp
TracedCallback< const std::string &, Ptr< const Packet > > m_mxTrace
Traced Callback: missed send packet call.
void InitKeyStores()
Initialize key stores at application layer.
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_kms
Buffer for received packets(fragmentation)
TypeId m_tid
tid
void StartApplication() override
Start application.
void Setup(std::string socketType, std::string appId, std::string remoteAppId, const Address &appAddress, const Address &remoteAppAddress, const Address &kmAddress, uint32_t packetSize, DataRate dataRate, std::string type)
uint32_t m_aesLifetime
key lifetime in bytes
Time m_waitInsufficient
time wait before submitting new get_key after error
void ConnectionToKMSSucceeded(Ptr< Socket > socket)
Callback function after the connection to the KMS is complete.
State
QKD App states(App) States that refer to QKDApp014 data transmision!
Definition qkd-app-014.h:85
Ptr< Socket > m_socketToKMS
void PrintStoreStats()
Print status information on key stores.
static TypeId GetTypeId()
Get the type ID.
Ipv4Address GetIp()
Get ipv4 address of source.
void SendDataPacket()
Send protected data.
std::vector< std::string > PopHttpAppRequest()
Pop HTTP request from app queue.
Ptr< AppKey > GetLocalKey(std::string keyType, std::string keyId="")
Get key from key store.
void HandleAcceptSignalingFromApp(Ptr< Socket > s, const Address &from)
Handle a signaling incoming connection from peer QKD application.
EventId m_scheduleManageStores
uint32_t GetAuthenticationKeySize()
Get key size for defined authentication algorithm.
std::string m_id
source application id
void ManageStores()
Checks the state of the key stores.
void HandlePeerCloseFromKMS(Ptr< Socket > socket)
Handle a connection close from KMS.
State m_state
application state
uint32_t GetEncryptionKeySize()
Get key size for defined encryption algorithm.
uint32_t m_encryption
encryption type
std::string IpToString(Ipv4Address address)
Convert ipv4 address in string.
void PushHttpAppRequest(std::vector< std::string > keyIds)
Adds HTTP request to app queue to properly map response later.
void ProcessResponseFromKMS(HTTPMessage &header, Ptr< Packet > packet, Ptr< Socket > socket)
Process response from KMS application.
void PrepareSocketToApp()
Prepare send socket to communicate with QKD Application.
void HandleAcceptFromApp(Ptr< Socket > s, const Address &from)
Handle an incoming connection from peer QKD application.
void ConnectionToAppFailed(Ptr< Socket > socket)
Callback function after the connection to the APP has failed.
std::string GetAppStateString() const
Returns the current state of the application in string format.
Address m_kms
local kms address
std::vector< std::vector< std::string > > m_appHttpReqQueue
void GetKeyWithKeyIDs(std::string keyIds)
Get keys identified with given IDs from local KMS.
TracedCallback< Ptr< Packet >, std::string > m_authenticationTrace
trace callback for authentication
uint32_t m_numberOfKeysKMS
number of keys to fetch per request
std::string ReadKeyIdField(std::string keyId)
Read key ID from the encryption key ID field of the QKDApp header.
bool ConnectionRequestedFromKMS(Ptr< Socket > socket, const Address &address)
Callback function after the connection for response from KMS has been received.
std::string m_socketType
TracedCallback< Ptr< Packet > > m_encryptionTrace
trace callback for encryption
uint32_t m_authentication
authentication type
std::string GetId()
Get the application ID.
void ScheduleAction(Time t, std::string action)
Schedule action to performe.
DataRate m_rate
data rate
EventId m_sendEvent
uint32_t m_authTagSize
length of the authentication tag in bits
void StopApplication() override
Stop application.
void HandleReadFromApp(Ptr< Socket > socket)
Handle a packet received by the QKD application from peer QKD application.
void ScheduleTx()
Schedule event to send data.
TracedCallback< const std::string &, Ptr< const Packet > > m_rxTrace
Traced Callback: received data packets.
void HandlePeerErrorFromApp(Ptr< Socket > socket)
Handle a connection error from peer QKD application.
void ConnectionToAppSucceeded(Ptr< Socket > socket)
Callback function after the connection to the APP is complete.
TracedCallback< const std::string &, Ptr< const Packet > > m_txSigTrace
Traced Callback: transmitted signaling packets.
void ProcessSignalingPacketFromApp(HTTPMessage &header, Ptr< Packet > packet, Ptr< Socket > socket)
Process signaling packets from peer QKD application.
void DoDispose() override
Destructor implementation.
void GetKeysFromKMS(std::string keyType)
Get keys from local KMS.
bool m_isDataConnectedToApp
~QKDApp014() override
std::map< std::string, Ptr< AppKey > > m_commonStore
std::string m_dstId
destination application id
void DataToKMSSend(Ptr< Socket >, uint32_t)
Callback function to notify that data to KMS has been sent.
void ConnectionToKMSFailed(Ptr< Socket > socket)
Callback function after the connection to the KMS has failed.
ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
The StateTransition trace source.
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_QKDApp014
Buffer for received packets(fragmentation)
void SendKeyIds(std::vector< std::string > keyIds, HTTPMessage::HttpStatus statusCode=HTTPMessage::Ok)
Implementation of send KEY_IDS notification.
void GetStatusFromKMS()
Get status from local KMS.
Address m_local
local address
void HandlePeerErrorSignalingFromApp(Ptr< Socket > socket)
Handle a signaling connection error from peer QKD application.
static uint32_t m_applicationCounts
application count
void SetCryptoSettings(uint32_t encryptionType, uint32_t authenticationType, uint32_t authenticationTagLengthInBits)
Set encryption and authentication type.
void HttpPacketReceived(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for tcp segmentation of packets received.
void CheckAppState()
Checks the conditions to change the application state.
uint32_t m_useCrypto
execute crypo algorithms
void PrepareSocketToKMS()
Prepare send socket to communicate with KMS Application.
std::multimap< std::string, std::string > m_transitionMatrix
transition map of protocol states
Ipv4Address GetKmsIp()
Get ipv4 address of local KMS.
TracedCallback< Ptr< Packet >, std::string > m_deauthenticationTrace
trace callback for authentication check
std::map< std::string, Ptr< AppKey > > m_encStore
void HandleReadSignalingFromApp(Ptr< Socket > socket)
Handle a signaling packet received by the QKD application from peer QKD application.
bool ConnectionRequestedSignalingFromApp(Ptr< Socket > socket, const Address &address)
Callback function after the connection for response from KMS has been received.
TracedCallback< Ptr< Packet > > m_decryptionTrace
trace callback for decryption
std::vector< std::string > ReadUri(std::string s)
Read http uri in vector.
Address m_peer
peer address
uint32_t m_size
data packet size
QKDEncryptor::AuthenticationType m_authenticationType
authentication type
void HandlePeerCloseFromApp(Ptr< Socket > socket)
Handle a connection close from peer QKD application.
bool m_isSignalingConnectedToApp
QKDEncryptor::EncryptionType m_encryptionType
encryption type
uint16_t m_portSignaling
void PushHttpKmsRequest(std::string input)
Adds HTTP request to kms queue to properly map response later.
QKD app packet header that carries info about used encryption, auth tag and other.
EncryptionType
Encryption type.
AuthenticationType
Authentication type.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:49
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition abort.h:65
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hashing for the Address class.
size_t operator()(const Address &x) const
operator()
static const uint32_t packetSize
Packet size generated at the AP.