46 : TclClass(
"UW/RANGING_TDOA/Packer")
59 , source_pkt_id_Bits(0)
60 , source_node_id_Bits(0)
74 std::cout <<
"Re-initialization of n_bits for the uwRangingTDOA packer."
88 hdr_cmn *hcmn = HDR_CMN(p);
101 offset +=
put(buffer,
107 offset +=
put(buffer, offset, &(tdoah->
times_), times_size_bits);
110 std::cout <<
"\033[1;37;45m (TX) UwRangingTDOA::DATA packer hdr "
122 hdr_cmn *hcmn = HDR_CMN(p);
128 offset +=
get(buffer,
133 offset +=
get(buffer,
138 offset +=
get(buffer,
144 offset +=
get(buffer, offset, &(tdoah->
times_), times_size_bits);
147 std::cout <<
"\033[1;32;40m (RX) UwRangingTDOA::DATA packer hdr "
148 "\033[0m" << std::endl;
158 std::cout <<
"\033[1;37;45m Packer Name \033[0m: UWRANGINGTDOA \n";
159 std::cout <<
"** DATA fields:\n";
160 std::cout <<
"\033[1;37;45m Field: SOURCE_PKT_ID_FIELD: \033[0m:"
162 std::cout <<
"\033[1;37;45m Field: SOURCE_NODE_ID_FIELD: \033[0m:"
164 std::cout <<
"\033[1;37;45m Field: TIMES_SIZE_FIELD: \033[0m:"
166 std::cout << std::endl;
172 hdr_cmn *hcmn = HDR_CMN(p);
177 std::cout <<
"\033[1;37;45m 1st field \033[0m, SOURCE_PKT_ID_FIELD: "
179 std::cout <<
"\033[1;37;45m 2nd field \033[0m, SOURCE_NODE_ID_FIELD: "
181 std::cout <<
"\033[1;37;45m 3rd field \033[0m, TIMES_SIZE_FIELD: "
183 std::cout <<
"\033[1;37;45m 4th field \033[0m, TIMES: ";
184 for (
int i = 0; i < tdoah->
times_size(); i++) {
185 std::cout <<
"(id: " << (int) tdoah->
times_[i].
id
187 <<
" time: " << tdoah->
times_[i].
time <<
") , ";
packet_t PT_UWRANGING_TDOA
PackerUwRangingTDOAClass()
TclObject * create(int, const char *const *)
Class to map a ns2 uwRangingTDOA header into a bit stream, and vice-versa.
packer_uwRangingTDOA()
Constructor packer_uwRangingTDOA class.
virtual size_t packMyHdr(Packet *p, unsigned char *buffer, size_t offset) override
Method to transform the headers of uwRangingTDOA protocol into a stream of bits.
size_t source_pkt_id_Bits
Bit length of the source_pkt_id field to be put in the header stream of bits.
virtual void printMyHdrFields(Packet *) override
Method used for debug purposes.
virtual size_t unpackMyHdr(unsigned char *buffer, size_t offset, Packet *p) override
Method responsible to take the informations from the received buffer and store it into the headers of...
size_t times_size_Bits
Bit length of the times_size_field to be put in the header stream of bits.
virtual void init() override
Init the packer for uwRangingTDOA prototocol.
virtual void printMyHdrMap() override
Method used for debug purposes.
@ SOURCE_PKT_ID_FIELD
ID of the ranging packet.
@ SOURCE_NODE_ID_FIELD
ID of the node.
@ TIMES_SIZE_FIELD
Size of the payload.
size_t source_node_id_Bits
Bit length of the source_node_id to be put in the header stream of bits.
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.
PackerUwRangingTDOAClass class_module_packerUwRangingTDOA
Header of the token bus protocol.
uwrange_node_t times_size_
uwrange_pkt_t source_pkt_id
Ranging packet id.
uwrange_node_t source_node_id
Source node id.
tdoa_entry times_[MAX_NUM_NODES]
Number of entries in the packet.
Define the struct of a single tdoa payload entry.
uwrange_pkt_t id
Id of the packet.
uwrange_time_t time
Holdover time.
uwrange_node_t node
Id of the source node.
Common structures and variables in the protocol.
#define HDR_RANGING_TDOA(p)
alias defined to access the hdr_ranging_tdoa HEADER