47 : TclClass(
"NS2/MAC/Packer")
79 cout <<
"Initialization (from constructor) of n_bits for the UWMAC "
103 cout <<
"Re-initialization of n_bits for the UWMAC packer " << endl;
121 hdr_mac *hmac = HDR_MAC(p);
125 offset +=
put(buf, offset, &(hmac->ftype_),
n_bits[field_idx++]);
126 offset +=
put(buf, offset, &(hmac->macSA_),
n_bits[field_idx++]);
127 offset +=
put(buf, offset, &(hmac->macDA_),
n_bits[field_idx++]);
128 offset +=
put(buf, offset, &(hmac->hdr_type_),
n_bits[field_idx++]);
129 offset +=
put(buf, offset, &(hmac->txtime_),
n_bits[field_idx++]);
130 offset +=
put(buf, offset, &(hmac->sstime_),
n_bits[field_idx++]);
131 offset +=
put(buf, offset, &(hmac->padding_),
n_bits[field_idx++]);
134 printf(
"\033[0;45;30m TX MAC packer hdr \033[0m \n");
145 hdr_mac *hmac = HDR_MAC(p);
149 memset(&(hmac->ftype_), 0,
sizeof(hmac->ftype_));
150 offset +=
get(buf, offset, &(hmac->ftype_),
n_bits[field_idx++]);
152 memset(&(hmac->macSA_), 0,
sizeof(hmac->macSA_));
153 offset +=
get(buf, offset, &(hmac->macSA_),
n_bits[field_idx++]);
156 memset(&(hmac->macDA_), 0,
sizeof(hmac->macDA_));
157 offset +=
get(buf, offset, &(hmac->macDA_),
n_bits[field_idx++]);
173 memset(&(hmac->hdr_type_), 0,
sizeof(hmac->hdr_type_));
174 offset +=
get(buf, offset, &(hmac->hdr_type_),
n_bits[field_idx++]);
176 memset(&(hmac->txtime_), 0,
sizeof(hmac->txtime_));
177 offset +=
get(buf, offset, &(hmac->txtime_),
n_bits[field_idx++]);
179 memset(&(hmac->sstime_), 0,
sizeof(hmac->sstime_));
180 offset +=
get(buf, offset, &(hmac->sstime_),
n_bits[field_idx++]);
182 memset(&(hmac->padding_), 0,
sizeof(hmac->padding_));
183 offset +=
get(buf, offset, &(hmac->padding_),
n_bits[field_idx++]);
187 printf(
"\033[0;45;30m RX MAC packer hdr \033[0m \n");
197 std::cout <<
"\033[0;45;30m"
200 <<
" UWMAC" << std::endl;
201 std::cout <<
"\033[0;45;30m 1st field "
203 <<
" ftype: " <<
Ftype_Bits <<
" bits" << std::endl;
204 std::cout <<
"\033[0;45;30m 2st field "
206 <<
" macDA: " <<
SRC_Bits <<
" bits" << std::endl;
207 std::cout <<
"\033[0;45;30m 3st field "
209 <<
" macDA: " <<
DST_Bits <<
" bits" << std::endl;
210 std::cout <<
"\033[0;45;30m 4st field "
212 <<
" hdr_type: " <<
Htype_Bits <<
" bits" << std::endl;
213 std::cout <<
"\033[0;45;30m 5st field "
215 <<
" txtime: " <<
TXtime_Bits <<
" bits" << std::endl;
216 std::cout <<
"\033[0;45;30m 6st field "
218 <<
" sstime: " <<
SStime_Bits <<
" bits" << std::endl;
219 std::cout <<
"\033[0;45;30m 7st field "
221 <<
" padding: " <<
Padding_Bits <<
" bits" << std::endl;
229 hdr_mac *hmac = HDR_MAC(p);
232 cout <<
"\033[0;45;30m ftype:\033[0m " << hmac->ftype_ <<
" "
235 cout <<
"\033[0;45;30m macSA:\033[0m " << hmac->macSA_ <<
" "
238 cout <<
"\033[0;45;30m macDA:\033[0m " << hmac->macDA_ <<
" "
241 cout <<
"\033[0;45;30m hdr_type:\033[0m " << hmac->hdr_type_ <<
" "
244 cout <<
"\033[0;45;30m txtime:\033[0m " << hmac->txtime_ <<
" "
245 <<
hex_bytes(hmac->txtime_) << std::endl;
247 cout <<
"\033[0;45;30m sstime:\033[0m " << hmac->sstime_ <<
" "
248 <<
hex_bytes(hmac->sstime_) << std::endl;
250 cout <<
"\033[0;45;30m padding:\033[0m " << hmac->padding_ <<
" "
Class to create the Otcl shadow object for an object of the class packer.
TclObject * create(int, const char *const *)
Class to map a ns2 mac header into a bit stream, and vice-versa.
~packerMAC()
Class destructor.
size_t DST_Bits
Bit length of the macSA_ field to be put in the header stream of bits.
size_t Htype_Bits
Bit length of the macDA_ field to be put in the header stream of bits.
size_t TXtime_Bits
Bit length of the hdr_type_ field to be put in the header stream of bits.
size_t SStime_Bits
Bit length of the txtime_ field to be put in the header stream of bits.
void printMyHdrMap()
Method used for debug purposes.
size_t packMyHdr(Packet *, unsigned char *, size_t)
Method to transform the headers of Uwpolling into a stream of bits.
void printMyHdrFields(Packet *)
Method used for debug purposes.
size_t SRC_Bits
Bit length of the ftype_ field to be put in the header stream of bits.
size_t Padding_Bits
Bit length of the sstime_ field to be put in the header stream of bits.
void init()
Init the Packer.
packerMAC()
Class constructor.
size_t unpackMyHdr(unsigned char *, size_t, Packet *)
Method responsible to take the informations from the received buffer and store it into the headers of...
Class exploited by the Uwal module to map an NS-Miracle packet into a bit stream, and vice-versa.
std::vector< size_t > n_bits
Vector of elements containing the indication of the number of bits to consider for each header field.
size_t put(unsigned char *buffer, size_t offset, void *val, size_t h)
Method used to map in a certain number of bits, contained in a buffer of chars, a given variable.
static std::string hex_bytes(float)
size_t get(unsigned char *buffer, size_t offset, void *val, size_t h)
Method used to retrieve a given variable from a certain number of bits contained in a buffer of chars...
static T restoreSignedValue(T _header_field, const uint32_t &_num_compressed_bits)
int debug_
Flag to enable debug messages.
PackerMACClass class_module_packerMAC
Header of the class responsible to map the ns2 packet of mac into a bit stream, and vice-versa.