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
lte-rlc-sequence-number.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
3
*
4
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Manuel Requena <manuel.requena@cttc.es>
7
*/
8
9
#ifndef LTE_RLC_SEQUENCE_NUMBER_H
10
#define LTE_RLC_SEQUENCE_NUMBER_H
11
12
#include <ns3/assert.h>
13
14
#include <iostream>
15
#include <limits>
16
#include <stdint.h>
17
18
namespace
ns3
19
{
20
21
/// SequenceNumber10 class
22
class
SequenceNumber10
23
{
24
public
:
25
SequenceNumber10
()
26
:
m_value
(0),
27
m_modulusBase
(0)
28
{
29
}
30
31
/**
32
* Constructor
33
*
34
* @param value the value
35
*/
36
explicit
SequenceNumber10
(uint16_t value)
37
:
m_value
(value % 1024),
38
m_modulusBase
(0)
39
{
40
}
41
42
/**
43
* Constructor
44
*
45
* @param value the value
46
*/
47
SequenceNumber10
(
const
SequenceNumber10
& value)
48
:
m_value
(value.
m_value
),
49
m_modulusBase
(value.
m_modulusBase
)
50
{
51
}
52
53
/**
54
* Assignment operator
55
*
56
* @param value the value
57
* @returns SequenceNumber10
58
*/
59
SequenceNumber10
&
operator=
(uint16_t value)
60
{
61
m_value
= value % 1024;
62
return
*
this
;
63
}
64
65
/**
66
* @brief Extracts the numeric value of the sequence number
67
* @returns the sequence number value
68
*/
69
uint16_t
GetValue
()
const
70
{
71
return
m_value
;
72
}
73
74
/**
75
* @brief Set modulus base
76
* @param modulusBase the modulus
77
*/
78
void
SetModulusBase
(
SequenceNumber10
modulusBase)
79
{
80
m_modulusBase
= modulusBase.
m_value
;
81
}
82
83
/**
84
* @brief Set modulus base
85
* @param modulusBase the modulus
86
*/
87
void
SetModulusBase
(uint16_t modulusBase)
88
{
89
m_modulusBase
= modulusBase;
90
}
91
92
/**
93
* postfix ++ operator
94
* @returns SequenceNumber10
95
*/
96
SequenceNumber10
operator++
(
int
)
97
{
98
SequenceNumber10
retval(
m_value
);
99
m_value
= ((
uint32_t
)
m_value
+ 1) % 1024;
100
retval.
SetModulusBase
(
m_modulusBase
);
101
return
retval;
102
}
103
104
/**
105
* addition operator
106
* @param delta the amount to add
107
* @returns SequenceNumber10
108
*/
109
SequenceNumber10
operator+
(uint16_t delta)
const
110
{
111
SequenceNumber10
ret((
m_value
+ delta) % 1024);
112
ret.
SetModulusBase
(
m_modulusBase
);
113
return
ret;
114
}
115
116
/**
117
* subtraction operator
118
* @param delta the amount to subtract
119
* @returns SequenceNumber10
120
*/
121
SequenceNumber10
operator-
(uint16_t delta)
const
122
{
123
SequenceNumber10
ret((
m_value
- delta) % 1024);
124
ret.
SetModulusBase
(
m_modulusBase
);
125
return
ret;
126
}
127
128
/**
129
* subtraction operator
130
* @param other the amount to subtract
131
* @returns SequenceNumber10
132
*/
133
uint16_t
operator-
(
const
SequenceNumber10
& other)
const
134
{
135
uint16_t diff =
m_value
- other.
m_value
;
136
return
diff;
137
}
138
139
/**
140
* greater than operator
141
* @param other the object to compare
142
* @returns true if greater than
143
*/
144
bool
operator>
(
const
SequenceNumber10
& other)
const
145
{
146
NS_ASSERT
(
m_modulusBase
== other.
m_modulusBase
);
147
uint16_t v1 = (
m_value
-
m_modulusBase
) % 1024;
148
uint16_t v2 = (other.
m_value
- other.
m_modulusBase
) % 1024;
149
return
v1 > v2;
150
}
151
152
/**
153
* equality operator
154
* @param other the object to compare
155
* @returns true if equal
156
*/
157
bool
operator==
(
const
SequenceNumber10
& other)
const
158
{
159
return
(
m_value
== other.
m_value
);
160
}
161
162
/**
163
* inequality operator
164
* @param other the object to compare
165
* @returns true if not equal
166
*/
167
bool
operator!=
(
const
SequenceNumber10
& other)
const
168
{
169
return
(
m_value
!= other.
m_value
);
170
}
171
172
/**
173
* less than or equal operator
174
* @param other the object to compare
175
* @returns true if less than or equal
176
*/
177
bool
operator<=
(
const
SequenceNumber10
& other)
const
178
{
179
return
(!this->
operator
>(other));
180
}
181
182
/**
183
* greater than or equal operator
184
* @param other the object to compare
185
* @returns true if greater than or equal
186
*/
187
bool
operator>=
(
const
SequenceNumber10
& other)
const
188
{
189
return
(this->
operator
>(other) || this->
operator
==(other));
190
}
191
192
/**
193
* less than operator
194
* @param other the object to compare
195
* @returns true if less than
196
*/
197
bool
operator<
(
const
SequenceNumber10
& other)
const
198
{
199
return
!this->
operator>
(other) &&
m_value
!= other.
m_value
;
200
}
201
202
friend
std::ostream&
operator<<
(std::ostream& os,
const
SequenceNumber10
& val);
203
204
private
:
205
uint16_t
m_value
;
///< the value
206
uint16_t
m_modulusBase
;
///< the modulus base
207
};
208
209
}
// namespace ns3
210
211
#endif
// LTE_RLC_SEQUENCE_NUMBER_H
ns3::SequenceNumber10
SequenceNumber10 class.
Definition
lte-rlc-sequence-number.h:23
ns3::SequenceNumber10::m_modulusBase
uint16_t m_modulusBase
the modulus base
Definition
lte-rlc-sequence-number.h:206
ns3::SequenceNumber10::operator==
bool operator==(const SequenceNumber10 &other) const
equality operator
Definition
lte-rlc-sequence-number.h:157
ns3::SequenceNumber10::operator-
uint16_t operator-(const SequenceNumber10 &other) const
subtraction operator
Definition
lte-rlc-sequence-number.h:133
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10(const SequenceNumber10 &value)
Constructor.
Definition
lte-rlc-sequence-number.h:47
ns3::SequenceNumber10::operator<
bool operator<(const SequenceNumber10 &other) const
less than operator
Definition
lte-rlc-sequence-number.h:197
ns3::SequenceNumber10::SetModulusBase
void SetModulusBase(uint16_t modulusBase)
Set modulus base.
Definition
lte-rlc-sequence-number.h:87
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10()
Definition
lte-rlc-sequence-number.h:25
ns3::SequenceNumber10::GetValue
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
Definition
lte-rlc-sequence-number.h:69
ns3::SequenceNumber10::operator!=
bool operator!=(const SequenceNumber10 &other) const
inequality operator
Definition
lte-rlc-sequence-number.h:167
ns3::SequenceNumber10::m_value
uint16_t m_value
the value
Definition
lte-rlc-sequence-number.h:205
ns3::SequenceNumber10::SequenceNumber10
SequenceNumber10(uint16_t value)
Constructor.
Definition
lte-rlc-sequence-number.h:36
ns3::SequenceNumber10::operator+
SequenceNumber10 operator+(uint16_t delta) const
addition operator
Definition
lte-rlc-sequence-number.h:109
ns3::SequenceNumber10::operator-
SequenceNumber10 operator-(uint16_t delta) const
subtraction operator
Definition
lte-rlc-sequence-number.h:121
ns3::SequenceNumber10::operator=
SequenceNumber10 & operator=(uint16_t value)
Assignment operator.
Definition
lte-rlc-sequence-number.h:59
ns3::SequenceNumber10::operator++
SequenceNumber10 operator++(int)
postfix ++ operator
Definition
lte-rlc-sequence-number.h:96
ns3::SequenceNumber10::operator>=
bool operator>=(const SequenceNumber10 &other) const
greater than or equal operator
Definition
lte-rlc-sequence-number.h:187
ns3::SequenceNumber10::operator>
bool operator>(const SequenceNumber10 &other) const
greater than operator
Definition
lte-rlc-sequence-number.h:144
ns3::SequenceNumber10::operator<<
friend std::ostream & operator<<(std::ostream &os, const SequenceNumber10 &val)
Ostream output function.
Definition
lte-rlc-sequence-number.cc:21
ns3::SequenceNumber10::operator<=
bool operator<=(const SequenceNumber10 &other) const
less than or equal operator
Definition
lte-rlc-sequence-number.h:177
ns3::SequenceNumber10::SetModulusBase
void SetModulusBase(SequenceNumber10 modulusBase)
Set modulus base.
Definition
lte-rlc-sequence-number.h:78
uint32_t
NS_ASSERT
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Definition
assert.h:55
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
src
lte
model
lte-rlc-sequence-number.h
Generated on Sun Dec 1 2024 18:20:42 for ns-3 by
1.11.0