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

Question for implementing rx_avg_delay_us in bbl_stream.c #263

Open
slieberth opened this issue Jun 9, 2024 · 0 comments
Open

Question for implementing rx_avg_delay_us in bbl_stream.c #263

slieberth opened this issue Jun 9, 2024 · 0 comments
Assignees
Labels
enhancement New feature or request low Low priority

Comments

@slieberth
Copy link
Contributor

slieberth commented Jun 9, 2024

Hello Christian,

thanks for providing bngblaster!

It would be beneficial for us, if we can measure the average latency (= rx_avg_delay_us) in our tests.
It is important for us to know the weight of rx_max_delay_us. e.g. is it just one packet or the majority of packets.

I see two options for implementing this feature:

calculation the sum over all delay_us values and divide the sum by the number of incoming packets.
The drawback of this approach is that this test cannot run infinitely. (max value of 1e308 for double). python code example:

import random

min_delay_us = 0.0
max_delay_us = 0.0
sum_for_avg_delay_us = 0.0
avg_delay_us = 0.0

for rx_packets in range(1,1000, 1):
    delay_us = random.random()
    if rx_packets == 1:
        min_delay_us = delay_us
        max_delay_us = delay_us
    else:
        if delay_us < min_delay_us:
            min_delay_us = delay_us
        if delay_us > max_delay_us:
            max_delay_us = delay_us
    sum_for_avg_delay_us += delay_us

avg_delay_us = sum_for_avg_delay_us / rx_packets

print (f"min:{min_delay_us} avg:{avg_delay_us} max:{max_delay_us}")

respectively a calculation on a per packet base, which is more resource intensive, but avoids any considerations for exceeding the max value for doubles in c.

import random

min_delay_us = 0.0
max_delay_us = 0.0
avg_delay_us = 0.0

for rx_packets in range(1,1000, 1):
    delay_us = random.random()
    if rx_packets == 1:
        min_delay_us = delay_us
        max_delay_us = delay_us
        avg_delay_us = delay_us
    else:
        if delay_us < min_delay_us:
            min_delay_us = delay_us
        if delay_us > max_delay_us:
            max_delay_us = delay_us
        avg_delay_us = ((avg_delay_us * (rx_packets - 1)) + delay_us) / rx_packets

print (f"min:{min_delay_us} avg:{avg_delay_us} max:{max_delay_us}")

It has to be done on each incoming packet.

Please let me know, what you think?
If you wish, I can try to implement a solution and provide a pull/merge request to you.

best regards Stefan

@slieberth slieberth added the enhancement New feature or request label Jun 9, 2024
@GIC-de GIC-de added the low Low priority label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request low Low priority
Projects
None yet
Development

No branches or pull requests

2 participants