LEFT | RIGHT |
1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 The Georgia Institute of Technology· | 3 * Copyright (c) 2009 The Georgia Institute of Technology· |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 * As the nix-vector travels along the route, an internal· | 52 * As the nix-vector travels along the route, an internal· |
53 * private member variable keeps track of how many bits· | 53 * private member variable keeps track of how many bits· |
54 * have been used. At a particular node, the nix-vector· | 54 * have been used. At a particular node, the nix-vector· |
55 * is used to return the next neighbor-index. This· | 55 * is used to return the next neighbor-index. This· |
56 * neighbor-index is used to determine which net-device· | 56 * neighbor-index is used to determine which net-device· |
57 * to use. The number of bits used would then be· | 57 * to use. The number of bits used would then be· |
58 * incremented accordingly, and the packet would be· | 58 * incremented accordingly, and the packet would be· |
59 * routed. | 59 * routed. |
60 */ | 60 */ |
61 | 61 |
62 typedef std::vector<uint32_t> NixBits_t; | |
63 | |
64 class NixVector : public Object | 62 class NixVector : public Object |
65 { | 63 { |
66 public: | 64 public: |
67 NixVector (); | 65 NixVector (); |
68 NixVector (const NixVector &o); | 66 NixVector (const NixVector &o); |
69 ~NixVector (); | 67 ~NixVector (); |
70 Ptr<NixVector> Copy (void) const; | 68 Ptr<NixVector> Copy (void) const; |
71 NixVector &operator = (const NixVector &o); | 69 NixVector &operator = (const NixVector &o); |
72 static TypeId GetTypeId (void); | 70 static TypeId GetTypeId (void); |
73 /** | 71 /** |
(...skipping 16 matching lines...) Expand all Loading... |
90 * | 88 * |
91 * Extracts the number of bits specified from· | 89 * Extracts the number of bits specified from· |
92 * the vector and returns the value extracted | 90 * the vector and returns the value extracted |
93 * | 91 * |
94 * Note: This function assumes that the number of bits to be extracted· | 92 * Note: This function assumes that the number of bits to be extracted· |
95 * is always less than or equal to 32, ie., you can only span one· | 93 * is always less than or equal to 32, ie., you can only span one· |
96 * entry of a nix-vector at a time. This is reasonable, since 32· | 94 * entry of a nix-vector at a time. This is reasonable, since 32· |
97 * bits gives you 2^32 possible neighbors. | 95 * bits gives you 2^32 possible neighbors. |
98 */ | 96 */ |
99 uint32_t ExtractNeighborIndex (uint32_t numberOfBits); | 97 uint32_t ExtractNeighborIndex (uint32_t numberOfBits); |
100 /** | |
101 * \return the nix-vector | |
102 */ | |
103 NixBits_t GetNixVector (void); | |
104 /** | 98 /** |
105 * \return number of bits remaining in the· | 99 * \return number of bits remaining in the· |
106 * nix-vector (ie m_total - m_used) | 100 * nix-vector (ie m_total - m_used) |
107 */ | 101 */ |
108 uint32_t GetRemainingBits (void); | 102 uint32_t GetRemainingBits (void); |
109 /** | 103 /** |
110 * \return the number of bytes required for serialization· | 104 * \return the number of bytes required for serialization· |
111 */ | 105 */ |
112 uint32_t GetSerializedSize (void) const; | 106 uint32_t GetSerializedSize (void) const; |
113 /** | 107 /** |
(...skipping 18 matching lines...) Expand all Loading... |
132 * AddNeighborIndex or ExtractNeighborIndex. | 126 * AddNeighborIndex or ExtractNeighborIndex. |
133 */ | 127 */ |
134 uint32_t BitCount (uint32_t numberOfNeighbors) const;·· | 128 uint32_t BitCount (uint32_t numberOfNeighbors) const;·· |
135 /* for printing of nix-vector */ | 129 /* for printing of nix-vector */ |
136 void DumpNixVector (std::ostream &os) const; | 130 void DumpNixVector (std::ostream &os) const; |
137 /* for printing of nix-vector */ | 131 /* for printing of nix-vector */ |
138 friend std::ostream & operator <<( std::ostream &outs, const NixVector &nix)
;· | 132 friend std::ostream & operator <<( std::ostream &outs, const NixVector &nix)
;· |
139 | 133 |
140 | 134 |
141 private: | 135 private: |
| 136 typedef std::vector<uint32_t> NixBits_t; |
| 137 |
142 /* the actual nix-vector */ | 138 /* the actual nix-vector */ |
143 NixBits_t m_nixVector; | 139 NixBits_t m_nixVector; |
144 | 140 |
145 /* for tracking where we are | 141 /* for tracking where we are |
146 * in the nix-vector | 142 * in the nix-vector |
147 */ | 143 */ |
148 uint32_t m_used; | 144 uint32_t m_used; |
149 ·································· | 145 ·································· |
150 /* for tracking how many bits we | 146 /* for tracking how many bits we |
151 * have used in the current vector | 147 * have used in the current vector |
152 * entry. need this in order to· | 148 * entry. need this in order to· |
153 * expand the vector passed 32bits | 149 * expand the vector passed 32bits |
154 */ | 150 */ |
155 uint32_t m_currentVectorBitSize; | 151 uint32_t m_currentVectorBitSize; |
156 | 152 |
157 /* a counter of how total bits are in· | 153 /* a counter of how total bits are in· |
158 * the nix-vector | 154 * the nix-vector |
159 */ | 155 */ |
160 uint32_t m_totalBitSize; | 156 uint32_t m_totalBitSize; |
161 | 157 |
162 /* internal for pretty printing of nix-vector */ | 158 /* internal for pretty printing of nix-vector */ |
163 void PrintDec2BinNixFill (uint32_t, uint32_t, std::ostream &os) const; | 159 void PrintDec2BinNixFill (uint32_t, uint32_t, std::ostream &os) const; |
164 | 160 |
165 /* internal for pretty printing of nix-vector */ | 161 /* internal for pretty printing of nix-vector */ |
166 void PrintDec2BinNix (uint32_t, uint32_t, std::ostream &os) const; | 162 void PrintDec2BinNix (uint32_t, uint32_t, std::ostream &os) const; |
167 }; | 163 }; |
168 } // namespace ns3 | 164 } // namespace ns3 |
169 | 165 |
170 #endif | 166 #endif |
LEFT | RIGHT |