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

How to use replayUnqueue or MultiReplayUnqueue to limit the tx rate? #367

Closed
Emikoer opened this issue Oct 4, 2022 · 3 comments
Closed

Comments

@Emikoer
Copy link

Emikoer commented Oct 4, 2022

I use the example under conf/pktgen/pktgen-l2.click to generate packets, but I don't know how to use replayUnqueue or MultiReplayUnqueue to limit the tx rate.
FastUDPSouce(RATE 0,LIMIT $N, LENGTH $L, SRCETH $mymac,SRCIP $myip,SPORT 8000, DSTETH $dmac, DSTIP $dstip, DPORT 8000)
-> MarkMACHeader
-> EnsureDPDKBuffer
-> replay :: MultiReplayUnqueue(STOP -1, ACTIVE false, QUICK_CLONE 1)
-> ic0 :: AverageCounter()
-> td :: ToDPDKDevice(0000:04:00.1, BLOCKING $blocking, VERBOSE $verbose)

@tbarbette
Copy link
Owner

tbarbette commented Oct 4, 2022

ReplayUnqueue can only act on the original timing of the packets. It was built to use with a real packet trace, read using FromPcap.

The easiest solution is to create a trace that has the timing you want, and then you set TIMING 100 in the ReplayUnqueue. Timing is an acceleration percentage exprimed in percent.

FastUDPSouce does not create timestamps so it cannot be used with ReplayUnqueue.

If you're not looking for very high speeds, you might use RatedUnqueue() or BandwidthRatedUnqueue instead of ReplayUnqueue ?

Another alternative is to set a fake timestamp in FastUDPSouce :

  • Create a class variable Timestamp _ts;
  • Initialize _ts to whatever (_ts = Timestamp::now();) in initiliaze() or configure()
  • After all p = packet->clone() you add p->set_timestamp_anno(ts); _ts = _ts + Timestamp::make_msec(1);
  • you 'll have 1000 packets per seconds.
  • Better, use a new FAKE_RATE argument to compute the amount of PPS per seconds. And even better, submit a PR :)

Note:
MultiReplay is to replay packets to multiple ports at the same time (like a TX side and an RX side towards a router, and replay two pcaps with the correct timings). In general it is accepted in system research to replay a mix at once.

@tbarbette
Copy link
Owner

Another way to go would be to modify ReplayUnqueue to use some kind of fake rate instead of the packet timestamp, around

while ((diff = (p->timestamp_anno() - _timing_packet).nsecval()) - (rdiff = (((int64_t)(now - _timing_real).nsecval() * (int64_t)_timing) / 100)) > min_timing_ns) {

@Emikoer
Copy link
Author

Emikoer commented Oct 5, 2022

Thanks for your answer! I tried to use BandwidthRatedUnqueue and it succeed.

@Emikoer Emikoer closed this as completed Oct 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants