A Discrete-Event Network Simulator
API
ns3::QKDKey Class Reference

The QKD key is an elementary class of QKDNetSim. More...

#include "qkd-key.h"

+ Inheritance diagram for ns3::QKDKey:
+ Collaboration diagram for ns3::QKDKey:

Public Types

enum  QKDKeyState_e {
  INIT , READY , SERVED , TRANSFORMED ,
  USED , OBSOLETE , RESTORED , RESERVED
}
 The QKD key states. More...
 

Public Member Functions

 QKDKey (std::string keyId, std::string key)
 Constructor. More...
 
 QKDKey (std::string keyId, uint64_t keyIdnum, std::string key)
 Constructor. More...
 
 QKDKey (std::string keyId, uint64_t keyIdnum, uint64_t keySize)
 Constructor. More...
 
 QKDKey (uint64_t keySize)
 Constructor. More...
 
std::string ConsumeKeyString (void)
 Get the key value and switch the key state to SERVED. More...
 
Ptr< QKDKeyCopy (void) const
 Copy the key. More...
 
std::string GenerateRandomString (const int len)
 Get a random string. More...
 
std::string GetId (void) const
 Get the key identifier. More...
 
uint8_t * GetKey (void)
 Get key value in byte* format. More...
 
std::string GetKeyBinary ()
 Get key value in bit notation. More...
 
std::string GetKeyString (void)
 Get QKD key value. More...
 
Time GetKeyTimestamp ()
 Get the key timestamp. More...
 
uint64_t GetSize (void) const
 Get the key size in bytes. More...
 
uint64_t GetSizeInBits (void) const
 Get the key size in bits. More...
 
QKDKeyState_e GetState () const
 Get the current state of the key. More...
 
std::string GetStateString () const
 Get the current state of the key in a string format. More...
 
void MarkReady ()
 Mark the key as ready. More...
 
void MarkReserved ()
 Mark the key as reserved. More...
 
void MarkRestored ()
 Mark the key as restored. More...
 
void MarkServed ()
 Mark the key as served. More...
 
void MarkTransformed ()
 Mark the key as transformed. More...
 
void MarkUsed ()
 Mark the key as used. More...
 
void SetId (std::string value)
 Set the key identifier. More...
 
void SetSize (uint64_t sizeInBytes)
 Set the key size. More...
 
void SwitchToState (QKDKeyState_e state)
 Change the state of the key. More...
 
std::string ToString (void)
 Get the key value. More...
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor. More...
 
 ~Object () override
 Destructor. More...
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together. More...
 
void Dispose ()
 Dispose of this Object. More...
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one. More...
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object. More...
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object. More...
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object. More...
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId. More...
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object. More...
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one. More...
 
bool IsInitialized () const
 Check if the object has been initialized. More...
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor. More...
 
 SimpleRefCount (const SimpleRefCount &o[[maybe_unused]])
 Copy constructor. More...
 
uint32_t GetReferenceCount () const
 Get the reference count of the object. More...
 
SimpleRefCountoperator= (const SimpleRefCount &o[[maybe_unused]])
 Assignment operator. More...
 
void Ref () const
 Increment the reference count. More...
 
void Unref () const
 Decrement the reference count. More...
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor. More...
 
void GetAttribute (std::string name, AttributeValue &value) const
 Get the value of an attribute, raising fatal errors if unsuccessful. More...
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful. More...
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors. More...
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context. More...
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context. More...
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context. More...
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context. More...
 

Static Public Member Functions

static std::string GetStateString (QKDKeyState_e state)
 Get the given state in a string format. More...
 
static TypeId GetTypeId (void)
 Get the TypeId. More...
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId ()
 Register this type. More...
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId ()
 Get the type ID. More...
 

Public Attributes

ns3::TracedCallback< const std::string &, const std::string & > m_stateTransitionTrace
 The StateTransition trace source. More...
 

Private Attributes

std::string m_id
 
uint64_t m_internalID
 
std::string m_key
 
Ptr< UniformRandomVariablem_random
 
uint64_t m_sizeInBits
 
uint64_t m_sizeInBytes
 
QKDKeyState_e m_state
 The key state. More...
 
Time m_timestamp
 

Static Private Attributes

static uint64_t m_globalUid = 0
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 Copy an Object. More...
 
virtual void DoDispose ()
 Destructor implementation. More...
 
virtual void DoInitialize ()
 Initialize() implementation. More...
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated. More...
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes. More...
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed. More...
 

Detailed Description

The QKD key is an elementary class of QKDNetSim.

It is used to describe the key that is established in the QKD process.

\noteIn the QKD process, keys are stored as blocks. Each QKDKey is identified using a unique 32 long character identifier. The key is also marked with the timestamp of its origin, its length, and the condition in which the key is located. QKDKey can be found in one of the following states: INIT - the call for the establishment of the key record is initiated READY - the key is successfully created and stored SERVED - the key is served for usage on request TRANSFORMED - the key is generated as the result of transform operation USED - the key is used for cryptographic operations (under construction) OBSOLETE - the key validity has expired (under construction) RESTORED - the key is restored for further usage (under construction)

Definition at line 69 of file qkd-key.h.

Member Enumeration Documentation

◆ QKDKeyState_e

The QKD key states.

Enumerator
INIT 
READY 
SERVED 
TRANSFORMED 
USED 
OBSOLETE 
RESTORED 
RESERVED 

Definition at line 76 of file qkd-key.h.

Constructor & Destructor Documentation

◆ QKDKey() [1/4]

ns3::QKDKey::QKDKey ( uint64_t  keySize)

Constructor.

Create a random QKD key.

Parameters
keySizeThe key size.

Definition at line 68 of file qkd-key.cc.

References GenerateRandomString(), GetStateString(), m_globalUid, m_id, m_internalID, m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_FUNCTION, READY, and SwitchToState().

+ Here is the call graph for this function:

◆ QKDKey() [2/4]

ns3::QKDKey::QKDKey ( std::string  keyId,
uint64_t  keyIdnum,
uint64_t  keySize 
)

Constructor.

Create a QKD key.

Parameters
keyIdThe key identifier.
KeyIdnumThe internal key identifier.
keySizeThe key size.

Definition at line 106 of file qkd-key.cc.

References GenerateRandomString(), m_globalUid, m_id, m_internalID, m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), NS_FATAL_ERROR, NS_LOG_FUNCTION, READY, and SwitchToState().

+ Here is the call graph for this function:

◆ QKDKey() [3/4]

ns3::QKDKey::QKDKey ( std::string  keyId,
uint64_t  keyIdnum,
std::string  key 
)

Constructor.

Create a QKD key.

Parameters
keyIdThe key identifier.
keyIdnumThe internal key identifier.
keyThe key value.

Definition at line 134 of file qkd-key.cc.

References m_globalUid, m_id, m_internalID, m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), NS_LOG_FUNCTION, READY, and SwitchToState().

+ Here is the call graph for this function:

◆ QKDKey() [4/4]

ns3::QKDKey::QKDKey ( std::string  keyId,
std::string  key 
)

Constructor.

Create a QKD key.

Parameters
keyIdThe key identifier.
keyThe key value.

Definition at line 155 of file qkd-key.cc.

References m_key, m_random, m_sizeInBits, m_sizeInBytes, m_timestamp, ns3::Simulator::Now(), READY, and SwitchToState().

+ Here is the call graph for this function:

Member Function Documentation

◆ ConsumeKeyString()

std::string ns3::QKDKey::ConsumeKeyString ( void  )

Get the key value and switch the key state to SERVED.

Returns
The key value.

Definition at line 227 of file qkd-key.cc.

References m_id, m_key, NS_LOG_FUNCTION, SERVED, and SwitchToState().

+ Here is the call graph for this function:

◆ Copy()

Ptr< QKDKey > ns3::QKDKey::Copy ( void  ) const

Copy the key.

Returns
The QKD key object.

Definition at line 55 of file qkd-key.cc.

◆ GenerateRandomString()

std::string ns3::QKDKey::GenerateRandomString ( const int  len)

Get a random string.

Parameters
lenThe length of the string.
Returns
The random string.

Definition at line 292 of file qkd-key.cc.

References ns3::UniformRandomVariable::GetValue(), m_internalID, m_random, and NS_LOG_FUNCTION.

Referenced by QKDKey().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ GetId()

std::string ns3::QKDKey::GetId ( void  ) const

Get the key identifier.

Returns
The key identifier.

Definition at line 190 of file qkd-key.cc.

References m_id.

◆ GetKey()

uint8_t * ns3::QKDKey::GetKey ( void  )

Get key value in byte* format.

Convert key from std::String to byte*.

Returns
The key value in byte* format.

Definition at line 242 of file qkd-key.cc.

References m_id, m_key, NS_LOG_FUNCTION, SERVED, and SwitchToState().

+ Here is the call graph for this function:

◆ GetKeyBinary()

std::string ns3::QKDKey::GetKeyBinary ( )

Get key value in bit notation.

Returns
The key value in bit notation.

Definition at line 177 of file qkd-key.cc.

References m_key, and NS_LOG_FUNCTION.

◆ GetKeyString()

std::string ns3::QKDKey::GetKeyString ( void  )

Get QKD key value.

Returns
The key value.

Definition at line 170 of file qkd-key.cc.

References m_key, and NS_LOG_FUNCTION.

◆ GetKeyTimestamp()

Time ns3::QKDKey::GetKeyTimestamp ( )

Get the key timestamp.

Returns
The key timestamp.

Definition at line 376 of file qkd-key.cc.

References m_timestamp.

◆ GetSize()

uint64_t ns3::QKDKey::GetSize ( void  ) const

Get the key size in bytes.

Returns
The key size.

Definition at line 202 of file qkd-key.cc.

References m_id, m_sizeInBytes, and NS_LOG_FUNCTION.

◆ GetSizeInBits()

uint64_t ns3::QKDKey::GetSizeInBits ( void  ) const

Get the key size in bits.

Returns
The key size.

Definition at line 209 of file qkd-key.cc.

References m_id, m_sizeInBytes, and NS_LOG_FUNCTION.

◆ GetState()

QKDKey::QKDKeyState_e ns3::QKDKey::GetState ( ) const

Get the current state of the key.

Returns
The current state of the key.

Definition at line 311 of file qkd-key.cc.

References m_state.

◆ GetStateString() [1/2]

std::string ns3::QKDKey::GetStateString ( ) const

Get the current state of the key in a string format.

Returns
The current state of the key.

Definition at line 356 of file qkd-key.cc.

References m_state.

Referenced by QKDKey(), and SwitchToState().

+ Here is the caller graph for this function:

◆ GetStateString() [2/2]

std::string ns3::QKDKey::GetStateString ( QKDKey::QKDKeyState_e  state)
static

Get the given state in a string format.

Parameters
stateThe key state.
Returns
The key state expressed in string format.

Definition at line 319 of file qkd-key.cc.

References INIT, NS_FATAL_ERROR, OBSOLETE, READY, RESERVED, RESTORED, SERVED, TRANSFORMED, and USED.

◆ GetTypeId()

TypeId ns3::QKDKey::GetTypeId ( void  )
static

Get the TypeId.

Returns
The TypeId for this class.

Definition at line 40 of file qkd-key.cc.

References m_stateTransitionTrace, ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().

+ Here is the call graph for this function:

◆ MarkReady()

void ns3::QKDKey::MarkReady ( )

Mark the key as ready.

Definition at line 252 of file qkd-key.cc.

References m_id, m_key, m_state, NS_LOG_FUNCTION, READY, and SwitchToState().

+ Here is the call graph for this function:

◆ MarkReserved()

void ns3::QKDKey::MarkReserved ( )

Mark the key as reserved.

Definition at line 280 of file qkd-key.cc.

References m_id, m_key, m_state, NS_LOG_FUNCTION, RESERVED, and SwitchToState().

+ Here is the call graph for this function:

◆ MarkRestored()

void ns3::QKDKey::MarkRestored ( )

Mark the key as restored.

Definition at line 272 of file qkd-key.cc.

References m_id, m_key, m_state, NS_LOG_FUNCTION, RESTORED, and SwitchToState().

+ Here is the call graph for this function:

◆ MarkServed()

void ns3::QKDKey::MarkServed ( )

Mark the key as served.

Definition at line 258 of file qkd-key.cc.

References m_id, m_key, m_state, NS_LOG_FUNCTION, SERVED, and SwitchToState().

+ Here is the call graph for this function:

◆ MarkTransformed()

void ns3::QKDKey::MarkTransformed ( )

Mark the key as transformed.

Definition at line 286 of file qkd-key.cc.

References m_id, m_key, m_state, NS_LOG_FUNCTION, SwitchToState(), and TRANSFORMED.

+ Here is the call graph for this function:

◆ MarkUsed()

void ns3::QKDKey::MarkUsed ( )

Mark the key as used.

Definition at line 265 of file qkd-key.cc.

References m_id, m_key, m_state, NS_LOG_FUNCTION, SwitchToState(), and USED.

+ Here is the call graph for this function:

◆ SetId()

void ns3::QKDKey::SetId ( std::string  value)

Set the key identifier.

Parameters
valueThe key identifier.

Definition at line 196 of file qkd-key.cc.

References m_id.

◆ SetSize()

void ns3::QKDKey::SetSize ( uint64_t  sizeInBytes)

Set the key size.

Parameters
sizeInBytesThe key size in bytes.

Definition at line 216 of file qkd-key.cc.

References m_id, m_sizeInBits, m_sizeInBytes, NS_FATAL_ERROR, and NS_LOG_FUNCTION.

◆ SwitchToState()

void ns3::QKDKey::SwitchToState ( QKDKey::QKDKeyState_e  state)

Change the state of the key.

Fires the StateTransition trace source.

Parameters
stateThe new state.

Definition at line 362 of file qkd-key.cc.

References GetStateString(), m_state, m_stateTransitionTrace, NS_LOG_FUNCTION, and NS_LOG_INFO.

Referenced by QKDKey(), ConsumeKeyString(), GetKey(), MarkReady(), MarkReserved(), MarkRestored(), MarkServed(), MarkTransformed(), and MarkUsed().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ToString()

std::string ns3::QKDKey::ToString ( void  )

Get the key value.

Returns
The key value.

Definition at line 235 of file qkd-key.cc.

References m_id, m_key, and NS_LOG_FUNCTION.

Member Data Documentation

◆ m_globalUid

uint64_t ns3::QKDKey::m_globalUid = 0
staticprivate

Definition at line 265 of file qkd-key.h.

Referenced by QKDKey().

◆ m_id

◆ m_internalID

uint64_t ns3::QKDKey::m_internalID
private

Definition at line 263 of file qkd-key.h.

Referenced by QKDKey(), and GenerateRandomString().

◆ m_key

std::string ns3::QKDKey::m_key
private

◆ m_random

Ptr<UniformRandomVariable> ns3::QKDKey::m_random
private

Definition at line 271 of file qkd-key.h.

Referenced by QKDKey(), and GenerateRandomString().

◆ m_sizeInBits

uint64_t ns3::QKDKey::m_sizeInBits
private

Definition at line 267 of file qkd-key.h.

Referenced by QKDKey(), and SetSize().

◆ m_sizeInBytes

uint64_t ns3::QKDKey::m_sizeInBytes
private

Definition at line 266 of file qkd-key.h.

Referenced by QKDKey(), GetSize(), GetSizeInBits(), and SetSize().

◆ m_state

QKDKeyState_e ns3::QKDKey::m_state
private

◆ m_stateTransitionTrace

ns3::TracedCallback<const std::string &, const std::string &> ns3::QKDKey::m_stateTransitionTrace

The StateTransition trace source.

Definition at line 260 of file qkd-key.h.

Referenced by GetTypeId(), and SwitchToState().

◆ m_timestamp

Time ns3::QKDKey::m_timestamp
private

Definition at line 269 of file qkd-key.h.

Referenced by QKDKey(), and GetKeyTimestamp().


The documentation for this class was generated from the following files: