45 TclObject*
create(
int,
const char*
const*) {
55rfftvalid_field_Bits(0),
56priority_filed_Bits(0),
57payload_size_field_Bits(0)
74 std::cout <<
"Re-initialization of n_bits for the uwApplication packer." << std::endl;
88 hdr_cmn* hcmn = HDR_CMN(p);
100 offset +=
put(buffer, offset, &(applh->
payload_msg), payload_size_bits);
103 std::cout <<
"\033[1;37;45m (TX) UWAPPLICATION::DATA packer hdr \033[0m" << std::endl;
112 hdr_cmn* hcmn = HDR_CMN(p);
118 memset(&(applh->
sn_), 0, sizeof (applh->
sn_));
120 memset(&(applh->
rftt_), 0, sizeof (applh->
rftt_));
131 offset +=
get(buffer, offset, &(applh->
payload_msg), payload_size_bit);
134 std::cout <<
"\033[1;32;40m (RX) UWAPPLICATION::DATA packer hdr \033[0m" << std::endl;
142 std::cout <<
"\033[1;37;45m Packer Name \033[0m: UWAPPLICATION \n";
143 std::cout <<
"** DATA fields:\n";
144 std::cout <<
"\033[1;37;45m Field: SN_FIELD: \033[0m:" <<
n_bits[
SN_FIELD] <<
" bits\n";
145 std::cout <<
"\033[1;37;45m Field: RFFT_FIELD: \033[0m:" <<
n_bits[
RFFT_FIELD] <<
" bits\n";
146 std::cout <<
"\033[1;37;45m Field: RFFTVALID_FIELD: \033[0m:" <<
n_bits[
RFFTVALID_FIELD] <<
" bits\n";
147 std::cout <<
"\033[1;37;45m Field: PRIORITY_FIELD: \033[0m:" <<
n_bits[
PRIORITY_FIELD] <<
" bits\n";
150 std::cout << std::endl;
155 hdr_cmn* hcmn = HDR_CMN(p);
160 std::cout <<
"\033[1;37;45m 1st field \033[0m, SN_FIELD: " << applh->
sn_ << std::endl;
161 std::cout <<
"\033[1;37;45m 2nd field \033[0m, RFFT_FIELD: " << applh->
rftt_ << std::endl;
162 std::cout <<
"\033[1;37;45m 3rd field \033[0m, RFFTVALID_FIELD: " << applh->
rftt_valid_ << std::endl;
163 std::cout <<
"\033[1;37;45m 4th field \033[0m, PRIORITY_FIELD: " << (int)applh->
priority_ << std::endl;
164 std::cout <<
"\033[1;37;45m 5th field \033[0m, PAYLOADMSG_SIZE_FIELD: " << applh->
payload_size_ << std::endl;
165 std::cout <<
"\033[1;37;45m 5th field \033[0m, PAYLOADMSG_FIELD: ";
packet_t PT_DATA_APPLICATION
DATA packet type.
TclObject * create(int, const char *const *)
PackerUwApplicationClass()
Class to map a ns2 mac header into a bit stream, and vice-versa.
void printMyHdrMap()
Method used for debug purposes.
size_t unpackMyHdr(unsigned char *buffer, size_t offset, Packet *p)
Method responsible to take the informations from the received buffer and store it into the headers of...
void init()
Init the packer for uwApplication prototocol.
size_t sn_field_Bits
Bit length of the sn_ field to be put in the header stream of bits.
size_t rfft_field_Bits
Bit length of the rfft_field to be put in the header stream of bits.
void printMyHdrFields(Packet *)
Method used for debug purposes.
size_t rfftvalid_field_Bits
Bit length of the rfftvalid_field to be put in the header stream of bits.
@ PRIORITY_FIELD
Priority flag: 1 means high priority, 0 normal priority.
@ SN_FIELD
Serial number of the packet.
@ RFFT_FIELD
Forward Trip Time of the packet.
@ RFFTVALID_FIELD
Flag used to set the validity of the fft field.
@ PAYLOAD_SIZE_FIELD
Message payload.
packer_uwApplication()
Constructor packer_uwApplication class.
size_t packMyHdr(Packet *p, unsigned char *buffer, size_t offset)
Method to transform the headers of uwApplication protocol into a stream of bits.
~packer_uwApplication()
Destructor packer_uwApplication class.
size_t payload_size_field_Bits
Bit length of the payloadmsg_field to be put in the header stream of bits.
size_t priority_filed_Bits
Bit length of the priority_field 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.
PackerUwApplicationClass class_module_packerUwApplication
Content header of TRIGGER packet.
int rftt_
Forward Trip Time of the packet.
char payload_msg[MAX_LENGTH_PAYLOAD]
Message payload.
uint16_t sn_
Serial number of the packet.
bool rftt_valid_
Flag used to set the validity of the fft field.
uint16_t payload_size_
Size (bytes) of the payload.
uint16_t & payload_size()
uint8_t priority_
Priority flag: 1 means high priority, 0 normal priority.