A Discrete-Event Network Simulator
API
qkd-app-004.h
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 #ifndef QKD_SEND_H004
22 #define QKD_SEND_H004
23 
24 #include "ns3/application.h"
25 #include "ns3/event-id.h"
26 #include "ns3/ptr.h"
27 #include "ns3/traced-callback.h"
28 #include "ns3/address.h"
29 #include "ns3/core-module.h"
30 #include "ns3/applications-module.h"
31 #include "ns3/random-variable-stream.h"
32 #include "ns3/core-module.h"
33 #include "ns3/http.h"
34 #include "qkd-app-header.h"
35 #include "ns3/qkd-encryptor.h"
36 #include <unordered_map>
37 #include <string>
38 #include "ns3/uuid.h"
39 
40 #include <iostream>
41 #include <sstream>
42 #include <unistd.h>
43 
44 namespace ns3 {
45 
46 class Address;
47 class Socket;
48 class Packet;
49 
71 class QKDApp004 : public Application
72 {
73 public:
78  static TypeId GetTypeId (void);
79 
83  QKDApp004 ();
84 
88  virtual ~QKDApp004();
89 
95  m_ksid_enc = val;
96  }
97 
103  m_ksid_auth = val;
104  }
105 
109  enum QKDAppState {
120  STOPPED
121  };
122 
132  void Setup (
133  std::string socketType,
134  Address src,
135  Address dst,
136  Address kms,
137  UUID dstSaeId,
138  std::string type
139  );
140 
152  void Setup (
153  std::string socketType,
154  Address src,
155  Address dst,
156  Address kms,
157  UUID dstSaeId,
158  uint32_t packetSize,
159  uint32_t nPackets,
160  DataRate dataRate,
161  std::string type
162  );
163 
167  struct KMSPacket
168  {
170  uint32_t methodType = 0;
171  uint32_t keyType = 0;
172  std::string ksid = "";
173  std::string uri = "";
174  };
175 
182  uint32_t ScheduleAction(Time t, std::string action);
183 
184 
189  void CancelScheduledAction(uint32_t eventId);
190 
195  void ConnectionToKMSFailed (Ptr<Socket> socket);
196 
202 
207  void ConnectionToAppFailed (Ptr<Socket> socket);
208 
214 
220 
226 
232  void DataToKMSSend (Ptr<Socket>, uint32_t);
233 
238  void HandleReadFromKMS (Ptr<Socket> socket);
239 
244  void HandlePeerCloseFromKMS (Ptr<Socket> socket);
245 
250  void HandlePeerCloseToKMS (Ptr<Socket> socket);
251 
256  void HandlePeerErrorFromKMS (Ptr<Socket> socket);
257 
262  void HandlePeerErrorToKMS (Ptr<Socket> socket);
263 
269  void HandleAcceptFromKMS (Ptr<Socket> s, const Address& from);
270 
275  void HandleReadFromApp (Ptr<Socket> socket);
276 
281  void HandlePeerCloseFromApp (Ptr<Socket> socket);
282 
287  void HandlePeerErrorFromApp (Ptr<Socket> socket);
288 
294  void HandleAcceptFromApp (Ptr<Socket> s, const Address& from);
295 
301 
307 
313 
319  void HandleAcceptSignalingFromApp (Ptr<Socket> s, const Address& from);
320 
326  void RegisterAckTime (Time oldRtt, Time newRtt);
327 
334 
339 
343  void PrepareSendSocketToKMS();
344 
349 
353  void PrepareSendSocketToApp();
354 
361  void PacketReceivedFromKMS (const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
362 
369  void SignalingPacketReceivedFromApp (const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
370 
377  void DataPacketReceivedFromApp (const Ptr<Packet> &p, const Address &from, Ptr<Socket> socket);
378 
385  void ProcessResponseFromKMS(HTTPMessage& header, Ptr<Packet> packet, Ptr<Socket> socket);
386 
394 
401  void ProcessDataPacketFromApp(QKDAppHeader header, Ptr<Packet> packet, Ptr<Socket> socket);
402 
415  void OpenConnect (std::string ksid, uint32_t keyType = 0);
416 
424  void GetKeyFromKMS (std::string ksid, uint32_t index = 0);
425 
430  void Close (std::string ksid);
431 
437 
442  void ProcessGetKeyResponse (HTTPMessage& header);
443 
448  void ProcessCloseResponse (HTTPMessage& header);
449 
455  void SendKsidRequest (std::string ksid, uint32_t input);
456 
462  void SendKsidResponse (HTTPMessage::HttpStatus httpStatus, std::string msg = "");
463 
469  void ProcessSendKsidResponse (HTTPMessage& header, std::string ksid);
470 
471  /*
472  * \brief Create a key stream session entry.
473  */
475 
483  uint32_t encryptionType,
484  uint32_t authenticationType,
485  uint32_t authenticationTagLengthInBits
486  );
487 
492  uint32_t GetEncryptionKeySize();
493 
498  uint32_t GetAuthenticationKeySize ();
499 
504  uint64_t GetMaxEncryptionKeyRate();
505 
510  uint64_t GetMaxAuthenticationKeyRate();
511 
516  QKDAppState GetAppState () const;
517 
522  std::string GetAppStateString () const;
523 
529  static std::string GetAppStateString (QKDAppState state);
530 
535  void SwitchAppState (QKDAppState state);
536 
541  UUID GetId (void) {
542  return m_id;
543  }
544 
550  std::string GetPacketContent(uint32_t msgLength = 0);
551 
552  TracedCallback<Ptr<const Packet>, std::string > m_txTrace; //<! A trace for transmitted data packets.
560 
566  return m_sendSocketToKMS;
567  }
568 
574  return m_sinkSocketFromKMS;
575  }
576 
577 private:
578 
581 
585  struct QKDAppKey
586  {
587  uint32_t index;
588  std::string key;
589  uint32_t lifetime; //Lifetime in bytes!
590  };
591 
596  {
597  std::string ksid;
598  bool verified;
599  uint32_t queueSize;
600  uint32_t keyActive;
601  std::map<uint32_t, QKDAppKey> buffer; //queue
602  };
603 
604  std::pair<Association004, Association004> m_associations;
605 
608 
610 
616  void InitializeAssociations ();
617 
621  void CheckAssociationsState ();
622 
626  void CreateKeyQueues ();
627 
634  void CheckQueues ();
635 
639  void CreateKeyQueuesResponse ();
640 
645  void ClearAssociation (std::string ksid);
646 
651 
656  QKDAppKey GetEncKey ();
657 
663 
672  void Http004KMSQuery (std::string uri, std::string ksid, uint32_t keyType);
673 
679  void Http004AppQuery (uint32_t methodType, std::string ksid);
680 
685  void Http004KMSQueryComplete (std::string uri);
686 
690  void Http004AppQueryComplete (void);
691 
696  uint32_t GetMethodFromHttp004KMSQuery (std::string uri);
697 
702  std::string GetKsidFromHttp004KMSQuery (std::string uri);
703 
709  uint32_t GetKeyTypeFromHttp004KMSQuery (std::string uri);
710 
715  uint32_t GetMethodFromHttp004AppQuery (void);
716 
721  std::string GetKsidFromHttp004AppQuery (void);
722 
723 
727  struct AddressHash
728  {
739  size_t operator() (const Address &x) const
740  {
743  return std::hash<uint32_t>()(a.GetIpv4 ().Get ());
744  }
745  };
746 
747  virtual void StartApplication (void);
748  virtual void StopApplication (void);
749 
753  void ScheduleTx (void);
754 
758  void AppTransitionTree (void);
759 
765  std::string PacketToString (Ptr<Packet> packet);
766 
770  void SendPacket (void);
771 
778 
783 
787  void CloseSocketToKms();
788 
793 
796 
799 
802 
804 
805  std::string m_socketType;
806 
807  uint32_t m_packetSize;
808  double m_delay;
809 
812 
816 
817  uint32_t m_packetsSent;
818  uint32_t m_dataSent;
820  uint32_t m_master;
821  uint32_t m_malicious;
822 
825 
826 
827  uint32_t m_priority;
828  uint32_t m_ttl;
829 
830  //HTTP mapping responses to requests!
831  std::vector<std::pair<uint32_t, std::string> > m_httpRequestsApp;
832  std::map<std::string, std::pair<std::string, uint32_t> > m_httpRequestsKMS;
833 
836 
837  static uint32_t m_applicationCounts;
838 
839  //Crypto params
840  uint32_t m_useCrypto;
844  uint32_t m_aesLifetime;
849 
856 
858 
859  std::vector<KMSPacket > m_queue_kms;
860 
861  std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_kms;
862  std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_sig;
863  std::unordered_map<Address, Ptr<Packet>, AddressHash> m_buffer_qkdapp;
864 
865  std::map<uint32_t, EventId > m_scheduledEvents;
866  std::multimap<std::string, std::string> m_transitionMatrix;
867 
868 };
869 
870 
871 } // namespace ns3
872 
873 #endif /* QKD_SINK_H004 */
a polymophic address class
Definition: address.h:101
The base class for all ns3 applications.
Definition: application.h:62
Class for representing data rates.
Definition: data-rate.h:89
An identifier for simulation events.
Definition: event-id.h:55
The basic class to represent both HTTP requests and responses.
Definition: http.h:78
an Inet address class
static bool IsMatchingType(const Address &address)
Ipv4Address GetIpv4() const
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
uint32_t Get() const
Get the host-order 32-bit IP address.
Establish secure communication on application lavel to use the key and test LKSM.
Definition: qkd-app-004.h:72
void ProcessDataPacketFromApp(QKDAppHeader header, Ptr< Packet > packet, Ptr< Socket > socket)
Process data packets from the peer QKD application.
void HandlePeerErrorFromKMS(Ptr< Socket > socket)
Handle a connection error from the KMS.
Definition: qkd-app-004.cc:614
void SetKsidAuthentication(UUID val)
Set authentication key stream identifier.
Definition: qkd-app-004.h:102
Ptr< Socket > m_sinkSignalingSocketApp
The receiving socket for the signaling messages.
Definition: qkd-app-004.h:790
virtual void StopApplication(void)
Application specific shutdown code.
void HandlePeerCloseFromApp(Ptr< Socket > socket)
Handle a connection close from the peer QKD application.
Definition: qkd-app-004.cc:654
double m_delay
The time interval between two successive data transmissions (calculated based on the application data...
Definition: qkd-app-004.h:808
TracedCallback< Ptr< const Packet > > m_rxSigTrace
A trace for received signaling packets.
Definition: qkd-app-004.h:556
void HandleReadFromApp(Ptr< Socket > socket)
Handle a packet received from the peer QKD application.
Definition: qkd-app-004.cc:840
UUID m_dstSaeId
The peer application identifier.
Definition: qkd-app-004.h:835
TracedCallback< Ptr< Packet >, std::string > m_deauthenticationTrace
A trace callback for the authentication check event.
Definition: qkd-app-004.h:848
void CancelScheduledAction(uint32_t eventId)
Cancel the scheduled event.
Definition: qkd-app-004.cc:308
void ConnectionToKMSSucceeded(Ptr< Socket > socket)
Callback function after the connection to the KMS is complete.
Definition: qkd-app-004.cc:572
std::string GetAppStateString() const
Get the current state of the application in a string notation.
QKDAppState m_appState
The application state.
Definition: qkd-app-004.h:857
QKDAppKey GetAuthKey()
Get the authentication key from the queue.
void Http004AppQueryComplete(void)
Remove the request from the vector of HTTP requests made to the peer QKD application.
DataRate m_dataRate
The application data rate.
Definition: qkd-app-004.h:810
QKDApp004()
Constructor.
Definition: qkd-app-004.cc:180
void ConnectionToKMSFailed(Ptr< Socket > socket)
Callback function after the connection to the KMS has failed.
Definition: qkd-app-004.cc:578
void HandleAcceptFromKMS(Ptr< Socket > s, const Address &from)
Handle an incoming connection from the KMS.
Definition: qkd-app-004.cc:535
uint32_t m_useCrypto
Execute actual cryptographic algorithms?
Definition: qkd-app-004.h:840
void SendPacket(void)
Send the application packet (includes the generation of a random message and optional encryption or/a...
void OpenConnect(std::string ksid, uint32_t keyType=0)
Request a key stream session (an association) from the local KMS.
uint32_t GetMethodFromHttp004AppQuery(void)
Map the HTTP response from the peer QKD application and obtain the ETSI method type.
void PrepareSinkSocketFromKMS()
Prepare the sink socket to listen from the KMS Application.
Definition: qkd-app-004.cc:330
void RegisterAckTime(Time oldRtt, Time newRtt)
Register the acknowledgement time.
Address m_localSignaling
The local address for the signaling data transmission.
Definition: qkd-app-004.h:801
void SendMaliciousRequestToKMS()
Send a malicious request to the KMS.
static TypeId GetTypeId(void)
Get the type ID.
Definition: qkd-app-004.cc:44
uint32_t m_keyBufferLengthEncryption
The size of the encryption key queue at the application layer.
Definition: qkd-app-004.h:854
void ProcessSignalingPacketFromApp(HTTPMessage &header, Ptr< Socket > socket)
Process a signaling packets from the peer QKD application.
Time m_dosAttackIntensity
The intensity of the DoS attack.
Definition: qkd-app-004.h:824
QKDAppState
The QKD application states.
Definition: qkd-app-004.h:109
@ ESTABLISHING_ASSOCIATIONS
Definition: qkd-app-004.h:112
@ ASSOCIATIONS_ESTABLISHED
Definition: qkd-app-004.h:113
void ProcessOpenConnectResponse(HTTPMessage &header)
Process the OPEN_CONNECT response.
void ProcessGetKeyResponse(HTTPMessage &header)
Process the GET_KEY response.
TracedCallback< Ptr< Packet >, std::string > m_authenticationTrace
A trace callback for the authentication event.
Definition: qkd-app-004.h:847
UUID m_id
The application identifier.
Definition: qkd-app-004.h:834
uint32_t ScheduleAction(Time t, std::string action)
Schedule the action.
uint32_t m_keyBufferLengthAuthentication
The size of the authentication key queue at the application layer.
Definition: qkd-app-004.h:855
uint32_t m_packetsSent
The number of sent data packets.
Definition: qkd-app-004.h:817
std::map< uint32_t, EventId > m_scheduledEvents
The map of scheduled events.
Definition: qkd-app-004.h:865
TracedCallback< Ptr< Packet > > m_encryptionTrace
A trace callback for the encryption event.
Definition: qkd-app-004.h:845
Address m_peer
The address of the peer for the data transmission.
Definition: qkd-app-004.h:797
void Http004KMSQueryComplete(std::string uri)
Remove the request from the vector of HTTP requests made to the KMS.
void GetKeyFromKMS(std::string ksid, uint32_t index=0)
Get key for the key stream.
ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
A trace for the application state transitions.
Definition: qkd-app-004.h:558
uint32_t GetKeyTypeFromHttp004KMSQuery(std::string uri)
Map the HTTP reponse from the KMS and obtain the key type.
std::string m_socketType
The sockets type.
Definition: qkd-app-004.h:805
UUID m_ksid_auth
The authentication key stream identifier.
Definition: qkd-app-004.h:580
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_qkdapp
The buffer for received data packets (fragmentation).
Definition: qkd-app-004.h:863
uint32_t m_packetSize
The data packet size.
Definition: qkd-app-004.h:807
void DataToKMSSend(Ptr< Socket >, uint32_t)
Callback function to notify that data to KMS has been sent.
TracedCallback< Ptr< const Packet > > m_txSigTrace
A trace for transmitted signaling packets.
Definition: qkd-app-004.h:553
void PrepareSinkSocketFromApp()
Prepare the sink socket to listen from the peer QKD Application.
Definition: qkd-app-004.cc:452
void HandleAcceptSignalingFromApp(Ptr< Socket > s, const Address &from)
Handle a signaling incoming connection from the peer QKD application.
Definition: qkd-app-004.cc:560
uint32_t m_aesLifetime
The AES key lifetime.
Definition: qkd-app-004.h:844
void ClearAssociation(std::string ksid)
Delete all records of key stream session identified with a given KSID.
bool m_primaryQueueEstablished
Is the queue established at the sender application?
Definition: qkd-app-004.h:606
void ProcessSendKsidResponse(HTTPMessage &header, std::string ksid)
Process the SEND_KSID response.
virtual ~QKDApp004()
Destructor.
Definition: qkd-app-004.cc:201
Ptr< UniformRandomVariable > m_random
The uniform random variable.
Definition: qkd-app-004.h:609
void HandleReadSignalingFromApp(Ptr< Socket > socket)
Handle a signaling packet received from the peer QKD application.
Definition: qkd-app-004.cc:927
virtual void StartApplication(void)
EventId m_closeSocketEvent
The closing socket event.
Definition: qkd-app-004.h:814
TracedCallback< const uint32_t & > m_obtainedKeyMaterialTrace
A trace callback for the obtained key material.
Definition: qkd-app-004.h:850
void ProcessCreateQueuesResponse()
Start establishing key queues at the reciving application once requested by the sender.
std::string GetKsidFromHttp004AppQuery(void)
Map the HTTP response from the peer QKD application and obtain the key stream identifier.
Ptr< Socket > m_sendDataSocketApp
The sending socket for the data.
Definition: qkd-app-004.h:791
void HandleAcceptFromApp(Ptr< Socket > s, const Address &from)
Handle an incoming connection from the peer QKD application.
Definition: qkd-app-004.cc:548
uint32_t GetMethodFromHttp004KMSQuery(std::string uri)
Read the ETSI request method from the URI.
Address m_peerSignaling
The address of the peer for the signaling data transmission.
Definition: qkd-app-004.h:798
QKDEncryptor::EncryptionType m_encryptionType
The encryption algorithm.
Definition: qkd-app-004.h:851
Ptr< Packet > m_maliciousPacket
The malicious packet.
Definition: qkd-app-004.h:823
uint32_t GetEncryptionKeySize()
Get the required key size for the choosen encryption algorithm.
void ConnectionSignalingToAppFailed(Ptr< Socket > socket)
Callback function after the signaling connection to the APP has failed.
Definition: qkd-app-004.cc:602
Address m_kms
The local KMS address.
Definition: qkd-app-004.h:803
EventId m_sendEvent
The data transmission event.
Definition: qkd-app-004.h:813
void Close(std::string ksid)
Close the keys stream session (the association).
void HandlePeerErrorSignalingFromApp(Ptr< Socket > socket)
Handle a signaling connection error from the peer QKD application.
Definition: qkd-app-004.cc:671
Ptr< Socket > m_sinkSocketFromKMS
The receiving socket from the KMS.
Definition: qkd-app-004.h:795
void InitializeAssociations()
Initialize the key stream sessions.
uint32_t m_ttl
The time-to-live of the key stream session.
Definition: qkd-app-004.h:828
void ProcessPacketsToKMSFromQueue()
Process and send any remaining packets to the KMS.
Definition: qkd-app-004.cc:730
void CloseSocketToKms()
Close the connecting sockets with the KMS.
Definition: qkd-app-004.cc:720
uint32_t GetAuthenticationKeySize()
Get the required key size for the choosen authentication algorithm.
std::pair< Association004, Association004 > m_associations
A pair (encryption/authentication) of the establihed key stream session.
Definition: qkd-app-004.h:604
bool ConnectionRequestedFromKMS(Ptr< Socket > socket, const Address &address)
Callback function after the connection for response from the KMS has been received.
Definition: qkd-app-004.cc:523
UUID m_ksid_enc
The encryption key stream identifier.
Definition: qkd-app-004.h:579
uint32_t m_dataSent
The amount of the sent data.
Definition: qkd-app-004.h:818
void PrepareSendSocketToKMS()
Prepare the send socket to communicate with the KMS Application.
Definition: qkd-app-004.cc:368
uint64_t GetMaxEncryptionKeyRate()
Get the maximum key rate required for the encryption (QoS settings).
void ProcessCloseResponse(HTTPMessage &header)
Process the CLOSE response.
void PacketReceivedFromKMS(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for the tcp segmentation of packets received from the KMS.
Definition: qkd-app-004.cc:759
std::string GetPacketContent(uint32_t msgLength=0)
Generate a random packet payload (the message).
bool m_replicaQueueEstablished
Is the queue established at the receiver application?
Definition: qkd-app-004.h:607
TracedCallback< Ptr< const Packet > > m_rxKmsTrace
A trace for received packets from the KMS.
Definition: qkd-app-004.h:557
void Http004KMSQuery(std::string uri, std::string ksid, uint32_t keyType)
Memories the HTTP request made to the local KMS.
void ConnectionSignalingToAppSucceeded(Ptr< Socket > socket)
Callback function after the signaling connection to the APP is complete.
Definition: qkd-app-004.cc:596
void ConnectionToAppSucceeded(Ptr< Socket > socket)
Callback function after the connection to the APP is complete.
Definition: qkd-app-004.cc:584
Time m_holdTime
The holding time before closing sockets.
Definition: qkd-app-004.h:815
std::map< std::string, std::pair< std::string, uint32_t > > m_httpRequestsKMS
A vector of HTTP requests set to the KMS.
Definition: qkd-app-004.h:832
std::vector< std::pair< uint32_t, std::string > > m_httpRequestsApp
A vector of HTTP requests sent to the peer application.
Definition: qkd-app-004.h:831
Ptr< Socket > m_sendSocketToKMS
The sending socket to the KMS.
Definition: qkd-app-004.h:794
TracedCallback< Ptr< const Packet > > m_txKmsTrace
A trace for transmitted packets to the KMS.
Definition: qkd-app-004.h:554
std::multimap< std::string, std::string > m_transitionMatrix
The map of the possible state transitions.
Definition: qkd-app-004.h:866
TracedCallback< Ptr< const Packet >, std::string > m_mxTrace
A trace for the missed time slots to send data (due to the lack of keys).
Definition: qkd-app-004.h:559
TypeId m_tid
The type identifier.
Definition: qkd-app-004.h:819
void SignalingPacketReceivedFromApp(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for the tcp segmentation of the signaling packets received from the peer application.
Definition: qkd-app-004.cc:959
QKDAppState GetAppState() const
Get the current state of the application.
void HandlePeerErrorFromApp(Ptr< Socket > socket)
Handle a connection error from the peer QKD application.
Definition: qkd-app-004.cc:659
uint64_t GetMaxAuthenticationKeyRate()
Get the maximum key rate required for the authentication (QoS settings).
QKDEncryptor::AuthenticationType m_authenticationType
The authentication algorithm.
Definition: qkd-app-004.h:852
void CreateKeyQueuesResponse()
Once the receiving application establishes the queues, it sends a response to the sender application.
Ptr< QKDEncryptor > m_encryptor
The QKD encryptor.
Definition: qkd-app-004.h:853
void HandlePeerCloseSignalingFromApp(Ptr< Socket > socket)
Handle a signaling connection close from the peer QKD application.
Definition: qkd-app-004.cc:665
uint32_t m_priority
The application priority (QoS).
Definition: qkd-app-004.h:827
std::string GetKsidFromHttp004KMSQuery(std::string uri)
Map the HTTP response from the KMS and obtain the key stream identifier.
uint32_t m_authenticationTagLengthInBits
The size of the authentication tag in bits (32 by default).
Definition: qkd-app-004.h:843
Address m_local
The local address for the data transmission.
Definition: qkd-app-004.h:800
void SetEncryptionAndAuthenticationSettings(uint32_t encryptionType, uint32_t authenticationType, uint32_t authenticationTagLengthInBits)
Set the encryption and the authentication algorithms.
void SendKsidResponse(HTTPMessage::HttpStatus httpStatus, std::string msg="")
Send a response on the SEND_KSID request.
uint32_t m_master
Is a master (sender/primary) application?
Definition: qkd-app-004.h:820
void CreateKeyQueues()
Create the required key queues to store a set amount of keys from the respective key stream sessions.
void ProcessResponseFromKMS(HTTPMessage &header, Ptr< Packet > packet, Ptr< Socket > socket)
Process a response from the KMS application.
void HandlePeerCloseToKMS(Ptr< Socket > socket)
Handle a connection close to the KMS.
Definition: qkd-app-004.cc:620
void SwitchAppState(QKDAppState state)
Change the state of the application.
void CheckQueues()
Request new keys from the KMS until the key queues at the application layer are established with a se...
void CheckAssociationsState()
Check if the required key stream sessions are successfuly established.
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_sig
The buffer for the received signaling packets (fragmentation).
Definition: qkd-app-004.h:862
Ptr< Socket > GetSinkSocketFromKMS()
Get the receiving socket from the KMS.
Definition: qkd-app-004.h:573
void ConnectionToAppFailed(Ptr< Socket > socket)
Callback function after the connection to the APP has failed.
Definition: qkd-app-004.cc:590
void CreateKeyStreamAssociations()
void HandlePeerCloseFromKMS(Ptr< Socket > socket)
Handle a connection close from the KMS.
Definition: qkd-app-004.cc:608
TracedCallback< Ptr< Packet > > m_decryptionTrace
A trace callback for the decryption event.
Definition: qkd-app-004.h:846
UUID GetId(void)
Get the application identifier.
Definition: qkd-app-004.h:541
uint32_t m_malicious
Is a malicious application?
Definition: qkd-app-004.h:821
void AppTransitionTree(void)
Transition through a tree of the application states and trigger actions.
void HandleReadFromKMS(Ptr< Socket > socket)
Handle a packet received by the QKD application from the KMS application.
Definition: qkd-app-004.cc:677
Ptr< Socket > m_sendSignalingSocketApp
The sending socket for the signaling messages.
Definition: qkd-app-004.h:789
std::string PacketToString(Ptr< Packet > packet)
Convert the packet to a string.
DataRate m_minDataRate
The minimum application data rate.
Definition: qkd-app-004.h:811
static uint32_t m_applicationCounts
The number of running applications.
Definition: qkd-app-004.h:837
QKDAppKey GetEncKey()
Get the encryption key from the queue.
Ptr< Socket > m_sinkDataSocketApp
The receiving socket for the data.
Definition: qkd-app-004.h:792
TracedCallback< Ptr< const Packet >, std::string > m_txTrace
Definition: qkd-app-004.h:552
void ScheduleTx(void)
Schedule the next time slot to send the data.
Definition: qkd-app-004.cc:291
Ptr< Socket > GetSendSocketToKMS()
Get the sending socket to the KMS.
Definition: qkd-app-004.h:565
uint32_t m_encryptionTypeInt
The encryption algorithm.
Definition: qkd-app-004.h:841
TracedCallback< Ptr< const Packet >, std::string > m_rxTrace
A trace for received data packets.
Definition: qkd-app-004.h:555
void DataPacketReceivedFromApp(const Ptr< Packet > &p, const Address &from, Ptr< Socket > socket)
Check for the tcp segmentation of the signaling packets received from the KMS.
Definition: qkd-app-004.cc:872
void SendKsidRequest(std::string ksid, uint32_t input)
Inform the peer QKD application of the established key stream session.
void PrepareSendSocketToApp()
Prepare the send socket to communicate with the peer QKD Application.
Definition: qkd-app-004.cc:402
std::vector< KMSPacket > m_queue_kms
The queue of packets waiting for the transmission to the KMS.
Definition: qkd-app-004.h:859
void Http004AppQuery(uint32_t methodType, std::string ksid)
Memories the HTTP request made to the peer QKD application.
void HandlePeerErrorToKMS(Ptr< Socket > socket)
Handle a connection error to the KMS.
Definition: qkd-app-004.cc:637
std::unordered_map< Address, Ptr< Packet >, AddressHash > m_buffer_kms
The buffer for the received packets from the KMS (fragmentation).
Definition: qkd-app-004.h:861
void SetKsidEncryption(UUID val)
Set encryption key stream identifier.
Definition: qkd-app-004.h:94
void Setup(std::string socketType, Address src, Address dst, Address kms, UUID dstSaeId, std::string type)
Configure the application.
Definition: qkd-app-004.cc:215
uint32_t m_authenticationTypeInt
The authentication algorithm.
Definition: qkd-app-004.h:842
QKD app packet header that carries info about used encryption, auth tag and other.
EncryptionType
Encryption type.
Definition: qkd-encryptor.h:96
AuthenticationType
Authentication type.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition: type-id.h:59
Universally unique identifier (UUID)
Definition: uuid.h:35
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Definition: abort.h:76
address
Definition: first.py:47
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Hashing for the Address class.
Definition: qkd-app-004.h:728
size_t operator()(const Address &x) const
operator ()
Definition: qkd-app-004.h:739
The key stream session details.
Definition: qkd-app-004.h:596
std::map< uint32_t, QKDAppKey > buffer
Definition: qkd-app-004.h:601
A cryptographic key at the application layer.
Definition: qkd-app-004.h:586
static const uint32_t packetSize
Packet size generated at the AP.