summaryrefslogtreecommitdiff
path: root/src/tcpreplay.c
diff options
context:
space:
mode:
author杨威 <[email protected]>2020-08-05 11:53:56 +0800
committer杨威 <[email protected]>2020-08-05 11:53:56 +0800
commit9fa3c0ae5bcdc5297a130843cff21c0926642819 (patch)
tree4d012c8072f6a4061315c780c31092a515ed850d /src/tcpreplay.c
parent95f324d4deec6e27af2194d27e2c5985d55fc6b0 (diff)
调整回放包逻辑,仅当使用marsio编译且使用marsio模式回放流量时,启用marsio_threadHEADmaster
Diffstat (limited to 'src/tcpreplay.c')
-rw-r--r--src/tcpreplay.c81
1 files changed, 37 insertions, 44 deletions
diff --git a/src/tcpreplay.c b/src/tcpreplay.c
index 000e631..c4e1c0e 100644
--- a/src/tcpreplay.c
+++ b/src/tcpreplay.c
@@ -1639,7 +1639,7 @@ static void *replay_files_thread(void *arg)
marsio_thread_init(tcpburst_marsio4_instance);
if(0 == loop){
- loop = 1; /* 至少一次 */
+ while(1)replay_file(0);
}
for(i = 0; i < loop; i++){
replay_file(0);
@@ -1748,50 +1748,43 @@ main(int argc, char *argv[])
if (gettimeofday(&begin, NULL) < 0)
errx(-1, "gettimeofday() failed: %s", strerror(errno));
- /* main loop for non-bridge mode */
- if (options.loop > 0) {
- while (options.loop--) { /* limited loop */
- /* process each pcap file in order */
- for (i = 0; i < argc; i++) {
- /* reset cache markers for each iteration */
- cache_byte = 0;
- cache_bit = 0;
-#ifdef MARSIO
- if(12 == send_pkt_driver_mode){
- pthread_t pid;
- pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop);
- pthread_join(pid, NULL);
- }else{
- replay_file(i);
- }
-#else
- replay_file(i);
-#endif
- }
- }
- }
- else {
- /* loop forever */
- while (1) {
- for (i = 0; i < argc; i++) {
- /* reset cache markers for each iteration */
- cache_byte = 0;
- cache_bit = 0;
-#ifdef MARSIO
- if(12 == send_pkt_driver_mode){
- pthread_t pid;
- pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop);
- pthread_join(pid, NULL);
- }else{
- replay_file(i);
- }
-#else
- replay_file(i);
-#endif
- }
- }
- }
+ if (12 == send_pkt_driver_mode)
+ {
+#ifdef MARSIO
+ pthread_t pid;
+ pthread_create(&pid, NULL, replay_files_thread, (void *)options.loop);
+ pthread_join(pid, NULL);
+#else
+ errx(-1, "send_pkt_driver_mode == %s, but tcp_burst did not compiled with %s", "MARSIO", "MARSIO");
+#endif
+ }
+ else
+ {
+ /* main loop for non-bridge mode */
+ if (options.loop > 0) {
+ while (options.loop--) { /* limited loop */
+ /* process each pcap file in order */
+ for (i = 0; i < argc; i++) {
+ /* reset cache markers for each iteration */
+ cache_byte = 0;
+ cache_bit = 0;
+ replay_file(i);
+ }
+ }
+ }
+ else {
+ /* loop forever */
+ while (1) {
+ for (i = 0; i < argc; i++) {
+ /* reset cache markers for each iteration */
+ cache_byte = 0;
+ cache_bit = 0;
+ replay_file(i);
+ }
+ }
+ }
+ }
if (bytes_sent > 0) {
if (gettimeofday(&end, NULL) < 0)
errx(-1, "Unable to gettimeofday(): %s", strerror(errno));