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

Add --skip-pkts and --skip-to-secs to allow skipping packets when replaying #478

Merged
merged 1 commit into from
Jun 1, 2024

Conversation

Exchizz
Copy link

@Exchizz Exchizz commented Jul 4, 2018

Standards checklist:

  • The PR title is descriptive.
  • The PR doesn't replicate another PR which is already open.
  • I have read the contribution guide and followed all the instructions.
  • The code follows the code style guide detailed in the wiki.
  • The code is mine or it's from somewhere with an MIT-compatible license.
  • The code is efficient, to the best of my ability, and does not waste computer resources.
  • The code is stable and I have tested it myself, to the best of my abilities.
  • If the code introduces new aliases, I provide a valid use case for all plugin users down below.

Changes:

  • Add --skip-pkts x as parameter to tcpreplay. It adds support for skipping the first X packets in a pcap file
  • Add --skip-to-secs Y as parameter to tcpreplay. It adds support for skipping until Y seconds into the pcap file. The seconds is absolute since since the unix epoch

Other comments:

We needed this in a project where we used a series of pcap files for storing sound and video recordings. If a user wanted to start a replay from a certain date and time we would know which pcap file to replay (based on the filename of the pcap file) and by using --skip-to-seconds we could jump to the date and time in the pcap file.

@fklassen fklassen self-assigned this Jul 4, 2018
Copy link
Member

@fklassen fklassen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple changes required before I could accept this.

Also reviewing the use case for this. Why is this needed?

@@ -519,13 +519,28 @@ send_packets(tcpreplay_t *ctx, pcap_t *pcap, int idx)
now_is_now = false;
}

/* SKIP PACKETS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change must be also implemented in send_dual_packets()

/* MAIN LOOP
* Keep sending while we have packets or until
* we've sent enough packets
*/
while (!ctx->abort &&
(pktdata = get_next_packet(ctx, pcap, &pkthdr, idx, prev_packet)) != NULL) {

/* Skip packets */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also must be copied to This change must be also implemented in send_dual_packets()`

@Exchizz
Copy link
Author

Exchizz commented Nov 2, 2018

We are using tcpreplay to replay video streams. We save video streams in chunks of 1 min. By being able to skip into pcap files we can easily jump back and forth in our recordings :)

Do you want me to make a new pull request with the changes added to send_dial_packets()? (I'm not very experienced with github)

@fklassen
Copy link
Member

We are using tcpreplay to replay video streams. We save video streams in chunks of 1 min. By being able to skip into pcap files we can easily jump back and forth in our recordings :)

Do you want me to make a new pull request with the changes added to send_dial_packets()? (I'm not very experienced with github)

Sorry for the delay. Just commit changes directly into this branch and push up.

I'll try to get this into 4.4.0 if I see changes in the next few days. I plan a release by the end of January.

@Exchizz
Copy link
Author

Exchizz commented Jan 15, 2024

Sorry for the late reply. Would you still like to merge this PR if I rebase and verify it still works ?

@fklassen
Copy link
Member

I would not guarantee that I can get it in to 4.5, but a rebase and test cases would help. Please rebase and target from this branch I created for you https://github.com/appneta/tcpreplay/tree/PR_478_skip_feature_rebase_4.5.0.

Also, new PRs will contain this checklist. Please apply it to the PR. https://github.com/appneta/tcpreplay/blob/PR_478_skip_feature_rebase_4.5.0/.github/PULL_REQUEST_TEMPLATE.md

@Exchizz Exchizz changed the title --skip-pkts,--skip-to-secs and --skip-to-usecs allow skipping packets Add --skip-pkts and --skip-to-secs to allow skipping packets when replying Jan 15, 2024
@Exchizz Exchizz changed the base branch from master to PR_478_skip_feature_rebase_4.5.0 January 15, 2024 22:12
@Exchizz Exchizz force-pushed the master branch 2 times, most recently from f26d87b to c79e648 Compare January 15, 2024 22:16
@Exchizz
Copy link
Author

Exchizz commented Jan 15, 2024

Let me know what you think :)

@Exchizz Exchizz changed the title Add --skip-pkts and --skip-to-secs to allow skipping packets when replying Add --skip-pkts and --skip-to-secs to allow skipping packets when replaying Jan 16, 2024
@fklassen fklassen merged commit 309e6f3 into appneta:PR_478_skip_feature_rebase_4.5.0 Jun 1, 2024
@fklassen
Copy link
Member

fklassen commented Jun 1, 2024

Did some testing in staging branch and decided to push to next release. This introduces new bugs:

  1. doesn't work when 2 interfaces are being replayed
  2. will skip into all supplied PCAP files

Most likely the skip logic has to happen in the calling functions. Also, documentation needs improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants