Skip to content

Commit 54ab894

Browse files
authored
Merge pull request appneta#283 from appneta/Release_4.2.0beta1
Release 4.2.0 beta1
2 parents 7f7eb95 + 2646d69 commit 54ab894

File tree

15 files changed

+133
-43
lines changed

15 files changed

+133
-43
lines changed

.travis.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,8 @@ addons:
77
packages:
88
- libpcap-dev
99

10-
cache:
11-
apt: true
12-
1310
matrix:
1411
include:
15-
- os: osx
16-
osx_image: xcode6.4
17-
compiler: gcc
18-
before_install:
19-
- brew update
20-
- brew install autogen homebrew/dupes/libpcap
2112
- os: osx
2213
osx_image: xcode8.2
2314
compiler: clang

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
dnl $Id$
33

44
AC_PREREQ([2.69])
5-
AC_INIT([tcpreplay],[4.1.2],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])
5+
AC_INIT([tcpreplay],[4.2.0],[https://github.com/appneta/tcpreplay/issues],[tcpreplay],[http://tcpreplay.sourceforge.net/])
66
AC_CONFIG_SRCDIR([src/tcpreplay.c])
77
AM_CONFIG_HEADER([src/config.h])
88
AC_CONFIG_AUX_DIR(config)
@@ -17,8 +17,8 @@ AC_CONFIG_MACRO_DIR([m4])
1717

1818
dnl Set version info here!
1919
MAJOR_VERSION=4
20-
MINOR_VERSION=1
21-
MICRO_VERSION=2
20+
MINOR_VERSION=2
21+
MICRO_VERSION=0-beta1
2222
TCPREPLAY_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION
2323
PACKAGE_URL=http://tcpreplay.appneta.com/
2424

docs/CHANGELOG

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
02/26/2017 Version 4.2.0beta1
2+
- Netmap startup delay increase (#209)
3+
- tcpcapinfo buffer overflow vulnerablily (#278)
4+
- Update git-clone instructions by Kyle McDonald (#277)
5+
- Allow fractions for --pps option (#270)
6+
- Print per-loop stats with --stats=0 (#269)
7+
- Add protection against packet drift by Guillaume Scott (#268)
8+
- Include Travis-CI build support by Ilya Shipitsin (#264) (#285)
9+
- Netmap shutdown delay implemention (#255)
10+
- First and last packet times in --stats output (#239)
11+
- tcprewrite fix checksum properly for fragmented packets (#190)
12+
113
11/19/2016 Version 4.1.2
214
- Fix compilation with musl C library (#260)
315
- Support parallel builds (#259)

src/common/flows.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static inline flow_entry_type_t hash_put_data(flow_hash_table_t *fht, const uint
147147
res = FLOW_ENTRY_INVALID;
148148
}
149149

150-
dbgx(2, "flow type=%d\n", (int)res);
150+
dbgx(2, "flow type=%d", (int)res);
151151
return res;
152152
}
153153

@@ -321,7 +321,7 @@ flow_hash_table_t *flow_hash_table_init(size_t n)
321321
{
322322
flow_hash_table_t *fht;
323323
if (!is_power_of_2(n))
324-
errx(-1, "invalid table size: %zu\n", n);
324+
errx(-1, "invalid table size: %zu", n);
325325

326326
fht = safe_malloc(sizeof(*fht));
327327
fht->num_buckets = n;

src/common/netmap.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,9 +502,16 @@ void sendpacket_close_netmap(void *p)
502502
fprintf(stderr, "Switching network driver for %s to normal mode... ",
503503
sp->device);
504504
fflush(NULL);
505-
/* flush any remaining packets */
505+
506+
/* flush any remaining packets */
506507
ioctl(sp->handle.fd, NIOCTXSYNC, NULL);
507508

509+
/* wait for traffic to be sent */
510+
dbgx(2, "Waiting %d seconds for phy reset...", sp->netmap_delay);
511+
sleep(sp->netmap_delay);
512+
dbg(2, "Ready!");
513+
514+
508515
#ifdef linux
509516
if (!sp->is_vale) {
510517
/* restore original settings:

src/common/sendpacket.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ struct sendpacket_s {
127127
struct tcpr_ether_addr ether;
128128
#if defined HAVE_QUICK_TX || defined HAVE_NETMAP
129129
int first_packet;
130+
int netmap_delay;
130131
#endif
131132

132133
#ifdef HAVE_QUICK_TX

src/common/utils.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ packet_stats(const tcpreplay_stats_t *stats)
157157
}
158158

159159
if (diff_us >= 1000000)
160-
printf("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%02zd seconds.\n",
161-
stats->pkts_sent, stats->bytes_sent, (ssize_t)diff.tv_sec, (ssize_t)(diff.tv_usec / (100 * 1000)));
160+
printf("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%02zd seconds\n",
161+
stats->pkts_sent, stats->bytes_sent, (ssize_t)diff.tv_sec, (ssize_t)(diff.tv_usec / (10 * 1000)));
162162
else
163-
printf("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%06zd seconds.\n",
163+
printf("Actual: " COUNTER_SPEC " packets (" COUNTER_SPEC " bytes) sent in %zd.%06zd seconds\n",
164164
stats->pkts_sent, stats->bytes_sent, (ssize_t)diff.tv_sec, (ssize_t)diff.tv_usec);
165165

166166

@@ -177,6 +177,29 @@ packet_stats(const tcpreplay_stats_t *stats)
177177
stats->failed);
178178
}
179179

180+
/**
181+
* fills a buffer with a string representing the given time
182+
*
183+
* @param when: the time that should be formatted
184+
* @param buf: a buffer to write to
185+
* @param len: length of the buffer
186+
* @return: string containing date, or -1 on error
187+
*/
188+
int format_date_time(struct timeval *when, char *buf, size_t len)
189+
{
190+
struct tm *tm;
191+
char tmp[64];
192+
193+
assert(len);
194+
195+
tm = localtime(&when->tv_sec);
196+
if (!tm)
197+
return -1;
198+
199+
strftime(tmp, sizeof tmp, "%Y-%m-%d %H:%M:%S.%%06u", tm);
200+
return snprintf(buf, len, tmp, when->tv_usec);
201+
}
202+
180203
/**
181204
* reads a hexstring in the format of xx,xx,xx,xx spits it back into *hex
182205
* up to hexlen bytes. Returns actual number of bytes returned. On error

src/common/utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ typedef struct {
4646

4747
int read_hexstring(const char *l2string, u_char *hex, const int hexlen);
4848
void packet_stats(const tcpreplay_stats_t *stats);
49+
int format_date_time(struct timeval *when, char *buf, size_t len);
4950

5051
/* our "safe" implimentations of functions which allocate memory */
5152
#define safe_malloc(x) _our_safe_malloc(x, __FUNCTION__, __LINE__, __FILE__)

src/send_packets.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,13 @@ static bool calc_sleep_time(tcpreplay_t *ctx, struct timeval *pkt_time_delta,
11701170
*/
11711171
now_us = TIMSTAMP_TO_MICROSEC(sent_timestamp);
11721172
if (now_us) {
1173-
COUNTER pps = ctx->options->speed.speed * (ctx->options->speed.pps_multi > 0 ? ctx->options->speed.pps_multi : 1);;
1173+
COUNTER pph = ctx->options->speed.speed * (ctx->options->speed.pps_multi > 0 ? ctx->options->speed.pps_multi : (60 * 60));;
11741174
COUNTER pkts_sent = ctx->stats.pkts_sent;
1175-
/* packets * 1000000 divided by pps = microseconds */
1176-
COUNTER next_tx_us = (pkts_sent * 1000000) / pps;
1175+
/*
1176+
* packets * 1000000 divided by pps = microseconds
1177+
* packets per sec (pps) = packets per hour / (60 * 60)
1178+
*/
1179+
COUNTER next_tx_us = (pkts_sent * 1000000) * (60 * 60) / pph;
11771180
COUNTER tx_us = now_us - *start_us;
11781181
if (next_tx_us > tx_us)
11791182
NANOSEC_TO_TIMESPEC((next_tx_us - tx_us) * 1000, &ctx->nap);

src/tcpcapinfo.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,15 @@ main(int argc, char *argv[])
281281
caplen = pcap_ph.caplen;
282282
}
283283

284+
if (caplentoobig) {
285+
printf("\n\nCapture file appears to be damaged or corrupt.\n"
286+
"Contains packet of size %u, bigger than snap length %u\n",
287+
caplen, pcap_fh.snaplen);
288+
289+
close(fd);
290+
break;
291+
}
292+
284293
/* check to make sure timestamps don't go backwards */
285294
if (last_sec > 0 && last_usec > 0) {
286295
if ((pcap_ph.ts.tv_sec == last_sec) ?
@@ -306,7 +315,7 @@ main(int argc, char *argv[])
306315
}
307316

308317
close(fd);
309-
continue;
318+
break;
310319
}
311320

312321
/* print the frame checksum */

0 commit comments

Comments
 (0)