Skip to content
This repository has been archived by the owner on Jul 15, 2022. It is now read-only.

Commit

Permalink
default to flush interval of -1 (which means behaviour is exactly as …
Browse files Browse the repository at this point in the history
…it was without a flush interval before)
  • Loading branch information
Consti10 committed Dec 19, 2020
1 parent f01d431 commit 737a965
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
4 changes: 2 additions & 2 deletions latencyTesting/startTxAndRxOnMyPc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ sudo iwconfig $MY_RX channel 6


# $WFB_FOLDER/wfb_tx -k $FEC_K -n $FEC_N -u 6000 -p 60 -M 7 -K $WFB_FOLDER/drone.key $MY_TX
xterm -hold -e $WFB_FOLDER/wfb_tx -k $FEC_K -n $FEC_N -u 6000 -p 60 -M 4 -B 40 -K $WFB_FOLDER/drone.key -f 5 $MY_TX &
xterm -hold -e $WFB_FOLDER/wfb_tx -k $FEC_K -n $FEC_N -u 6000 -p 60 -M 4 -B 40 -K $WFB_FOLDER/drone.key $MY_TX &

$WFB_FOLDER/wfb_rx -k $FEC_K -n $FEC_N -c 127.0.0.1 -u 6100 -p 60 -K $WFB_FOLDER/gs.key -f 10 $MY_RX
$WFB_FOLDER/wfb_rx -k $FEC_K -n $FEC_N -c 127.0.0.1 -u 6100 -p 60 -K $WFB_FOLDER/gs.key $MY_RX

#other usefull commands:
#sudo iw dev
Expand Down
8 changes: 5 additions & 3 deletions src/rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ radio_loop(std::shared_ptr<Aggregator> agg,const std::vector<std::string> rxInte
for (;;) {
auto cur_ts=std::chrono::steady_clock::now();
//const int timeoutMS=log_send_ts > cur_ts ? (int)std::chrono::duration_cast<std::chrono::milliseconds>(log_send_ts - cur_ts).count() : 0;
const int timeoutMS=std::chrono::duration_cast<std::chrono::milliseconds>(flush_interval).count();
const int timeoutMS=flush_interval.count()>0 ? std::chrono::duration_cast<std::chrono::milliseconds>(flush_interval).count() : std::chrono::duration_cast<std::chrono::milliseconds>(log_interval).count();
int rc = poll(fds, N_RECEIVERS,timeoutMS);

if (rc < 0) {
Expand All @@ -403,7 +403,9 @@ radio_loop(std::shared_ptr<Aggregator> agg,const std::vector<std::string> rxInte

if (rc == 0){
// timeout expired
agg->flushRxRing();
if(flush_interval.count()>0){
agg->flushRxRing();
}
continue;
}

Expand All @@ -424,7 +426,7 @@ int main(int argc, char *const *argv) {
int opt;
uint8_t k = 8, n = 12, radio_port = 1;
std::chrono::milliseconds log_interval{1000};
std::chrono::milliseconds flush_interval{40};
std::chrono::milliseconds flush_interval{-1};
int client_udp_port = 5600;
std::string client_addr = "127.0.0.1";
std::string keypair = "gs.key";
Expand Down
13 changes: 10 additions & 3 deletions src/tx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@ WBTransmitter::WBTransmitter(RadiotapHeader radiotapHeader, int k, int n, const
}
mEncryptor.makeSessionKey();
outputDataCallback=std::bind(&WBTransmitter::sendFecBlock, this, std::placeholders::_1);
mInputSocket=SocketHelper::openUdpSocketForRx(udp_port,flushInterval);
if(FLUSH_INTERVAL.count()<0){
mInputSocket=SocketHelper::openUdpSocketForRx(udp_port,LOG_INTERVAL);
}else{
mInputSocket=SocketHelper::openUdpSocketForRx(udp_port,FLUSH_INTERVAL);
}
fprintf(stderr, "WB-TX Listen on UDP Port %d assigned ID %d assigned WLAN %s FLUSH_INTERVAL(ms) %d\n", udp_port,radio_port,wlan.c_str(),(int)flushInterval.count());
}

Expand Down Expand Up @@ -141,7 +145,9 @@ void WBTransmitter::loop() {
}else{
if(errno==EAGAIN || errno==EWOULDBLOCK){
// timeout
finishCurrentBlock();
if(FLUSH_INTERVAL.count()>0){
finishCurrentBlock();
}
continue;
}
if (errno == EINTR){
Expand All @@ -158,7 +164,8 @@ int main(int argc, char *const *argv) {
int opt;
uint8_t k = 8, n = 12, radio_port = 1;
int udp_port = 5600;
std::chrono::milliseconds flushInterval=std::chrono::milliseconds(40);
// use -1 for no flush interval
std::chrono::milliseconds flushInterval=std::chrono::milliseconds(-1);

RadiotapHeader::UserSelectableParams params{20, false, 0, false, 1};

Expand Down
1 change: 1 addition & 0 deletions src/tx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class WBTransmitter: public FECEncoder{
int64_t nInjectedPackets=0;
const std::chrono::steady_clock::time_point INIT_TIME=std::chrono::steady_clock::now();
static constexpr const std::chrono::nanoseconds LOG_INTERVAL=std::chrono::milliseconds(1000);
// use -1 for no flush interval
const std::chrono::milliseconds FLUSH_INTERVAL;
Chronometer pcapInjectionTime{"PcapInjectionTime"};
public:
Expand Down

0 comments on commit 737a965

Please sign in to comment.