mac: set duration to 0 and allocate statically
This commit is contained in:
+14
-13
@@ -106,30 +106,31 @@ void app_in (pmt::pmt_t msg) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(msg_len > 1500) {
|
||||
throw std::invalid_argument("Frame too large (> 1500)");
|
||||
}
|
||||
|
||||
// make MAC frame
|
||||
int psdu_length;
|
||||
char *psdu;
|
||||
generate_mac_data_frame(msdu, msg_len, &psdu, &psdu_length);
|
||||
generate_mac_data_frame(msdu, msg_len, &psdu_length);
|
||||
|
||||
// dict
|
||||
pmt::pmt_t dict = pmt::make_dict();
|
||||
dict = pmt::dict_add(dict, pmt::mp("crc_included"), pmt::PMT_T);
|
||||
|
||||
// blob
|
||||
pmt::pmt_t mac = pmt::make_blob(psdu, psdu_length);
|
||||
pmt::pmt_t mac = pmt::make_blob(d_psdu, psdu_length);
|
||||
|
||||
// pdu
|
||||
message_port_pub(pmt::mp("phy out"), pmt::cons(dict, mac));
|
||||
|
||||
free(psdu);
|
||||
}
|
||||
|
||||
void generate_mac_data_frame(const char *msdu, int msdu_size, char **psdu, int *psdu_size) {
|
||||
void generate_mac_data_frame(const char *msdu, int msdu_size, int *psdu_size) {
|
||||
|
||||
// mac header
|
||||
mac_header header;
|
||||
header.frame_control = 0x0008;
|
||||
header.duration = 0x002e;
|
||||
header.duration = 0x0000;
|
||||
|
||||
for(int i = 0; i < 6; i++) {
|
||||
header.addr1[i] = d_dst_mac[i];
|
||||
@@ -148,18 +149,17 @@ void generate_mac_data_frame(const char *msdu, int msdu_size, char **psdu, int *
|
||||
|
||||
//header size is 24, plus 4 for FCS means 28 bytes
|
||||
*psdu_size = 28 + msdu_size;
|
||||
*psdu = (char *) calloc(*psdu_size, sizeof(char));
|
||||
|
||||
//copy mac header into psdu
|
||||
std::memcpy(*psdu, &header, 24);
|
||||
std::memcpy(d_psdu, &header, 24);
|
||||
//copy msdu into psdu
|
||||
memcpy(*psdu + 24, msdu, msdu_size);
|
||||
memcpy(d_psdu + 24, msdu, msdu_size);
|
||||
//compute and store fcs
|
||||
boost::crc_32_type result;
|
||||
result.process_bytes(*psdu, msdu_size + 24);
|
||||
result.process_bytes(d_psdu, msdu_size + 24);
|
||||
|
||||
unsigned int fcs = result.checksum();
|
||||
memcpy(*psdu + msdu_size + 24, &fcs, sizeof(unsigned int));
|
||||
uint32_t fcs = result.checksum();
|
||||
memcpy(d_psdu + msdu_size + 24, &fcs, sizeof(uint32_t));
|
||||
}
|
||||
|
||||
bool check_mac(std::vector<uint8_t> mac) {
|
||||
@@ -172,6 +172,7 @@ private:
|
||||
uint8_t d_src_mac[6];
|
||||
uint8_t d_dst_mac[6];
|
||||
uint8_t d_bss_mac[6];
|
||||
uint8_t d_psdu[1528];
|
||||
};
|
||||
|
||||
ofdm_mac::sptr
|
||||
|
||||
Reference in New Issue
Block a user