14#include "ns3/application.h"
15#include "ns3/event-id.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"
24#include "ns3/qkd-encryptor.h"
25#include "ns3/app-key.h"
26#include <unordered_map>
460 std::vector<std::string>
ReadUri(std::string s);
531 return std::hash<uint32_t>()(
a.GetIpv4().Get());
a polymophic address class
The base class for all ns3 applications.
Class for representing data rates.
An identifier for simulation events.
The basic class to represent both HTTP requests and responses.
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.
Establish secure communication on application lavel to use the key and test LKSM.
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)
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!
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.
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.
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
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
void PushHttpKmsRequest(std::string input)
Adds HTTP request to kms queue to properly map response later.
EncryptionType
Encryption type.
AuthenticationType
Authentication type.
Simulation virtual time values and global simulation resolution.
Forward calls to a chain of Callback.
a unique identifier for an interface.
#define NS_ABORT_IF(cond)
Abnormal program termination if a condition is true.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
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.