A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
Loading...
Searching...
No Matches
qkd-app-header.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2020 DOTFEESA www.tk.etf.unsa.ba
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
*
7
*
8
* Author: Miralem Mehic <miralem.mehic@ieee.org>,
9
* Emir Dervisevic <emir.dervisevic@etf.unsa.ba>
10
* Oliver Mauhart <oliver.maurhart@ait.ac.at>
11
*/
12
13
#ifndef QKD_APP_HEADER_H
14
#define QKD_APP_HEADER_H
15
16
#include <queue>
17
#include <string>
18
#include "ns3/packet.h"
19
#include "ns3/header.h"
20
#include "ns3/object.h"
21
22
namespace
ns3
{
23
24
/**
25
* @ingroup qkd
26
* @class QKDAppHeader
27
* @brief QKD app packet header that carries info about used encryption, auth tag and other.
28
*
29
* @note
30
* 0 4 8 16 24 32
31
* 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0
32
* 0 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33
* | Length |
34
* 4 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35
* | Msg-Id |
36
* 8 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37
* | E | A |
38
* 16 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39
* | Encryption Key Id |
40
* 20 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41
* | Authentication Key Id |
42
* 24 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43
* | A-Tag ... |
44
* 28 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45
* | ... A-Tag |
46
* +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47
*
48
* with:
49
*
50
* Length: total size of packet, including the length field itself
51
* Msg-Id: message number (inside a channel)
52
* E: Type of used encryption cipher where value 0 means unencrypted packet
53
* A: Type of used authentication algorithm where value 0 means non-authenticated packet
54
* E-KeyId: Encryption Key Id
55
* A-KeyId: Authentication Key Id
56
* A-Tag: Authentication tag
57
*
58
*/
59
60
class
QKDAppHeader
:
public
Header
61
{
62
public
:
63
64
/**
65
* @brief Constructor
66
*/
67
QKDAppHeader
();
68
69
/**
70
* @brief Get the type ID.
71
* @return the object TypeId
72
*/
73
static
TypeId
GetTypeId
();
74
/**
75
* @brief Get the type ID.
76
* @return the object TypeId
77
*/
78
TypeId
GetInstanceTypeId
()
const override
;
79
80
void
Print
(std::ostream &os)
const override
;
81
bool
operator==
(
QKDAppHeader
const
&
o
)
const
;
82
83
uint32_t
GetSerializedSize
()
const override
;
84
85
void
Serialize
(
Buffer::Iterator
start)
const override
;
86
uint32_t
Deserialize
(
Buffer::Iterator
start)
override
;
87
88
/**
89
* @param authenticated Set the message length
90
*/
91
void
SetLength
(
uint32_t
value
);
92
93
/**
94
* @return Get the message length
95
*/
96
uint32_t
GetLength
()
const
;
97
98
/**
99
* @param authenticated Set the message ID
100
*/
101
void
SetMessageId
(
uint32_t
value
);
102
103
/**
104
* @return Get the message ID
105
*/
106
uint32_t
GetMessageId
()
const
;
107
108
/**
109
* @param authenticated Set the encryption flag
110
*/
111
void
SetEncrypted
(
uint32_t
value
);
112
113
/**
114
* @return Get the encryption flag
115
*/
116
uint32_t
GetEncrypted
()
const
;
117
118
/**
119
* @param authenticated Set the authentication flag
120
*/
121
void
SetAuthenticated
(
uint32_t
value
);
122
123
/**
124
* @return Get the authentication flag
125
*/
126
uint32_t
GetAuthenticated
()
const
;
127
128
/**
129
* @param keyID Set the encryption QKD Key ID
130
*/
131
void
SetEncryptionKeyId
(std::string
value
);
132
133
/**
134
* @return Get the encryption QKD Key ID
135
*/
136
std::string
GetEncryptionKeyId
()
const
;
137
138
/**
139
* @param keyID Set the authentication QKD Key ID
140
*/
141
void
SetAuthenticationKeyId
(std::string
keyID
);
142
143
/**
144
* @return Get the authentication QKD Key ID
145
*/
146
std::string
GetAuthenticationKeyId
()
const
;
147
148
/**
149
* @param keyID Set the authentication tag
150
*/
151
void
SetAuthTag
(std::string
value
);
152
153
/**
154
* @param keyID Get the authentication tag
155
*/
156
std::string
GetAuthTag
()
const
;
157
158
/// Check that type if valid
159
bool
IsValid
()
const
160
{
161
return
m_valid
;
162
}
163
164
private
:
165
166
uint32_t
m_length
;
//!< message length field
167
uint32_t
m_messageId
;
//!< message id field
168
169
uint8_t
m_encryped
;
//!< is packet encrypted or not
170
uint8_t
m_authenticated
;
//!< is packet authenticated or not
171
172
std::string
m_encryptionKeyId
;
//!< encryption key id
173
std::string
m_authenticationKeyId
;
//!< authentication key id
174
std::string
m_authTag
;
//!< authentication tag of the packet
175
176
bool
m_valid
;
//!< Is header valid or corrupted
177
178
};
179
180
181
}
182
// namespace ns3
183
184
#endif
/* QKD_APP_HEADER_H */
185
186
ns3::Buffer::Iterator
iterator in a Buffer instance
Definition
buffer.h:89
ns3::Header
Protocol header serialization and deserialization.
Definition
header.h:33
ns3::QKDAppHeader
QKD app packet header that carries info about used encryption, auth tag and other.
Definition
qkd-app-header.h:61
ns3::QKDAppHeader::GetLength
uint32_t GetLength() const
Definition
qkd-app-header.cc:147
ns3::QKDAppHeader::m_valid
bool m_valid
Is header valid or corrupted.
Definition
qkd-app-header.h:176
ns3::QKDAppHeader::GetAuthTag
std::string GetAuthTag() const
Definition
qkd-app-header.cc:217
ns3::QKDAppHeader::operator==
bool operator==(QKDAppHeader const &o) const
Definition
qkd-app-header.cc:127
ns3::QKDAppHeader::QKDAppHeader
QKDAppHeader()
Constructor.
Definition
qkd-app-header.cc:23
ns3::QKDAppHeader::GetEncrypted
uint32_t GetEncrypted() const
Definition
qkd-app-header.cc:230
ns3::QKDAppHeader::GetInstanceTypeId
TypeId GetInstanceTypeId() const override
Get the type ID.
Definition
qkd-app-header.cc:42
ns3::QKDAppHeader::m_messageId
uint32_t m_messageId
message id field
Definition
qkd-app-header.h:167
ns3::QKDAppHeader::m_authTag
std::string m_authTag
authentication tag of the packet
Definition
qkd-app-header.h:174
ns3::QKDAppHeader::Deserialize
uint32_t Deserialize(Buffer::Iterator start) override
Definition
qkd-app-header.cc:69
ns3::QKDAppHeader::m_length
uint32_t m_length
message length field
Definition
qkd-app-header.h:166
ns3::QKDAppHeader::Serialize
void Serialize(Buffer::Iterator start) const override
Definition
qkd-app-header.cc:56
ns3::QKDAppHeader::Print
void Print(std::ostream &os) const override
Definition
qkd-app-header.cc:110
ns3::QKDAppHeader::m_authenticated
uint8_t m_authenticated
is packet authenticated or not
Definition
qkd-app-header.h:170
ns3::QKDAppHeader::SetMessageId
void SetMessageId(uint32_t value)
Definition
qkd-app-header.cc:154
ns3::QKDAppHeader::SetEncryptionKeyId
void SetEncryptionKeyId(std::string value)
Definition
qkd-app-header.cc:167
ns3::QKDAppHeader::m_encryped
uint8_t m_encryped
is packet encrypted or not
Definition
qkd-app-header.h:169
ns3::QKDAppHeader::SetEncrypted
void SetEncrypted(uint32_t value)
Definition
qkd-app-header.cc:224
ns3::QKDAppHeader::GetSerializedSize
uint32_t GetSerializedSize() const override
Definition
qkd-app-header.cc:48
ns3::QKDAppHeader::SetLength
void SetLength(uint32_t value)
Definition
qkd-app-header.cc:141
ns3::QKDAppHeader::IsValid
bool IsValid() const
Check that type if valid.
Definition
qkd-app-header.h:159
ns3::QKDAppHeader::SetAuthenticated
void SetAuthenticated(uint32_t value)
Definition
qkd-app-header.cc:237
ns3::QKDAppHeader::SetAuthTag
void SetAuthTag(std::string value)
Definition
qkd-app-header.cc:210
ns3::QKDAppHeader::GetEncryptionKeyId
std::string GetEncryptionKeyId() const
Definition
qkd-app-header.cc:181
ns3::QKDAppHeader::GetAuthenticationKeyId
std::string GetAuthenticationKeyId() const
Definition
qkd-app-header.cc:203
ns3::QKDAppHeader::GetMessageId
uint32_t GetMessageId() const
Definition
qkd-app-header.cc:160
ns3::QKDAppHeader::m_authenticationKeyId
std::string m_authenticationKeyId
authentication key id
Definition
qkd-app-header.h:173
ns3::QKDAppHeader::GetAuthenticated
uint32_t GetAuthenticated() const
Definition
qkd-app-header.cc:243
ns3::QKDAppHeader::SetAuthenticationKeyId
void SetAuthenticationKeyId(std::string keyID)
Definition
qkd-app-header.cc:189
ns3::QKDAppHeader::GetTypeId
static TypeId GetTypeId()
Get the type ID.
Definition
qkd-app-header.cc:32
ns3::QKDAppHeader::m_encryptionKeyId
std::string m_encryptionKeyId
encryption key id
Definition
qkd-app-header.h:172
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:49
uint32_t
ns3::Create
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition
ptr.h:436
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::value
static unsigned int value(char c)
Definition
qkd-encryptor.cc:267
src
applications
model
qkd-app-header.h
Generated on Mon Dec 15 2025 15:21:49 for ns-3 by
1.9.8