Skip to content

Commit

Permalink
depricate --enable-file-cache option for appneta#16 and appneta#17
Browse files Browse the repository at this point in the history
  • Loading branch information
fklassen committed Dec 8, 2013
1 parent 893d187 commit 9cba129
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 36 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$Id$

??/??/2013 Version 3.5.0
- Deprecated file-cache option - use preload-pcap instead (appneta #17)
- Removed obsolete sleep-mode and sleep-accel options (appneta #16)
- Remove unreliable RDTSC option (appneta #16)
- Implement pseudo-CRC to improve tcpedit performance (appneta #8)
Expand Down
2 changes: 1 addition & 1 deletion src/common/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ git_version.c:
libcommon_a_SOURCES = cidr.c err.c list.c cache.c services.c get.c \
fakepcap.c fakepcapnav.c fakepoll.c xX.c utils.c \
timer.c git_version.c abort.c sendpacket.c \
dlt_names.c mac.c interface.c
dlt_names.c mac.c interface.c git_version.c

if ENABLE_TCPDUMP
libcommon_a_SOURCES += tcpdump.c
Expand Down
10 changes: 5 additions & 5 deletions src/send_packets.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ send_packets(pcap_t *pcap, int cache_file_idx)
(void)signal(SIGINT, break_now);
}

if (options.enable_file_cache) {
if (options.preload_pcap) {
prev_packet = &cached_packet;
} else {
prev_packet = NULL;
Expand Down Expand Up @@ -362,7 +362,7 @@ send_packets(pcap_t *pcap, int cache_file_idx)
#if defined TCPREPLAY && !defined TCPREPLAY_EDIT
++iteration;
#endif
if (options.enable_file_cache) {
if (options.preload_pcap) {
options.file_cache[cache_file_idx].cached = TRUE;
}
}
Expand Down Expand Up @@ -405,7 +405,7 @@ send_dual_packets(pcap_t *pcap1, int cache_file_idx1, pcap_t *pcap2, int cache_f
(void)signal(SIGINT, break_now);
}

if (options.enable_file_cache) {
if (options.preload_pcap) {
prev_packet1 = &cached_packet1;
prev_packet2 = &cached_packet2;
} else {
Expand Down Expand Up @@ -591,7 +591,7 @@ send_dual_packets(pcap_t *pcap1, int cache_file_idx1, pcap_t *pcap2, int cache_f
#endif
} /* while */

if (options.enable_file_cache) {
if (options.preload_pcap) {
options.file_cache[cache_file_idx1].cached = TRUE;
options.file_cache[cache_file_idx2].cached = TRUE;
}
Expand Down Expand Up @@ -621,7 +621,7 @@ get_next_packet(pcap_t *pcap, struct pcap_pkthdr *pkthdr, int file_idx,
/*
* Check if we're caching files
*/
if ((options.enable_file_cache || options.preload_pcap) && (prev_packet != NULL)) {
if (options.preload_pcap && (prev_packet != NULL)) {
/*
* Yes we are caching files - has this one been cached?
*/
Expand Down
19 changes: 5 additions & 14 deletions src/tcpreplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,14 +103,14 @@ main(int argc, char *argv[])
}
#endif

if ((options.enable_file_cache || options.preload_pcap) && ! HAVE_OPT(QUIET)) {
if (options.preload_pcap && ! HAVE_OPT(QUIET)) {
notice("File Cache is enabled");
}

/*
* Setup up the file cache, if required
*/
if (options.enable_file_cache || options.preload_pcap) {
if (options.preload_pcap) {
options.file_cache = safe_malloc(argc * sizeof(file_cache_t));

/*
Expand Down Expand Up @@ -256,7 +256,7 @@ replay_file(int file_idx)
warnx("unable to close stdin: %s", strerror(errno));

/* read from pcap file if we haven't cached things yet */
if (! (options.enable_file_cache || options.preload_pcap)) {
if (!options.preload_pcap) {
if ((pcap = pcap_open_offline(path, ebuf)) == NULL)
errx(-1, "Error opening pcap file: %s", ebuf);
} else {
Expand Down Expand Up @@ -321,7 +321,7 @@ replay_two_files(int file_idx1, int file_idx2)
err(-1, "Sorry, can't read STDIN in --dualfile mode");

/* read from first pcap file if we haven't cached things yet */
if (! (options.enable_file_cache || options.preload_pcap)) {
if (!options.preload_pcap) {
if ((pcap1 = pcap_open_offline(path1, ebuf)) == NULL)
errx(-1, "Error opening pcap file: %s", ebuf);
} else {
Expand All @@ -331,7 +331,7 @@ replay_two_files(int file_idx1, int file_idx2)
}

/* read from second pcap file if we haven't cached things yet */
if (! (options.enable_file_cache || options.preload_pcap)) {
if (!options.preload_pcap) {
if ((pcap2 = pcap_open_offline(path2, ebuf)) == NULL)
errx(-1, "Error opening pcap file: %s", ebuf);
} else {
Expand Down Expand Up @@ -496,17 +496,8 @@ post_args(int argc)

#endif

/*
* Check if the file cache should be enabled - if we're looping more than
* once and the command line option has been spec'd
*/
if (HAVE_OPT(ENABLE_FILE_CACHE) && (options.loop != 1)) {
options.enable_file_cache = TRUE;
}

if (HAVE_OPT(PRELOAD_PCAP)) {
options.preload_pcap = TRUE;
options.enable_file_cache = TRUE;
}

if (HAVE_OPT(DUALFILE)) {
Expand Down
3 changes: 1 addition & 2 deletions src/tcpreplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ struct tcpreplay_opt_s {
tcpdump_t *tcpdump;
#endif

/* pcap file caching */
int enable_file_cache;
/* cache pcap file before running */
file_cache_t *file_cache;
int preload_pcap;

Expand Down
14 changes: 0 additions & 14 deletions src/tcpreplay_opts.def
Original file line number Diff line number Diff line change
Expand Up @@ -208,20 +208,6 @@ options.
EOText;
};

/* Cache files to internal memory */
flag = {
name = enable_file_cache;
value = K;
flags-must = loop;
descrip = "Enable caching of packets to internal memory";
doc = <<- EOText
Cache pcap file(s) the first time they are cached in RAM so that subsequent
loops do not incurr any disk I/O latency in order to increase performance. Make
sure you have enough free RAM to store the entire pcap file(s) in memory or the
system will swap and performance will suffer.
EOText;
};

flag = {
name = preload_pcap;
descrip = "Preloads packets into RAM before sending";
Expand Down

0 comments on commit 9cba129

Please sign in to comment.