A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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 , USED ,
  OBSOLETE , RESTORED , RESERVED
}
 QKD Key States. More...
 

Public Member Functions

 QKDKey (std::string keyId, std::string key)
 
 QKDKey (std::string keyId, uint64_t keyIdnum, std::string key)
 
 QKDKey (std::string keyId, uint64_t keyIdnum, uint64_t keySize)
 Create an empty QKD key of a key size.
 
 QKDKey (uint64_t keySize)
 Create an empty QKD key of a key size.
 
std::string ConsumeKeyString ()
 Return the raw key in std::string format and switch to SERVED state.
 
Ptr< QKDKeyCopy () const
 Help function - Copy key.
 
std::string GenerateRandomString (const int len)
 Return random string.
 
std::string GetId () const
 
uint8_t * GetKey ()
 Return key in byte* which is necessery for encryption or authentication Convert key from std::String to byte*.
 
std::string GetKeyBinary ()
 Return key in bits which is necessery for encryption or authentication.
 
std::string GetKeyString ()
 Get QKD key.
 
Time GetKeyTimestamp ()
 Get timestamp of the key.
 
std::string GetModuleId ()
 Returns the id of the QKD module that generated key.
 
uint64_t GetSize () const
 Get the size of the key.
 
uint64_t GetSizeInBits () const
 Get the size of the key in bits.
 
QKDKeyState_e GetState () const
 Returns the current state of the key.
 
std::string GetStateString () const
 Returns the current state of the key in string format.
 
void MarkReady ()
 
void MarkReserved ()
 
void MarkRestored ()
 
void MarkServed ()
 
void MarkUsed ()
 
void SetId (std::string)
 
void SetModuleId (std::string)
 Save details about the QKD module that generated key.
 
void SetSize (uint64_t)
 Set the size of the key.
 
void SetValue (std::string)
 
void SwitchToState (QKDKeyState_e state)
 Change the state of the key.
 
std::string ToString ()
 Return the raw key in std::string format.
 
- Public Member Functions inherited from ns3::Object
 Object ()
 Constructor.
 
 ~Object () override
 Destructor.
 
void AggregateObject (Ptr< Object > other)
 Aggregate two Objects together.
 
void Dispose ()
 Dispose of this Object.
 
AggregateIterator GetAggregateIterator () const
 Get an iterator to the Objects aggregated to this one.
 
TypeId GetInstanceTypeId () const override
 Get the most derived TypeId for this Object.
 
template<typename T >
Ptr< T > GetObject () const
 Get a pointer to the requested aggregated Object.
 
template<>
Ptr< ObjectGetObject () const
 Specialization of () for objects of type ns3::Object.
 
template<typename T >
Ptr< T > GetObject (TypeId tid) const
 Get a pointer to the requested aggregated Object by TypeId.
 
template<>
Ptr< ObjectGetObject (TypeId tid) const
 Specialization of (TypeId tid) for objects of type ns3::Object.
 
void Initialize ()
 Invoke DoInitialize on all Objects aggregated to this one.
 
bool IsInitialized () const
 Check if the object has been initialized.
 
void UnidirectionalAggregateObject (Ptr< Object > other)
 Aggregate an Object to another Object.
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 Default constructor.
 
 SimpleRefCount (const SimpleRefCount &o)
 Copy constructor.
 
uint32_t GetReferenceCount () const
 Get the reference count of the object.
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 Assignment operator.
 
void Ref () const
 Increment the reference count.
 
void Unref () const
 Decrement the reference count.
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 Virtual destructor.
 
void GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const
 Get the value of an attribute, raising fatal errors if unsuccessful.
 
bool GetAttributeFailSafe (std::string name, AttributeValue &value) const
 Get the value of an attribute without raising errors.
 
void SetAttribute (std::string name, const AttributeValue &value)
 Set a single attribute, raising fatal errors if unsuccessful.
 
bool SetAttributeFailSafe (std::string name, const AttributeValue &value)
 Set a single attribute without raising errors.
 
bool TraceConnect (std::string name, std::string context, const CallbackBase &cb)
 Connect a TraceSource to a Callback with a context.
 
bool TraceConnectWithoutContext (std::string name, const CallbackBase &cb)
 Connect a TraceSource to a Callback without a context.
 
bool TraceDisconnect (std::string name, std::string context, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected with a context.
 
bool TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb)
 Disconnect from a TraceSource a Callback previously connected without a context.
 

Static Public Member Functions

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

Public Attributes

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

Protected Attributes

std::string m_id
 
std::string m_key
 
uint64_t m_size
 

Private Attributes

uint64_t m_internalID
 
std::string m_moduleId
 id of QKD module that generated key
 
QKDKeyState_e m_state
 state of the key
 
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.
 
virtual void DoDispose ()
 Destructor implementation.
 
virtual void DoInitialize ()
 Initialize() implementation.
 
virtual void NotifyNewAggregate ()
 Notify all Objects aggregated to this one of a new Object being aggregated.
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 Complete construction of ObjectBase; invoked by derived classes.
 
virtual void NotifyConstructionCompleted ()
 Notifier called once the ObjectBase is fully constructed.
 

Detailed Description

The QKD key is an elementary class of QKDNetSim.

Introspection did not find any typical Config paths.

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

@noteIn the QKD process, keys are stored as blocks. Later, some part of the block is taken and used for encryption, while others remain in the buffer. Operations regarding QKD Key management(merge, split and other) are under construction. 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 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)


No Attributes are defined for this type.

TraceSources

Size of this type is 208 bytes (on a 64-bit architecture).

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

Member Enumeration Documentation

◆ QKDKeyState_e

QKD Key States.

Enumerator
INIT 
READY 
SERVED 
USED 
OBSOLETE 
RESTORED 
RESERVED 

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

Constructor & Destructor Documentation

◆ QKDKey() [1/4]

ns3::QKDKey::QKDKey ( uint64_t  keySize)

Create an empty QKD key of a key size.

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

References ns3::Create(), GenerateRandomString(), GetStateString(), m_globalUid, m_id, m_internalID, m_key, m_size, m_timestamp, ns3::Simulator::Now(), 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 
)

Create an empty QKD key of a key size.

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

References ns3::Create(), GenerateRandomString(), m_globalUid, m_id, m_internalID, m_key, m_size, m_timestamp, ns3::Simulator::Now(), 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 
)

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

References ns3::Create(), m_globalUid, m_id, m_internalID, m_key, m_size, 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 
)

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

References m_key, m_size, 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 ( )

Return the raw key in std::string format and switch to SERVED state.

Returns
std::string

Definition at line 212 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 ( ) const

Help function - Copy key.

Returns
Ptr<QKDKey>

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

References ns3::Create().

+ Here is the call graph for this function:

◆ GenerateRandomString()

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

Return random string.

Parameters
lenlength of string to generate
Returns
string random string

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

References ns3::Create(), m_internalID, and NS_LOG_FUNCTION.

Referenced by QKDKey(), and QKDKey().

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

◆ GetId()

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

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

References m_id.

◆ GetKey()

uint8_t * ns3::QKDKey::GetKey ( )

Return key in byte* which is necessery for encryption or authentication Convert key from std::String to byte*.

Returns
byte*

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

References ns3::Create(), m_id, m_key, NS_LOG_FUNCTION, SERVED, and SwitchToState().

+ Here is the call graph for this function:

◆ GetKeyBinary()

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

Return key in bits which is necessery for encryption or authentication.

Returns
string

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

References ns3::Create(), m_key, and NS_LOG_FUNCTION.

+ Here is the call graph for this function:

◆ GetKeyString()

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

Get QKD key.

Returns
string key

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

References m_key, and NS_LOG_FUNCTION.

◆ GetKeyTimestamp()

Time ns3::QKDKey::GetKeyTimestamp ( )

Get timestamp of the key.

Returns
Time key timestamp

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

References m_timestamp.

◆ GetModuleId()

std::string ns3::QKDKey::GetModuleId ( )

Returns the id of the QKD module that generated key.

Returns
The id of the QKD module that generated key

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

References m_moduleId.

◆ GetSize()

uint64_t ns3::QKDKey::GetSize ( ) const

Get the size of the key.

Returns
uint64_t

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

References m_id, m_size, and NS_LOG_FUNCTION.

◆ GetSizeInBits()

uint64_t ns3::QKDKey::GetSizeInBits ( ) const

Get the size of the key in bits.

Returns
uint64_t

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

References m_id, m_size, and NS_LOG_FUNCTION.

◆ GetState()

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

Returns the current state of the key.

Returns
The current state of the key.

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

References m_state.

◆ GetStateString() [1/2]

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

Returns the current state of the key in string format.

Returns
The current state of the key in string format.

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

References GetStateString(), and m_state.

Referenced by QKDKey(), GetStateString(), and SwitchToState().

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

◆ GetStateString() [2/2]

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

Returns the given state in string format.

Parameters
stateAn arbitrary state of a key.
Returns
The given state equivalently expressed in string format.

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

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

◆ GetTypeId()

TypeId ns3::QKDKey::GetTypeId ( )
static

Get the TypeId.

Returns
The TypeId for this class

Definition at line 30 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 ( )

Definition at line 237 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 ( )

Definition at line 265 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 ( )

Definition at line 257 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 ( )

Definition at line 243 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:

◆ MarkUsed()

void ns3::QKDKey::MarkUsed ( )

Definition at line 250 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)

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

References m_id, and ns3::value().

+ Here is the call graph for this function:

◆ SetModuleId()

void ns3::QKDKey::SetModuleId ( std::string  moduleId)

Save details about the QKD module that generated key.

Parameters
QKDModuleId.

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

References ns3::Create(), and m_moduleId.

+ Here is the call graph for this function:

◆ SetSize()

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

Set the size of the key.

Parameters
uint64_t

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

References m_id, m_size, NS_FATAL_ERROR, NS_LOG_FUNCTION, and ns3::value().

+ Here is the call graph for this function:

◆ SetValue()

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

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

References m_key, m_size, NS_LOG_FUNCTION, and ns3::value().

+ Here is the call graph for this 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 336 of file qkd-key.cc.

References ns3::Create(), GetStateString(), m_state, m_stateTransitionTrace, NS_LOG_FUNCTION, and NS_LOG_INFO.

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

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

◆ ToString()

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

Return the raw key in std::string format.

Returns
std::string

Definition at line 220 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 225 of file qkd-key.h.

Referenced by QKDKey(), QKDKey(), and QKDKey().

◆ m_id

std::string ns3::QKDKey::m_id
protected

◆ m_internalID

uint64_t ns3::QKDKey::m_internalID
private

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

Referenced by QKDKey(), QKDKey(), QKDKey(), and GenerateRandomString().

◆ m_key

std::string ns3::QKDKey::m_key
protected

◆ m_moduleId

std::string ns3::QKDKey::m_moduleId
private

id of QKD module that generated key

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

Referenced by GetModuleId(), and SetModuleId().

◆ m_size

uint64_t ns3::QKDKey::m_size
protected

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

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

◆ m_state

QKDKeyState_e ns3::QKDKey::m_state
private

state of the key

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

Referenced by GetState(), GetStateString(), MarkReady(), MarkReserved(), MarkRestored(), MarkServed(), MarkUsed(), and SwitchToState().

◆ m_stateTransitionTrace

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

The StateTransition trace source.

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

Referenced by GetTypeId(), and SwitchToState().

◆ m_timestamp

Time ns3::QKDKey::m_timestamp
private

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

Referenced by QKDKey(), QKDKey(), QKDKey(), QKDKey(), and GetKeyTimestamp().


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