44 TclObject*
create(
int,
const char*
const*) {
62 uid_probe_sink_Bits(0),
65 uid_last_packet_Bits(0),
67 ack_array_size_Bits(0),
77 bind(
"ts_Bits", (
int*) &
ts_Bits);
131 hdr_cmn* ch = HDR_CMN(p);
143 cout <<
"\033[1;37;45m (TX) UWPOLLING::TRIGGER packer hdr \033[0m" << std::endl;
147 else if ( ch->ptype() ==
PT_POLL)
158 cout <<
"\033[1;37;45m (TX) UWPOLLING::POLL packer hdr \033[0m" << std::endl;
173 cout <<
"\033[1;37;45m (TX) UWPOLLING::PROBE packer hdr \033[0m" << std::endl;
187 cout <<
"\033[1;37;45m (TX) UWPOLLING::PROBE_SINK packer hdr \033[0m" << std::endl;
194 std::vector<uint16_t>::iterator ack_id_it;
195 size_t fix_array_it = 0;
196 for (ack_id_it = ackh->
id_ack_.begin(); ack_id_it != ackh->
id_ack_.end(); ++ack_id_it) {
197 uid_acks_array[fix_array_it] = (uint16_t)*ack_id_it;
204 size_t actual_size = fix_array_it;
207 for (fix_array_it = 0; fix_array_it < actual_size; fix_array_it++) {
212 cout <<
"\033[1;37;45m (TX) UWPOLLING::ACK_SINK packer hdr \033[0m" << std::endl;
219 hdr_mac *mach = HDR_MAC(p);
226 cout <<
"\033[1;37;45m (TX) UWPOLLING::AUV_MULE packer hdr \033[0m" << std::endl;
236 hdr_cmn* ch = HDR_CMN(p);
242 memset(&(triggerh->
t_in_),0,
sizeof(triggerh->
t_in_));
253 cout <<
"\033[1;32;40m (RX) UWPOLLING::TRIGGER packer hdr \033[0m" << std::endl;
258 else if (ch->ptype() ==
PT_POLL)
262 memset(&(pollh->
id_),0,
sizeof(pollh->
id_));
273 cout <<
"\033[1;32;40m (RX) UWPOLLING::POLL packer hdr \033[0m" << std::endl;
284 memset(&(probeh->
ts_),0,
sizeof(probeh->
ts_));
298 cout <<
"\033[1;32;40m (RX) UWPOLLING::PROBE packer hdr \033[0m" << std::endl;
318 cout <<
"\033[1;32;40m (RX) UWPOLLING::PROBE_SINK packer hdr \033[0m" << std::endl;
329 for (
int i=0; i < array_size; i++) {
337 cout <<
"\033[1;32;40m (RX) UWPOLLING::ACK_SINK packer hdr \033[0m" << std::endl;
344 hdr_mac *mach = HDR_MAC(p);
355 cout <<
"\033[1;32;40m (RX) UWPOLLING::AUV_MULE packer hdr \033[0m" << std::endl;
367 hdr_cmn* ch = HDR_CMN(p);
372 cout <<
"\033[1;37;41m 1st field \033[0m, t_in_: " << triggerh->
t_in_ << std::endl
373 <<
"\033[1;37;41m 2nd field \033[0m, t_fin_: " << triggerh->
t_fin_ << std::endl
374 <<
"\033[1;37;41m 3rd field \033[0m, TRIGGER_uid: " << triggerh->
TRIGGER_uid_ << std::endl;
380 cout <<
"\033[1;37;41m 2nd field \033[0m, ts_: " << probeh->
ts_ << std::endl
381 <<
"\033[1;37;41m 3rd field \033[0m, n_pkts_: " << (
unsigned int) probeh->
n_pkts_ << std::endl
382 <<
"\033[1;37;41m 4th field \033[0m, id_node_: " << (
unsigned int) probeh->
id_node_ << std::endl
383 <<
"\033[1;37;41m 5th field \033[0m, PROBE_uid: " << (
unsigned int) probeh->
PROBE_uid_ << std::endl;
385 else if ( ch ->ptype() ==
PT_POLL)
388 cout <<
"\033[1;37;41m 1st field \033[0m, id_polled_: " << pollh->
id_ << std::endl
389 <<
"\033[1;37;41m 2nd field \033[0m, POLL_uid: " << pollh->
POLL_uid_ << std::endl
390 <<
"\033[1;37;41m 3rd field \033[0m, POLL_time_: " << pollh->
POLL_time_ << std::endl;
395 cout <<
"\033[1;37;41m 1st field \033[0m, id_sink: " << probe_sink_hdr->
id_sink_ << std::endl
396 <<
"\033[1;37;41m 2nd field \033[0m, PROBE_uid_: " << probe_sink_hdr->
PROBE_uid_ << std::endl
397 <<
"\033[1;37;41m 3rd field \033[0m, id_ack_: " << probe_sink_hdr->
id_ack_ << std::endl;
402 std::vector<uint16_t>::iterator ack_id_it;
404 for (ack_id_it = ackh->
id_ack_.begin(); ack_id_it != ackh->
id_ack_.end(); ++ack_id_it) {
406 cout <<
"\033[1;37;41m 1st field \033[0m, ack_id " << count <<
" : "
407 << (uint16_t)*ack_id_it << std::endl;
413 cout <<
"\033[1;37;41m 1st field \033[0m, pkt_uid_: " << auv_mule_hdr->
pkt_uid_ << std::endl
414 <<
"\033[1;37;41m 2nd field \033[0m, last_pkt_uid_: " << auv_mule_hdr->
last_pkt_uid_ << std::endl;
420 cout <<
"\033[0;46;30m Packer Name \033[0m: UWCBR" << std::endl;
421 cout <<
"** TRIGGER header fields" << std::endl;
422 cout <<
"\033[0;46;30m minimum backoff: \033[0m" <<
t_in_Bits <<
" bits" << std::endl;
423 cout <<
"\033[0;46;30m maximum backoff: \033[0m" <<
t_fin_Bits <<
" bits" << std::endl;
424 cout <<
"\033[0;46;30m trigger packet unique id: \033[0m" <<
uid_trigger_Bits <<
" bits" << std::endl;
426 cout <<
"** POLL header fields" << std::endl;
427 cout <<
"\033[0;46;30m polled node id: \033[0m" <<
id_polled_Bits <<
" bits" << std::endl;
428 cout <<
"\033[0;46;30m poll packet unique id: \033[0m" <<
uid_poll_Bits <<
" bits" << std::endl;
429 cout <<
"\033[0;46;30m poll time: \033[0m" <<
poll_time_Bits <<
" bits" << std::endl;
431 cout <<
"** PROBE header fields" << std::endl;
432 cout <<
"\033[0;46;30m timestemp: \033[0m" <<
ts_Bits <<
" bits" << std::endl;
433 cout <<
"\033[0;46;30m number of packets: \033[0m" <<
n_pkts_Bits <<
" bits" << std::endl;
434 cout <<
"\033[0;46;30m node id: \033[0m" <<
id_node_Bits <<
" bits" << std::endl;
435 cout <<
"\033[0;46;30m probe packets unique id: \033[0m" <<
uid_probe_Bits <<
" bits" << std::endl;
437 cout <<
"** PROBE SINK header fields" << std::endl;
438 cout <<
"\033[0;46;30m sink node id: \033[0m" <<
uid_sink_Bits <<
" bits" << std::endl;
439 cout <<
"\033[0;46;30m sink probe packets unique id: \033[0m" <<
uid_probe_sink_Bits <<
" bits" << std::endl;
440 cout <<
"\033[0;46;30m probe ack id: \033[0m" <<
uid_ack_Bits <<
" bits" << std::endl;
442 cout <<
"** AUV header fields" << std::endl;
443 cout <<
"\033[0;46;30m data packet unique id: \033[0m" <<
uid_packet_Bits <<
" bits" << std::endl;
444 cout <<
"\033[0;46;30m last tx packet unique id: \033[0m" <<
uid_last_packet_Bits <<
" bits" << std::endl;
446 cout <<
"** ACK SINK header fields" << std::endl;
447 cout <<
"\033[0;46;30m max number of ACKs: \033[0m" <<
ack_array_size_Bits <<
" bits" << std::endl;
448 cout <<
"\033[0;46;30m ack id: \033[0m" <<
ack_array_el_Bits <<
" bits per element" << std::endl;
TclObject * create(int, const char *const *)
Class to map a Uwpolling header into a bit stream, and vice-versa.
size_t uid_probe_sink_Bits
number of Bits used for PROBE_uid_ field on PROBE_SINK header
size_t t_fin_Bits
number of Bits used for t_fin field on TRIGGER header
size_t id_polled_Bits
number of Bits used for id_polled field on POLL header
size_t poll_time_Bits
number of Bits used for POLL_time field on POLL header
size_t uid_ack_Bits
number of Bits used for id_ack_ field on PROBE_SINK header
size_t uid_trigger_Bits
number of Bits used for uid field on TRIGGER header
size_t n_pkts_Bits
number of Bits used for n_pkts field on PROBE header
int sink_mac
Mac addres of the destination that need AUV_MULE hdr.
size_t ts_Bits
number of Bits used for ts field on PROBE header
void printMyHdrMap()
Method used for debug purposes.
~packerUwpolling()
Class destructor.
size_t uid_poll_Bits
number of Bits used for uid field on POLL header
void printMyHdrFields(Packet *)
Method used for debug purposes.
size_t t_in_Bits
number of Bits used for t_in field on TRIGGER header
size_t backoff_time_Bits
number of Bits used for backoff field on PROBE header
void init()
Init the Packer.
size_t uid_packet_Bits
number of Bits used for pkt_uid_ field on AUV_MULE header
size_t id_node_Bits
number of Bits used for id_node field on PROBE header
size_t ack_array_size_Bits
number of Bits used for number of ACKs on ACK_SINK header
size_t uid_sink_Bits
number of Bits used for id_sink_ field on PROBE_SINK header
packerUwpolling()
Class constructor.
size_t ack_array_el_Bits
number of Bits used for each ACK on ACK_SINK header
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...
size_t uid_probe_Bits
number of Bits used for uid field on PROBE header
size_t packMyHdr(Packet *, unsigned char *, size_t)
Method to transform the headers of Uwpolling into a stream of bits.
size_t ack_array_size
Maximum number of elements for the ACK vector.
size_t uid_last_packet_Bits
number of Bits used for last_pkt_uid_ field on AUV_MULE header
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.
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...
int debug_
Flag to enable debug messages.
PackerUwpollingClass class_module_packerUwpolling
Header of the class responsible to map the ns2 packet of Uwpolling into a bit stream,...
Header of the ACK sent by the SINK.
std::vector< uint16_t > id_ack_
ACK is the id of the wrong packets.
Header of the data sent from AUV MULE to SINK.
uint16_t pkt_uid_
unique ID of the transmitted packet by the AUV node
Header of the POLL message.
int id_
ID of the POLLED node.
uint16_t POLL_time_
Time needed by the AUV to poll all the nodes.
uint POLL_uid_
POLL packet unique ID.
Header of the PROBE message.
uint id_sink_
ID of the sink.
uint16_t id_ack_
ID used for ack purpose.
uint PROBE_uid_
Unique ID of the PROBE packet.
Header of the PROBE message.
uint PROBE_uid_
Unique ID of the PROBE packet.
uint16_t ts_
Timestamp of the most recent data packet.
uint id_node_
ID of the node.
int n_pkts_
Number of packets that the node wish to transmit to the AUV.
Header of the TRIGGER message.
uint TRIGGER_uid_
TRIGGER packet unique ID.
uint16_t t_in_
Minimum value in which the node can choose his backoff time.
uint16_t t_fin_
Maximum value in which the node can choose his backoff time.
#define HDR_PROBE_SINK(p)
alias defined to access the ACK SINK HEADER
#define HDR_ACK_SINK(p)
alias defined to access the ACK SINK HEADER
#define HDR_POLL(p)
alias defined to access the POLL HEADER
#define HDR_AUV_MULE(p)
alias defined to access the AUV MULE HEADER
#define HDR_TRIGGER(p)
alias defined to access the TRIGGER HEADER \
#define HDR_PROBE(p)
alias defined to access the PROBE HEADER