A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
qkd-app-004.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 QKD_SEND_H004
12#define QKD_SEND_H004
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-stream.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 QKDApp QKDApp004
42 *
43 * The QKDApp004 application implements communication
44 * to Local Key Management System and it establish secure
45 * communciation with counter-part QKDApp.
46 */
47
48/**
49 * @ingroup QKDApp
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 QKDApp 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.
57 *
58 */
59class QKDApp004 : public Application
60{
61public:
62 /**
63 * @brief Get the type ID.
64 * @return the object TypeId
65 */
66 static TypeId GetTypeId();
67 QKDApp004();
68 ~QKDApp004() override;
69
70 /**
71 * @brief QKD App states(App)
72 * States that refer to QKDApp data transmision!
73 */
87
95
96 void Setup(
97 std::string socketType,
98 std::string appId,
99 std::string remoteAppId,
100 const Address& appAddress,
102 const Address& kmAddress,
103 std::string type
104 );
105
106 void Setup(
107 std::string socketType,
108 std::string appId,
109 std::string remoteAppId,
110 const Address& appAddress,
112 const Address& kmAddress,
115 std::string type
116 );
117
118 /**
119 * @brief Set encryption and authentication type
120 * @param ecryptionType encryption type
121 * @param authenticationType authentication type
122 */
127 );
128
129 /**
130 * @brief Get key size for defined encryption algorithm
131 * @return uint32_t key size
132 */
134
135 /**
136 * @brief Get key size for defined authentication algorithm
137 * @return uint32_t key size
138 */
140
141 /**
142 * @brief Set state
143 * @param state new application state.
144 */
145 void SetState(State state);
146
147 /**
148 * @brief Returns the current state of the application.
149 * @return string current state of the application.
150 */
151 State GetState() const;
152
153 /**
154 * @brief Returns the current state of the application in string format.
155 * @return string current state of the application.
156 */
157 std::string GetAppStateString() const;
158
159 /**
160 * @brief Returns the given application state in string format.
161 * @param state An arbitrary state of an application.
162 * @return string given state equivalently expressed in string format.
163 */
164 static std::string GetAppStateString(State state);
165
166 /**
167 * @brief Get application identifier
168 * @return string application id
169 */
170 std::string GetId(){
171 return m_appId;
172 }
173
174 /**
175 * @brief Get peer application identifier
176 * @return string application id
177 */
178 std::string GetPeerId(){
179 return m_dstAppId;
180 }
181
182 /**
183 * @brief Get KMS Ipv4 address
184 * @return Ipv4Address address
185 */
187
188 /**
189 * @brief Get application Ipv4 address
190 * @return Ipv4Address address
191 */
193
194 /**
195 * @brief Get peer application Ipv4 address
196 * @return Ipv4Address address
197 */
199
200 /// Traced Callback: transmitted data packets.
202 /// Traced Callback: transmitted signaling packets.
204 /// Traced Callback: transmitted packets to KMS.
206 /// Traced Callback: received data packets.
208 ///Traced Callback: missed send packet call.
210 /// Traced Callback: received signaling packets.
212 /// Traced Callback: received packets from KMS.
214 /// The `StateTransition` trace source.
216
217protected:
218 void DoDispose() override;
219
220private:
221
222 /***
223 * STRUCTURES
224 */
231
232 /***
233 * SOCKETS AND HandleRead
234 */
235
236 /**
237 * @brief Callback function after the connection to the KMS has failed
238 * @param socket the connected socket
239 */
241
242 /**
243 * @brief Callback function after the connection to the KMS is complete
244 * @param socket the connected socket
245 */
247
248 /**
249 * @brief Callback function after the connection to the APP has failed
250 * @param socket the connected socket
251 */
253
254 /**
255 * @brief Callback function after the connection to the APP is complete
256 * @param socket the connected socket
257 */
259
260 /**
261 * @brief Callback function after the signaling connection to the APP has
262 * @param socket the connected socket
263 */
265
266 /**
267 * @brief Callback function after the signaling connection to the APP is complete
268 * @param socket the connected socket
269 */
271
272 /**
273 * @brief Callback function to notify that data to KMS has been sent
274 * @param socket the connected socket
275 * @param uint32_t amount of data sent
276 */
278
279 /**
280 * @brief Handle a connection close from KMS
281 * @param socket the connected socket
282 */
284
285 /**
286 * @brief Handle a connection close to KMS
287 * @param socket the connected socket
288 */
290
291 /**
292 * @brief Handle a connection error from KMS
293 * @param socket the connected socket
294 */
296
297 /**
298 * @brief Handle a connection error to KMS
299 * @param socket the connected socket
300 */
302
303 /**
304 * @brief Handle an incoming connection from KMS
305 * @param s the incoming connection socket
306 * @param from the address the connection is from
307 */
308 void HandleAcceptFromKMS(Ptr<Socket> s, const Address& from);
309
310 /**
311 * @brief Handle a connection close from peer QKD application
312 * @param socket the connected socket
313 */
315
316 /**
317 * @brief Handle a connection error from peer QKD application
318 * @param socket the connected socket
319 */
321
322 /**
323 * @brief Handle an incoming connection from peer QKD application
324 * @param s the incoming connection socket
325 * @param from the address the connection is from
326 */
327 void HandleAcceptFromApp(Ptr<Socket> s, const Address& from);
328
329 /**
330 * @brief Handle a signaling connection close from peer QKD application
331 * @param socket the connected socket
332 */
334
335 /**
336 * @brief Handle a signaling connection error from peer QKD application
337 * @param socket the connected socket
338 */
340
341 /**
342 * @brief Handle a signaling incoming connection from peer QKD application
343 * @param s the incoming connection socket
344 * @param from the address the connection is from
345 */
347
348 /**
349 * @brief Handle a packet received by the QKD application from KMS application
350 * @param socket the receiving socket
351 */
352 void HandleReadFromKMS(Ptr<Socket> socket);
353
354 /**
355 * @brief Handle a packet received by the QKD application from peer QKD application
356 * @param socket the receiving socket
357 */
358 void HandleReadFromApp(Ptr<Socket> socket);
359
360 /**
361 * @brief Handle a signaling packet received by the QKD application from peer QKD application
362 * @param socket the receiving socket
363 */
365
367
368 /**
369 * @brief Callback function after the connection for response from KMS has been received
370 * @param socket the connected socket
371 * @param address address of the KMS
372 */
373 bool ConnectionRequestedFromKMS(Ptr<Socket> socket, const Address &address);
374
375 /**
376 * @brief Callback function after the connection for response from KMS has been received
377 * @param socket the connected socket
378 * @param address address of the KMS
379 */
380 bool ConnectionRequestedFromApp(Ptr<Socket> socket, const Address &address);
381
382 /**
383 * @brief Callback function after the connection for response from KMS has been received
384 * @param socket the connected socket
385 * @param address address of the KMS
386 */
387 bool ConnectionRequestedSignalingFromApp(Ptr<Socket> socket, const Address &address);
388
389
390 /**
391 * @brief Prepare send socket to communicate with KMS Application
392 */
393 void PrepareSocketToKMS();
394
395 /**
396 * @brief Prepare send socket to communicate with QKD Application
397 */
398 void PrepareSocketToApp();
399
400 /**
401 * @brief Check for tcp segmentation of packets received from KMS
402 * @param packet
403 * @param address address of the KMS
404 * @param socket the connected socket
405 */
406 void PacketReceivedFromKMS(const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
407
408 /**
409 * @brief Check for tcp segmentation of signaling packets received from APP
410 * @param packet
411 * @param address address of the KMS
412 * @param socket the connected socket
413 */
414 void SignalingPacketReceivedFromApp(const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
415
416 /**
417 * @brief Check for tcp segmentation of signaling packets received from KMS
418 * @param packet
419 * @param address address of the KMS
420 * @param socket the connected socket
421 */
422 void DataPacketReceived(const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
423
424 /**
425 * @brief Process response from KMS application
426 * @param header received HTTP header
427 * @param packet received packet
428 * @param socket the receiving socket
429 */
430 void ProcessResponseFromKMS(HTTPMessage& header, Ptr<Packet> packet, Ptr<Socket> socket);
431
432 /**
433 * @brief Process signaling packets from peer QKD application
434 * @param header HTTP packet header
435 * @param packet received packet
436 * @param socket the receiving socket
437 */
439
440 /**
441 * @brief Process data packets from peer QKD application
442 * @param header QKDApp packet header
443 * @param packet received packet
444 * @param socket the receiving socket
445 */
446 void ProcessDataPacket(QKDAppHeader header, Ptr<Packet> packet, Ptr<Socket> socket);
447
448 /**
449 * @brief QKDApp reserves an association(Key_stream_ID)
450 * @param ksid unique identifier for the group of syncronized bits
451 * @param sessionType the purpose of given session
452 *
453 * Replica QKDApp always states KSID in OPEN_CONNECT call.
454 * Primary QKDApp does not state KSID(design decision).
455 * Each QKDApp is limited(by design decisions) to establish up to 2
456 * associations(one for encryption and one for authentification).
457 */
458 void OpenConnect(std::string ksid, KeyStreamSession::Type sessionType);
459
460 /**
461 * @brief Obtain the required amount of key material.
462 * @param ksid Unique identifier for the group of syncronized bits
463 *
464 * QKDApp request key via ETSI GS 004 interface. In current version
465 * QKDApps request keys in synchronous order and index is not specified!
466 */
467 void GetKeyFromKMS(std::string ksid);
468
469 /**
470 * @brief Terminate the association
471 * @param ksid Unique identifier of association
472 */
473 void Close(std::string ksid);
474
475 /**
476 * @brief Process response from KMS on OPEN_CONNECT call
477 * @param header received HTTP header
478 */
480
481 /**
482 * @brief Process Get Key response from KMS
483 * @param header received HTTP header
484 */
486
487 /**
488 * @brief Process response from KMS on CLOSE call
489 * @param header received HTTP header
490 */
491 void ProcessCloseResponse(HTTPMessage& header);
492
493 /**
494 * @brief Sends SEND_KSID request(for sender App004) or response(for receiver App004)
495 * @param ksid unique key stream identifier
496 * @param sessionType scope of the session
497 * @param statusCode HTTP status code in case is response
498 *
499 */
501
502 /**
503 * @brief Sends ESTABLISH_QUEUES request(for sende App004) or response(for receiver App004)
504 *
505 */
506 void EstablishQueues();
507
510 return "enc";
511 else
512 return "auth";
513 }
514
515 /*
516 * @brief Creates required key stream sessions
517 *
518 */
520
523
524 /**
525 * @brief Check if the associations are successfuly established
526 *
527 * If the associations are established, establishing queues is started!
528 */
529 void CheckStreamSessions();
530
531 /**
532 * @brief Application establishing key queues before establishing data traffic.
533 *
534 * Application can establish key queues of desired size prior to secure communication
535 * to support fast rekeying scenarios.
536 */
537 void CheckQueues();
538
539 /**
540 * @brief Add HTTP request to queue to map response later
541 * @param uri request URI
542 * @param sessionType session scope
543 *
544 */
546
547 /**
548 * @brief Pop HTTP request from the queue(mapping response)
549 * @param uri request URI
550 * @return KeyStreamSession::Type session scope
551 *
552 * Deletes request from the queue.
553 */
555
556 /**
557 * @brief Hashing for the Address class
558 */
560 {
561 /**
562 * @brief operator()
563 * @param x the address of which calculate the hash
564 * @return the hash of x
565 *
566 * Should this method go in address.h?
567 *
568 * It calculates the hash taking the uint32_t hash value of the ipv4 address.
569 * It works only for InetSocketAddresses(Ipv4 version)
570 */
571 size_t operator()(const Address &x) const
572 {
575 return std::hash<uint32_t>()(a.GetIpv4().Get());
576 }
577 };
578
579 void StartApplication() override;
580 void StopApplication() override;
581
582 void ScheduleTx();
583
584 /**
585 * @brief Transition tree of the application. Change states and take actions!
586 */
587 void AppTransitionTree();
588
589 /**
590 * @brief Get the packet payload content
591 * @param msgLength length of random string to generate
592 * @return string random string
593 */
594 std::string GetPacketContent(uint32_t msgLength = 0);
595
596 /**
597 * @brief Convert packet to string
598 * @param packet packet
599 * @return string packet as a string
600 */
601 std::string PacketToString(Ptr<Packet> packet);
602
603 std::vector<std::string> ReadUri(std::string s);
604
605 std::string IpToString(Ipv4Address address);
606
607
608 /**
609 * @brief QKDApp encrypts the data with obtained keys
610 * and sends this encrypted data to the peer QKDApp.
611 */
612 void SendPacket();
613
615
618
622
627
628 std::string m_socketType;
629
635
640
641 std::string m_dstAppId;
642 std::string m_appId;
643
644 //HTTP mapping responses to requests!
645 std::multimap<std::string, KeyStreamSession::Type> m_httpRequestsKMS;
646
649
651
652 //Crypto params
656 uint32_t m_authenticationTagLengthInBits; //!< length of the authentication tag in bits(32 by default)
657 uint32_t m_aesLifetime; //in packets!
658 TracedCallback<Ptr<Packet> > m_encryptionTrace; //!< trace callback for encryption
659 TracedCallback<Ptr<Packet> > m_decryptionTrace; //!< trace callback for decryption
660 TracedCallback<Ptr<Packet>, std::string > m_authenticationTrace; //!< trace callback for authentication
661 TracedCallback<Ptr<Packet>, std::string > m_deauthenticationTrace; //!< trace callback for authentication check
667
668 State m_state; //Application state!
669
670 std::vector<KMSPacket > m_queue_kms;
671
672 std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_kms; //!< Buffer for received packets(fragmentation)
673 std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_sig; //!< Buffer for received packets(fragmentation)
674 std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_qkdapp; //!< Buffer for received packets(fragmentation)
675
676 std::multimap<std::string, std::string> m_transitionMatrix; //!< transition map of protocol states
677
678};
679
680
681} // namespace ns3
682
683#endif /* QKD_SINK_H004 */
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-004.h:60
void HandlePeerErrorFromKMS(Ptr< Socket > socket)
Handle a connection error from KMS.
void PushHttpKmsRequest(std::string uri, KeyStreamSession::Type sessionType=KeyStreamSession::ENCRYPTION)
Add HTTP request to queue to map response later.
void HandlePeerCloseFromApp(Ptr< Socket > socket)
Handle a connection close from peer QKD application.
std::multimap< std::string, KeyStreamSession::Type > m_httpRequestsKMS
void HandleReadFromApp(Ptr< Socket > socket)
Handle a packet received by the QKD application from peer QKD application.
State GetState() const
Returns the current state of the application.
TracedCallback< Ptr< Packet >, std::string > m_deauthenticationTrace
trace callback for authentication check
void ConnectionToKMSSucceeded(Ptr< Socket > socket)
Callback function after the connection to the KMS is complete.
std::string GetAppStateString() const
Returns the current state of the application in string format.
Ipv4Address GetIp()
Get application Ipv4 address.
DataRate m_dataRate
Ptr< Socket > m_dataSocketApp
void SendKsid(std::string ksid, KeyStreamSession::Type sessionType, HTTPMessage::HttpStatus statusCode=HTTPMessage::Ok)
Sends SEND_KSID request(for sender App004) or response(for receiver App004)
void ConnectionToKMSFailed(Ptr< Socket > socket)
Callback function after the connection to the KMS has failed.
void HandleAcceptFromKMS(Ptr< Socket > s, const Address &from)
Handle an incoming connection from KMS.
uint32_t m_useCrypto
void OpenConnect(std::string ksid, KeyStreamSession::Type sessionType)
QKDApp reserves an association(Key_stream_ID)
std::vector< std::string > ReadUri(std::string s)
void RegisterAckTime(Time oldRtt, Time newRtt)
Ptr< Socket > m_socketToKMS
bool m_isSignalingConnectedToApp
uint32_t m_keyBufferLengthEncryption
TracedCallback< const std::string &, Ptr< const Packet > > m_rxSigTrace
Traced Callback: received signaling packets.
uint32_t m_encryption
Ptr< Socket > m_signalingSocketApp
void ProcessSignalingPacketFromApp(HTTPMessage &header, Ptr< Socket > socket)
Process signaling packets from peer QKD application.
void ProcessOpenConnectResponse(HTTPMessage &header)
Process response from KMS on OPEN_CONNECT call.
void ProcessGetKeyResponse(HTTPMessage &header)
Process Get Key response from KMS.
TracedCallback< Ptr< Packet >, std::string > m_authenticationTrace
trace callback for authentication
bool ConnectionRequestedSignalingFromApp(Ptr< Socket > socket, const Address &address)
Callback function after the connection for response from KMS has been received.
uint32_t m_keyBufferLengthAuthentication
uint32_t m_packetsSent
TracedCallback< Ptr< Packet > > m_encryptionTrace
trace callback for encryption
ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
The StateTransition trace source.
void CreateKeyStreamSessions()
std::string m_socketType
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_qkdapp
Buffer for received packets(fragmentation)
uint32_t m_packetSize
void Setup(std::string socketType, std::string appId, std::string remoteAppId, const Address &appAddress, const Address &remoteAppAddress, const Address &kmAddress, std::string type)
Ptr< KeyStreamSession > m_authStream
void DataToKMSSend(Ptr< Socket >, uint32_t)
Callback function to notify that data to KMS has been sent.
TracedCallback< const std::string &, Ptr< const Packet > > m_mxTrace
Traced Callback: missed send packet call.
void HandleAcceptSignalingFromApp(Ptr< Socket > s, const Address &from)
Handle a signaling incoming connection from peer QKD application.
uint32_t m_aesLifetime
bool m_primaryQueueEstablished
void PrepareSocketToKMS()
Prepare send socket to communicate with KMS Application.
void StartApplication() override
void HandleReadSignalingFromApp(Ptr< Socket > socket)
Handle a signaling packet received by the QKD application from peer QKD application.
bool m_isDataConnectedToApp
TracedCallback< const std::string &, Ptr< const Packet > > m_rxTrace
Traced Callback: received data packets.
EventId m_closeSocketEvent
std::string m_dstAppId
TracedCallback< const std::string &, Ptr< const Packet > > m_rxKmsTrace
Traced Callback: received packets from KMS.
void CheckStreamSessions()
Check if the associations are successfuly established.
void HandleAcceptFromApp(Ptr< Socket > s, const Address &from)
Handle an incoming connection from peer QKD application.
QKDEncryptor::EncryptionType m_encryptionType
uint32_t GetEncryptionKeySize()
Get key size for defined encryption algorithm.
void ConnectionSignalingToAppFailed(Ptr< Socket > socket)
Callback function after the signaling connection to the APP has.
EventId m_sendEvent
void EstablishQueues()
Sends ESTABLISH_QUEUES request(for sende App004) or response(for receiver App004)
void Close(std::string ksid)
Terminate the association.
void HandlePeerErrorSignalingFromApp(Ptr< Socket > socket)
Handle a signaling connection error from peer QKD application.
Ptr< KeyStreamSession > m_encStream
~QKDApp004() override
static TypeId GetTypeId()
Get the type ID.
void ProcessPacketsToKMSFromQueue()
void SetCryptoSettings(uint32_t encryptionType, uint32_t authenticationType, uint32_t authenticationTagLengthInBits)
Set encryption and authentication type.
uint32_t GetAuthenticationKeySize()
Get key size for defined authentication algorithm.
void StopApplication() override
Application specific shutdown code.
bool ConnectionRequestedFromKMS(Ptr< Socket > socket, const Address &address)
Callback function after the connection for response from KMS has been received.
uint32_t m_dataSent
uint16_t m_portSignaling
void ProcessCloseResponse(HTTPMessage &header)
Process response from KMS on CLOSE call.
void PacketReceivedFromKMS(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for tcp segmentation of packets received from KMS.
std::string GetPacketContent(uint32_t msgLength=0)
Get the packet payload content.
bool m_replicaQueueEstablished
void ConnectionSignalingToAppSucceeded(Ptr< Socket > socket)
Callback function after the signaling connection to the APP is complete.
void ConnectionToAppSucceeded(Ptr< Socket > socket)
Callback function after the connection to the APP is complete.
bool ConnectionRequestedFromApp(Ptr< Socket > socket, const Address &address)
Callback function after the connection for response from KMS has been received.
void SetState(State state)
Set state.
void SendPacket()
QKDApp encrypts the data with obtained keys and sends this encrypted data to the peer QKDApp.
std::multimap< std::string, std::string > m_transitionMatrix
transition map of protocol states
void SignalingPacketReceivedFromApp(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for tcp segmentation of signaling packets received from APP.
void ProcessDataPacket(QKDAppHeader header, Ptr< Packet > packet, Ptr< Socket > socket)
Process data packets from peer QKD application.
Ipv4Address GetPeerIp()
Get peer application Ipv4 address.
void HandlePeerErrorFromApp(Ptr< Socket > socket)
Handle a connection error from peer QKD application.
QKDEncryptor::AuthenticationType m_authenticationType
Ptr< QKDEncryptor > m_encryptor
void HandlePeerCloseSignalingFromApp(Ptr< Socket > socket)
Handle a signaling connection close from peer QKD application.
std::string GetSessionScope(KeyStreamSession::Type type)
uint32_t m_authenticationTagLengthInBits
length of the authentication tag in bits(32 by default)
void GetKeyFromKMS(std::string ksid)
Obtain the required amount of key material.
uint32_t m_master
State
QKD App states(App) States that refer to QKDApp data transmision!
Definition qkd-app-004.h:74
@ ESTABLISHING_ASSOCIATIONS
Definition qkd-app-004.h:77
void ProcessResponseFromKMS(HTTPMessage &header, Ptr< Packet > packet, Ptr< Socket > socket)
Process response from KMS application.
void HandlePeerCloseToKMS(Ptr< Socket > socket)
Handle a connection close to KMS.
void CheckQueues()
Application establishing key queues before establishing data traffic.
std::string IpToString(Ipv4Address address)
uint32_t m_authentication
std::string GetId()
Get application identifier.
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_sig
Buffer for received packets(fragmentation)
void ConnectionToAppFailed(Ptr< Socket > socket)
Callback function after the connection to the APP has failed.
void HandlePeerCloseFromKMS(Ptr< Socket > socket)
Handle a connection close from KMS.
TracedCallback< Ptr< Packet > > m_decryptionTrace
trace callback for decryption
Ipv4Address GetKmsIp()
Get KMS Ipv4 address.
void HandleReadFromKMS(Ptr< Socket > socket)
Handle a packet received by the QKD application from KMS application.
std::string PacketToString(Ptr< Packet > packet)
Convert packet to string.
static uint32_t m_applicationCounts
void AppTransitionTree()
Transition tree of the application.
TracedCallback< const std::string &, Ptr< const Packet > > m_txKmsTrace
Traced Callback: transmitted packets to KMS.
void DataPacketReceived(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for tcp segmentation of signaling packets received from KMS.
std::string GetPeerId()
Get peer application identifier.
std::vector< KMSPacket > m_queue_kms
void HandlePeerErrorToKMS(Ptr< Socket > socket)
Handle a connection error to KMS.
TracedCallback< const std::string &, Ptr< const Packet > > m_txSigTrace
Traced Callback: transmitted signaling packets.
void DoDispose() override
Destructor implementation.
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_kms
Buffer for received packets(fragmentation)
void PrepareSocketToApp()
Prepare send socket to communicate with QKD Application.
TracedCallback< const std::string &, Ptr< const Packet > > m_txTrace
Traced Callback: transmitted data packets.
KeyStreamSession::Type PopHttpKmsRequest(std::string uri)
Pop HTTP request from the queue(mapping response)
std::string m_appId
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()
KeyStreamSession::Type scope
static const uint32_t packetSize
Packet size generated at the AP.