RTT and PLR(Packet Loss Ratio)

Hello :slight_smile:
i did a conversation chat room with both transceivers being receivers and transmitters at the same time.
The problem is that i don't know how to calculate RTT and PLR in my code :c

Note: Can't use ACKS

can someone plz help me? :slight_smile:

Thank you!

Margarida

#include <printf.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24_config.h>

#define _cepin 7
#define _cspin 8
RF24 radio(_cepin, _cspin);

const uint64_t pipes[2] = { 0xF0F0F0F0E1LL, 0xF0F0F0F0D2LL };
bool tx_mode = false;
char input[32] = "";

void setup() {
Serial.begin(57600);
Serial.println("\t\t------------------------------------");
Serial.println("\t\t| Chat Room: |");
Serial.println("\t\t------------------------------------");
printf_begin();
radio.begin();
radio.setChannel(16);
radio.setDataRate(RF24_2MBPS);
radio.openWritingPipe(pipes[1]);
radio.openReadingPipe(1, pipes[0]);
disableCRC();
radio.startListening();
}

void loop() {

if (Serial.available()) {
int len = Serial.readBytesUntil('\n', input, 31);
input[len] = '\0';
tx_mode = true;
}

if (tx_mode){
radio.stopListening();

bool ok = radio.write(input, 32);
if (ok){
printf("André : %s\n", input);
tx_mode = false;
delay(500);
radio.startListening();
}
else
printf("Erro! Veja se o recetor está corretamente ligado ou a distância é demasiado comprida\n");
}

if (radio.available()){
char carga[32] = "";
bool done = false;
while (!done) {
done = radio.read( carga , 32 );
printf("Ana: %s\n", carga);
}
}
}

Round Trip Time
Packet Loss Ratio

I'm not sure that the library you are using makes that all visible to you because the handling of re-trys etc. is done at a low level.
Have a look at the product specification: nRF24 Series - Nordic Semiconductor - nordicsemi.com
May be you can get something by sending a block of data, setting a timer, and waiting for the acknowlegement.

The librarie that i'm using is this one: :slight_smile:

RF24-master.zip (203 KB)

OK. I see that this is school work from your other posts.
But, anyway I don't believe that your get information about the automatic packet loss / re-transmit handling.

However, you can do something like this:
Continually transmit packets which include a serial number which you increment by one each time.
On the receiver side, simply look for gaps. That is where the serial number of the packet just received is more than one increment higher than in the previous packet received. From that, work out the proportion of missing packets.

Could you give me an example plz :slight_smile:

if you don't mind of course :stuck_out_tongue:

Maybe this gets you started with the measurement of lost packets:

// transmitter code fragment - lost packets :

const unsigned long intervalMs = 10 ;  
unsigned long lastTrasmitAtMs = 0 ;
unsigned long serialNumber = 1 ;


loop() {
  // sends 6000 packets @ 10 mS intervals. Duration = approx 1 minute
  if ( serialNumber < 6000 && millis() - lastTrasmitAtMs > interval ) {
     lastTrasmitAtMs += intervalMs ;
     radio.write( &serialNumber, sizeof( serialNumber ) ); 
     serialNumber++; 
  }
}




// receiver code - lost packets

unsigned long serialNumber ;
unsigned long serialNumberPrevious = 0  ;
unsigned long missingPackets ; 

loop() {
     radio.read( &serialNumber, sizeof( serialNumber ) ); 
     missingPackets = serialNumber - serialNumberPrevious - 1 ;
     // prints a message when a loss of a packet or group of packets is discovered.
     if ( missingPackets > 0 ) {
       Serial.print ( "lost packets= " ) ; 
       Serial.print ( missingPackets ) ;
     }
     serialNumberPrevious = serialNumber ;
  }
}

Thank you :slight_smile:

But I have the transmitter and receiver code in the same code ahahha

My problem with RTT is that i can't use ACKS and i'm only sending messages.

If the RTT is the time required for a signal pulse or packet to travel from a specific source to a specific destination and back again.

how do I do that using my code, if i can't use ACKS? :c

I searched a lot and I rellay don't have any clue

can someone plz help me? :c

Someone plz close this topic

I know basically nothing about arduino because i just started learning it by myself.
My teachers don't help me either. They say that i have to search on internet for information that I don't find.

Yet I have to do a Chat room and on top of that i have to get RTT and PLR.

I thought this forum would help me to find an answear for my questions. But this is a complete waist of time.

I really wanted to learn more about arduino with all of you, but you choose to ignore me

Anyway, thanks a lot

I thought this forum would help me to find an [answer] for my questions. But this is a complete [waste] of time.

I really wanted to learn more about arduino with all of you, but you choose to ignore me.

Well that all sounds a bit like a dramatic outburst of frustration, but anyway:

If you cant use 'ack' to measure the round trip delivery time, then you have to devise your own method of achieving the same thing.
You have to send a message from A to B. A sets a timer when it sends the message. B accepts the message and sends a response back to A. A records the time it receives the response back from B. The difference between these two times, that is the time of the sending of the original message and the time of receiving the response back, is the round trip delivery time.

This is not a trivial exercise, but it is also not extremely difficult. Do you have to show a complete working solution or only show the outline of a solution ?

I'm sorry :c

I know that I sounded very rude

The problem is that I don't have the necessary bases to do this. For me it's hard

I just started learning Arduino

Once again, you're right

I'm really sorry

And i have to show a complete working solution with RTT and PLR

One thing is clear. This is not a project for a complete beginner with Arduino. You started off using terms like RTT so I guess your course has an element of communications in it and is not at a basic level.

Anyway, you asked (PM) about the "serialNumber" in post #5. This is simply a number which starts at 0 the first time it used. It is incremented by one each time it is used. The idea is that the receiver notices if packets are dropped. For example, if the last packet received has a serial number 57 and the next received has a serial number of 60, the receiver 'knows' that 2 packets, that is packets 58 and 59 have been dropped.

A slightly easier way of doing this has occurred to me:
The transmitter part continually sends packets at say every 10 mS. The content is irrelevant.
The receiver part, on receiving a packet, sets a timer say lastPacketReceivedAtMs = millis() ;
The value of the formula: millis() - lastPacketReceivedAtMs is continually checked and if it is greater that the 10 mS transmission interval, that indicates a lost packet. The number of missing packets can be determined by dividing the previous formula by 10.

Thanks a lot Mr 6v6gt :slight_smile:

Without you I couldn't do my project!