A Discrete-Event Network Simulator
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
22namespace 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
60class 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 */
92
93 /**
94 * @return Get the message length
95 */
96 uint32_t GetLength () const;
97
98 /**
99 * @param authenticated Set the message ID
100 */
102
103 /**
104 * @return Get the message ID
105 */
106 uint32_t GetMessageId () const;
107
108 /**
109 * @param authenticated Set the encryption flag
110 */
112
113 /**
114 * @return Get the encryption flag
115 */
116 uint32_t GetEncrypted () const;
117
118 /**
119 * @param authenticated Set the authentication flag
120 */
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
iterator in a Buffer instance
Definition buffer.h:89
Protocol header serialization and deserialization.
Definition header.h:33
QKD app packet header that carries info about used encryption, auth tag and other.
uint32_t GetLength() const
bool m_valid
Is header valid or corrupted.
std::string GetAuthTag() const
bool operator==(QKDAppHeader const &o) const
QKDAppHeader()
Constructor.
uint32_t GetEncrypted() const
TypeId GetInstanceTypeId() const override
Get the type ID.
uint32_t m_messageId
message id field
std::string m_authTag
authentication tag of the packet
uint32_t Deserialize(Buffer::Iterator start) override
uint32_t m_length
message length field
void Serialize(Buffer::Iterator start) const override
void Print(std::ostream &os) const override
uint8_t m_authenticated
is packet authenticated or not
void SetMessageId(uint32_t value)
void SetEncryptionKeyId(std::string value)
uint8_t m_encryped
is packet encrypted or not
void SetEncrypted(uint32_t value)
uint32_t GetSerializedSize() const override
void SetLength(uint32_t value)
bool IsValid() const
Check that type if valid.
void SetAuthenticated(uint32_t value)
void SetAuthTag(std::string value)
std::string GetEncryptionKeyId() const
std::string GetAuthenticationKeyId() const
uint32_t GetMessageId() const
std::string m_authenticationKeyId
authentication key id
uint32_t GetAuthenticated() const
void SetAuthenticationKeyId(std::string keyID)
static TypeId GetTypeId()
Get the type ID.
std::string m_encryptionKeyId
encryption key id
a unique identifier for an interface.
Definition type-id.h:49
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static unsigned int value(char c)