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

SrsKbps interface error, behavior does not comply with the specification of ISrsProtocolStatistic. #588

Closed
winlinvip opened this issue Apr 10, 2016 · 2 comments
Assignees
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@winlinvip
Copy link
Member

winlinvip commented Apr 10, 2016

ISrsProtocolStatistic interface provides the number of bytes transferred at the class protocol layer, including the number of bytes received and sent.
Its implicit meaning is that each time this interface is called, it returns the number of bytes already transferred.

SrsKbps class mainly provides the byte difference over a certain period of time, as well as the rate (Kbps).
This class can also provide the historical number of bytes, including the total number of bytes after switching to the underlying IO.
In other words:

kbps->set(io0, io0)
kbps->set(io1, io1)

This SrsKbps class is used to track historical data, allowing for the aggregation of data from multiple IOs. For example, it can be used to calculate the total byte data for a client connecting to different servers.
Based on this consideration, SrsKbps inherits from ISrsProtocolStatistic to provide byte statistics.

However, there is a special requirement for the functions in ISrsKbps. They must be called after invoking the sample() function because the sample() function needs to be called to update the data for Kbps and refresh its cache.

public:
    /**
    * get the total send/recv bytes, from the startup of the oldest io.
    * @remark, use sample() to update data.
    */
    virtual int64_t get_cur_send_bytes();
    virtual int64_t get_cur_recv_bytes();

Therefore, the behavior of SrsKbps is different from what is defined in the interface.
This can result in outdated data if the functions in the interface are called without first sampling.
In simpler terms, it means that the bandwidth calculation may be underestimated. If the interface is called in two different places, such as for billing logs and access logs, there may be a difference of one sampling period.

TRANS_BY_GPT3

@winlinvip winlinvip added the Bug It might be a bug. label Apr 10, 2016
@winlinvip winlinvip added this to the srs 2.0 release milestone Apr 10, 2016
@winlinvip
Copy link
Member Author

winlinvip commented Apr 10, 2016

Can make Kbps comply with this interface specification and eliminate deviation.

TRANS_BY_GPT3

@winlinvip
Copy link
Member Author

winlinvip commented Apr 10, 2016

Must be able to directly support proxy mode:

 * 4. kbps used as ISrsProtocolStatistic, to provides raw bytes:
 *      SrsKbps* kbps = ...;
 *      SrsKbps* user = ...;
 *      user->set_io(kbps, kbps);

Because SrsKbps itself has implemented this interface.

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Sep 24, 2021
@winlinvip winlinvip changed the title SrsKbps的接口错误,行为不符合ISrsProtocolStatistic的规范 SrsKbps interface error, behavior does not comply with the specification of ISrsProtocolStatistic. Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

1 participant