diff --git a/latencyTesting/startTxAndRxOnMyPc.sh b/latencyTesting/startTxAndRxOnMyPc.sh index a48d9d2b..dd760d29 100755 --- a/latencyTesting/startTxAndRxOnMyPc.sh +++ b/latencyTesting/startTxAndRxOnMyPc.sh @@ -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 diff --git a/src/rx.cpp b/src/rx.cpp index 728f3f6f..f4def227 100644 --- a/src/rx.cpp +++ b/src/rx.cpp @@ -386,7 +386,7 @@ radio_loop(std::shared_ptr agg,const std::vector rxInte for (;;) { auto cur_ts=std::chrono::steady_clock::now(); //const int timeoutMS=log_send_ts > cur_ts ? (int)std::chrono::duration_cast(log_send_ts - cur_ts).count() : 0; - const int timeoutMS=std::chrono::duration_cast(flush_interval).count(); + const int timeoutMS=flush_interval.count()>0 ? std::chrono::duration_cast(flush_interval).count() : std::chrono::duration_cast(log_interval).count(); int rc = poll(fds, N_RECEIVERS,timeoutMS); if (rc < 0) { @@ -403,7 +403,9 @@ radio_loop(std::shared_ptr agg,const std::vector rxInte if (rc == 0){ // timeout expired - agg->flushRxRing(); + if(flush_interval.count()>0){ + agg->flushRxRing(); + } continue; } @@ -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"; diff --git a/src/tx.cpp b/src/tx.cpp index 3f4433c7..3ed5ba42 100644 --- a/src/tx.cpp +++ b/src/tx.cpp @@ -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()); } @@ -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){ @@ -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}; diff --git a/src/tx.hpp b/src/tx.hpp index 33111095..2e6c2ae1 100644 --- a/src/tx.hpp +++ b/src/tx.hpp @@ -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: