4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 2c060e3 was
2c060e3,
checked in by Daniel Lawson <dlawson@…>, 18 years ago
|
Initial revision
|
-
Property mode set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | // $Id$ |
---|
2 | // |
---|
3 | // This program takes a trace and outputs every packet that it sees to standard |
---|
4 | // out, decoding source/dest IP's, protocol type, and the timestamp of this |
---|
5 | // packet. |
---|
6 | |
---|
7 | #include <stdio.h> |
---|
8 | #include <stdlib.h> |
---|
9 | #include <assert.h> |
---|
10 | #include <string.h> |
---|
11 | #include <sys/time.h> |
---|
12 | #include <time.h> |
---|
13 | |
---|
14 | #include <netinet/in.h> |
---|
15 | #include <netinet/tcp.h> |
---|
16 | #include <netinet/ip.h> |
---|
17 | #include <netinet/ip_icmp.h> |
---|
18 | #include <arpa/inet.h> |
---|
19 | #include <sys/socket.h> |
---|
20 | #include "dagformat.h" |
---|
21 | #include "libtrace.h" |
---|
22 | |
---|
23 | struct libtrace_t *trace; |
---|
24 | |
---|
25 | #define SCANSIZE 4096 |
---|
26 | |
---|
27 | char *buffer[SCANSIZE]; |
---|
28 | |
---|
29 | int main(int argc, char *argv[]) { |
---|
30 | |
---|
31 | char *uri = "rtclient:chasm.cs.waikato.ac.nz"; |
---|
32 | int psize = 0; |
---|
33 | int status = 0; |
---|
34 | struct libtrace_ip *ipptr = 0; |
---|
35 | |
---|
36 | if (argc == 2) { |
---|
37 | uri = strdup(argv[1]); |
---|
38 | } |
---|
39 | |
---|
40 | // open a trace |
---|
41 | trace = create_trace(uri); |
---|
42 | |
---|
43 | for (;;) { |
---|
44 | unsigned char *x; |
---|
45 | int i; |
---|
46 | if ((psize = libtrace_read_packet(trace, buffer, SCANSIZE, &status)) <1) { |
---|
47 | break; |
---|
48 | } |
---|
49 | |
---|
50 | printf("TS %f: ",get_seconds(trace,buffer,SCANSIZE)); |
---|
51 | |
---|
52 | ipptr = get_ip(trace,buffer,SCANSIZE); |
---|
53 | if (!ipptr) { |
---|
54 | printf("Non IP\n"); |
---|
55 | continue; |
---|
56 | } |
---|
57 | |
---|
58 | printf("%s -> ",inet_ntoa(ipptr->ip_src)); |
---|
59 | printf("%s protocol %02x\n", |
---|
60 | inet_ntoa(ipptr->ip_dst), |
---|
61 | ipptr->ip_p); |
---|
62 | x=(void*)ipptr; |
---|
63 | for(i=0;i<get_capture_length(trace,buffer,SCANSIZE);i++) { |
---|
64 | if (i%4==0 && i!=0) |
---|
65 | printf("\n"); |
---|
66 | printf("%02x ",x[i]); |
---|
67 | } |
---|
68 | printf("\n\n"); |
---|
69 | } |
---|
70 | |
---|
71 | destroy_trace(trace); |
---|
72 | return 0; |
---|
73 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.