Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include ARQ scheme #10 #37

Merged
merged 24 commits into from
Oct 11, 2020
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
e91fcb3
ARQ mode: change message definitions of dldata and uldata to contain
lukasostendorf Sep 1, 2020
9ca9887
add Unit Tests for some MAC messages
lukasostendorf Sep 1, 2020
91a0395
fix linting
lukasostendorf Sep 1, 2020
4d7d619
ARQ: add constructor and parser for ACK messages
lukasostendorf Sep 2, 2020
fc790d6
ARQ: implement transmission window when sending fragments
lukasostendorf Sep 2, 2020
be349dc
ARQ: include ACK transmissions
lukasostendorf Sep 2, 2020
09a8d23
ARQ: adapt reassembler to work with AM und UM mode
lukasostendorf Sep 2, 2020
1d8e428
ARQ: include handlers for ACK messages
lukasostendorf Sep 2, 2020
94fc0bf
add Unit Tests for some MAC messages
lukasostendorf Sep 3, 2020
727312b
Bugfixes for ARQ:
lukasostendorf Sep 3, 2020
6489d21
ARQ: fix crash in mac fragmenter object
lukasostendorf Sep 13, 2020
bcff676
ARQ: fix TCP/IP packet detection + add some logs
lukasostendorf Sep 28, 2020
b55319c
ARQ: bugfixes for fragmenter and reassembler
lukasostendorf Sep 29, 2020
8d10fb3
Mac messages: increase max sequence number for better flow with ARQ
lukasostendorf Sep 29, 2020
082680e
ARQ: faster ACK transmission from Client to BS
lukasostendorf Sep 29, 2020
e3654ce
Fix mac uldata_ack and dldata_ack messages to 4Bit seqNr size
lukasostendorf Sep 29, 2020
c0f2982
Client scheduler: check if a fragment is available before calling get…
lukasostendorf Oct 1, 2020
21bfe3a
Adjust log levels for some PHY functions
lukasostendorf Oct 3, 2020
5ffd041
ARQ: clean up code
lukasostendorf Oct 3, 2020
acb6b48
ARQ: refactor mac_frag_get_fragment for better readability
lukasostendorf Oct 5, 2020
cf059c9
ARQ: Bugfixes for mac_frag_get_fragment
lukasostendorf Oct 10, 2020
e877088
Add unit tests for packet inspection
lukasostendorf Oct 10, 2020
1a62ff1
Fix linting
lukasostendorf Oct 10, 2020
78399da
Merge branch 'develop' into arq_scheme
Oct 11, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions src/mac/mac_bs.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,19 @@

#include "mac_bs.h"
#include "../util/log.h"
#include <net/ethernet.h>
#include <netinet/ip.h>
#include <unistd.h>

#ifdef MAC_TEST_DELAY
#include "../runtime/test.h"
#endif

user_s *ue_create(uint userid) {
user_s *ue_create(uint userid, long long unsigned int *subframe_ptr) {
// create user instance and association response
user_s *new_ue = calloc(sizeof(user_s), 1);
new_ue->msg_control_queue = ringbuf_create(MAC_CTRL_MSG_BUF_SIZE);
new_ue->fragmenter = mac_frag_init();
new_ue->fragmenter = mac_frag_init(subframe_ptr);
new_ue->reassembler = mac_assmbl_init();
new_ue->userid = userid;
new_ue->ul_queue = 0;
Expand Down Expand Up @@ -63,7 +65,7 @@ MacBS mac_bs_init() {
macinst->UE[i] = NULL;
}
macinst->broadcast_ctrl_queue = ringbuf_create(MAC_CTRL_MSG_BUF_SIZE);
macinst->broadcast_data_fragmenter = mac_frag_init();
macinst->broadcast_data_fragmenter = mac_frag_init(&macinst->subframe_cnt);

#ifdef MAC_ENABLE_TAP_DEV
macinst->tapdevice = tap_init("tap0");
Expand Down Expand Up @@ -137,7 +139,7 @@ void mac_bs_add_new_ue(MacBS mac, uint8_t rachuserid, uint8_t rach_try_cnt,
ringbuf_put(mac->broadcast_ctrl_queue, response);
} else {
// create new UE struct
mac->UE[userid] = ue_create(userid);
mac->UE[userid] = ue_create(userid, &mac->subframe_cnt);
mac->UE[userid]->fs = fs;
mac->UE[userid]->last_seen = mac->subframe_cnt;
mac->UE[userid]->timingadvance = timing_diff;
Expand Down Expand Up @@ -199,6 +201,8 @@ int mac_bs_add_txdata(MacBS mac, uint8_t destUserID, MacDataFrame frame) {
MacFrag fragmenter = NULL;
if (destUserID == USER_BROADCAST) {
fragmenter = mac->broadcast_data_fragmenter;
// force frames that are forwarded using broadcast frag to disable ARQ
frame->do_arq = 0;
} else if (mac->UE[destUserID] != NULL) {
fragmenter = mac->UE[destUserID]->fragmenter;
} else {
Expand Down Expand Up @@ -284,7 +288,15 @@ int mac_bs_handle_message(MacBS mac, MacMessage msg, uint8_t userID) {
INFO, "[MAC BS] mcs_change_request from user %d mcs: %d is_ul %d\n",
userID, msg->hdr.MCSChangeReq.mcs, msg->hdr.MCSChangeReq.ul_flag)
break;
case dl_data_ack:
mac_frag_ack_fragment(user->fragmenter, msg);
break;
case ul_data:
if (msg->hdr.ULdata.do_ack) {
MacMessage ack = mac_msg_create_ul_data_ack(ACK, msg->hdr.ULdata.seqNr,
msg->hdr.ULdata.fragNr);
ringbuf_put(user->msg_control_queue, ack);
}
frame = mac_assmbl_reassemble(user->reassembler, msg);
if (frame != NULL) {
user->stats.bytes_rx += frame->size;
Expand Down Expand Up @@ -384,6 +396,11 @@ void mac_bs_map_slot(MacBS mac, uint subframe, uint slot, user_s *ue) {
MacMessage msg = mac_frag_get_fragment(ue->fragmenter, payload_size, 0);
lchan_add_message(chan, msg);
ue->stats.bytes_tx += msg->payload_len;
if (msg->hdr.DLdata.do_ack) {
// if the user is expected to send an ack for this frame, indicade a
// pending transmission to the scheduler
ue->ul_queue++;
}
mac_msg_destroy(msg);
}
lchan_calc_crc(chan);
Expand Down Expand Up @@ -692,6 +709,19 @@ void *mac_bs_tap_rx_th(void *arg) {
MacDataFrame frame = dataframe_create(dev->bytes_rec);
memcpy(frame->data, dev->buffer, dev->bytes_rec);

// Packet inspection: determine if this is TCP traffic
dl1com marked this conversation as resolved.
Show resolved Hide resolved
// then activate ARQ
uint16_t ether_type = (frame->data[12] << 8) + frame->data[13];
struct iphdr *ip4hdr = (struct iphdr *)&frame->data[14];
frame->do_arq = 0; // no ARQ by default
LOG(DEBUG, "[TAP] Packet inspect: ethertype %04x, proto %d\n", ether_type,
ip4hdr->protocol);
if (ether_type == ETHERTYPE_IP) {
// is IPv4 packet, check if TCP
if (ip4hdr->protocol == 6) {
frame->do_arq = 1;
}
}
// find correct userid to forward EtherFrame to
// if no entry is found, broadcast channel is used
struct entry *np = NULL;
Expand Down
1 change: 1 addition & 0 deletions src/mac/mac_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ MacDataFrame dataframe_create(uint size) {
MacDataFrame frame = malloc(sizeof(MacDataFrame_s));
frame->data = malloc(size);
frame->size = size;
frame->do_arq = 0; // do not use ARQ mode by default
return frame;
}

Expand Down
1 change: 1 addition & 0 deletions src/mac/mac_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
typedef struct {
uint size;
uint8_t *data;
uint do_arq;
} MacDataFrame_s;

// Store some MAC layer statistics
Expand Down
Loading