10#include "ns3/packet.h"
11#include "ns3/assert.h"
20#include <cryptopp/base64.h>
34 .AddTraceSource(
"StateTransition",
35 "Trace fired upon every QKDKey state transition.",
37 "ns3::Application::StateTransitionCallback")
78 new CryptoPP::Base64Encoder(
79 new CryptoPP::StringSink(
m_key)
167 for(std::size_t
i = 0;
i <
m_key.size(); ++
i){
206 NS_FATAL_ERROR(
this <<
"Key size must be in bits and divided with 8!" );
231 uint8_t*
temp =
new uint8_t [
m_key.length()];
278 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
279 "abcdefghijklmnopqrstuvwxyz";
281 for(
int i = 0;
i <
len; ++
i){
323 return "FATAL_ERROR";
A base class which provides memory management and object aggregation.
Smart pointer class similar to boost::intrusive_ptr.
The QKD key is an elementary class of QKDNetSim.
std::string GetModuleId()
Returns the id of the QKD module that generated key.
Ptr< QKDKey > Copy() const
Help function - Copy key.
std::string GetKeyString()
Get QKD key.
std::string GenerateRandomString(const int len)
Return random string.
void SetModuleId(std::string)
Save details about the QKD module that generated key.
Time GetKeyTimestamp()
Get timestamp of the key.
static TypeId GetTypeId()
Get the TypeId.
std::string ToString()
Return the raw key in std::string format.
std::string GetKeyBinary()
Return key in bits which is necessery for encryption or authentication.
QKDKeyState_e
QKD Key States.
std::string m_moduleId
id of QKD module that generated key
QKDKeyState_e m_state
state of the key
ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
The StateTransition trace source.
void SetSize(uint64_t)
Set the size of the key.
std::string ConsumeKeyString()
Return the raw key in std::string format and switch to SERVED state.
std::string GetId() const
uint64_t GetSize() const
Get the size of the key.
std::string GetStateString() const
Returns the current state of the key in string format.
void SetValue(std::string)
void SwitchToState(QKDKeyState_e state)
Change the state of the key.
uint64_t GetSizeInBits() const
Get the size of the key in bits.
QKDKey(uint64_t keySize)
Create an empty QKD key of a key size.
QKDKeyState_e GetState() const
Returns the current state of the key.
uint8_t * GetKey()
Return key in byte* which is necessery for encryption or authentication Convert key from std::String ...
static uint64_t m_globalUid
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static unsigned int value(char c)