4.0.1-hotfixescachetimestampsdevelopdpdk-ndagetsilivegetfragoffhelplibtrace4ndag_formatpfringrc-4.0.1rc-4.0.2rc-4.0.3rc-4.0.4ringdecrementfixringperformanceringtimestampfixes
Last change
on this file since 6010b54 was
f0b9060,
checked in by Daniel Lawson <dlawson@…>, 16 years ago
|
removed trace_ prefix on functions where it isn't needed
|
-
Property mode set to
100755
|
File size:
993 bytes
|
Line | |
---|
1 | #!/usr/bin/python |
---|
2 | import sys |
---|
3 | sys.path.append('/usr/local/lib/python2.4/site-packages/libtrace') |
---|
4 | import libtrace |
---|
5 | |
---|
6 | trace = libtrace.Trace(sys.argv[1]) |
---|
7 | |
---|
8 | if trace.is_err(): |
---|
9 | print "Trace failed: %s" % trace.trace_get_err() |
---|
10 | sys.exit() |
---|
11 | print "trace=",trace |
---|
12 | |
---|
13 | |
---|
14 | packet = libtrace.Packet() |
---|
15 | |
---|
16 | print "packet=",packet |
---|
17 | count = 0 |
---|
18 | |
---|
19 | filter = libtrace.Filter("tcp") |
---|
20 | print "filter=",filter |
---|
21 | |
---|
22 | ret=trace.start() |
---|
23 | |
---|
24 | if ret < 0: |
---|
25 | print "Trace failed to start with error %s " % ret |
---|
26 | sys.exit() |
---|
27 | |
---|
28 | while 1: |
---|
29 | trace.read_packet(packet) |
---|
30 | if not packet: |
---|
31 | break |
---|
32 | |
---|
33 | ippacket = packet.get_ip() |
---|
34 | if not ippacket: |
---|
35 | continue |
---|
36 | |
---|
37 | count += 1 |
---|
38 | if count % 10000 == 0: |
---|
39 | print count |
---|
40 | |
---|
41 | tcppacket = packet.get_tcp() |
---|
42 | if not tcppacket: |
---|
43 | continue |
---|
44 | |
---|
45 | if not packet.apply_filter(filter): |
---|
46 | continue |
---|
47 | |
---|
48 | src = packet.get_source_port() |
---|
49 | dst = packet.get_destination_port() |
---|
50 | if packet.get_server_port(4,src,dst) == 0: |
---|
51 | print ippacket.ip_src,':',src,'->',ippacket.ip_dst,':',dst |
---|
52 | else: |
---|
53 | print ippacket.ip_dst,':',dst,'<-',ippacket.ip_src,':',src |
---|
54 | |
---|
Note: See
TracBrowser
for help on using the repository browser.