A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
lte-rlc-sequence-number.h
Go to the documentation of this file.
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Manuel Requena <manuel.requena@cttc.es>
19  */
20 
21 #ifndef LTE_RLC_SEQUENCE_NUMBER_H
22 #define LTE_RLC_SEQUENCE_NUMBER_H
23 
24 #include <limits>
25 #include <iostream>
26 #include <stdint.h>
27 
28 // #include "ns3/lte-rlc.h"
29 
30 namespace ns3 {
31 
32 
34 {
35 public:
37  : m_value (0),
38  m_modulusBase (0)
39  {}
40 
41  explicit SequenceNumber10 (uint16_t value)
42  : m_value (value % 1024),
43  m_modulusBase (0)
44  {}
45 
47  : m_value (value.m_value),
49  {}
50 
51  SequenceNumber10& operator= (uint16_t value)
52  {
53  m_value = value % 1024;
54  return *this;
55  }
56 
57 
62  uint16_t GetValue () const
63  {
64  return m_value;
65  }
66 
67  void SetModulusBase (SequenceNumber10 modulusBase)
68  {
69  m_modulusBase = modulusBase.m_value;
70  }
71 
72  void SetModulusBase (uint16_t modulusBase)
73  {
74  m_modulusBase = modulusBase;
75  }
76 
77  // postfix ++
79  {
80  SequenceNumber10 retval (m_value);
81  m_value = (m_value + 1) % 1024;
82  return retval;
83  }
84 
85  SequenceNumber10 operator + (uint16_t delta) const
86  {
87  SequenceNumber10 ret ((m_value + delta) % 1024);
89  return ret;
90  }
91 
92  SequenceNumber10 operator - (uint16_t delta) const
93  {
94  SequenceNumber10 ret ((m_value - delta) % 1024);
96  return ret;
97  }
98 
99  uint16_t operator - (const SequenceNumber10 &other) const
100  {
101  uint16_t diff = m_value - other.m_value;
102  return (diff);
103  }
104 
105  bool operator > (const SequenceNumber10 &other) const
106  {
107  SequenceNumber10 v1 ((m_value - m_modulusBase) % 1024);
108  SequenceNumber10 v2 ((other.m_value - other.m_modulusBase) % 1024);
109  return ( v1.GetValue () > v2.GetValue () );
110  }
111 
112  bool operator == (const SequenceNumber10 &other) const
113  {
114  return (m_value == other.m_value);
115  }
116 
117  bool operator != (const SequenceNumber10 &other) const
118  {
119  return (m_value != other.m_value);
120  }
121 
122  bool operator <= (const SequenceNumber10 &other) const
123  {
124  return (!this->operator> (other));
125  }
126 
127  bool operator >= (const SequenceNumber10 &other) const
128  {
129  return (this->operator> (other) || this->operator== (other));
130  }
131 
132  bool operator < (const SequenceNumber10 &other) const
133  {
134  return !this->operator> (other) && m_value != other.m_value;
135  }
136 
137 
138  friend std::ostream & operator<< (std::ostream& os, const SequenceNumber10 &val);
139 
140 private:
141  uint16_t m_value;
142  uint16_t m_modulusBase;
143 };
144 
145 
146 } // namespace ns3
147 
148 #endif // LTE_RLC_SEQUENCE_NUMBER_H
uint16_t GetValue() const
Extracts the numeric value of the sequence number.
friend std::ostream & operator<<(std::ostream &os, const SequenceNumber10 &val)
SequenceNumber10 operator++(int)
bool operator!=(const SequenceNumber10 &other) const
bool operator>=(const SequenceNumber10 &other) const
void SetModulusBase(SequenceNumber10 modulusBase)
bool operator>(const SequenceNumber10 &other) const
bool operator<=(const SequenceNumber10 &other) const
SequenceNumber10 operator+(uint16_t delta) const
SequenceNumber10 & operator=(uint16_t value)
SequenceNumber10 operator-(uint16_t delta) const
bool operator<(const SequenceNumber10 &other) const
void SetModulusBase(uint16_t modulusBase)
SequenceNumber10(SequenceNumber10 const &value)
bool operator==(const SequenceNumber10 &other) const