Skip to content

Commit e35b34f

Browse files
committed
chore: Add pcap example
Signed-off-by: Leon Hwang <hffilwlqm@gmail.com>
1 parent a3c1228 commit e35b34f

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

README.md

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,16 @@ Usage: ./vista [options] [pcap-filter]
6161
--kprobe-backend string Tracing backend('kprobe', 'kprobe-multi'). Will auto-detect if not specified.
6262
--output-file string write traces to file
6363
--output-iptables print iptables
64-
--output-limit-lines uint exit the program after the number of events has been received/printed
64+
--output-limit-lines int exit the program after the number of events has been received/printed
6565
--output-meta print skb metadata
6666
--output-sk print sock
6767
--output-skb print skb
6868
--output-stack print stack
6969
--output-tcp print TCP
7070
--output-tuple print L4 tuple
71+
--pcap-file string write packets to pcap file, only work with --filter-trace-xdp/--filter-trace-tc
72+
--pcap-mode strings pcap mode, can be 'entry' and/or 'exit', only work with --pcap-file. Default is 'entry' and 'exit'. 'entry' is to capture packet before BPF prog, 'exit' is to capture packet after BPF prog.
73+
--pcap-snaplen uint16 snapture length of packet for pcap (default 256)
7174
--timestamp string print timestamp per event ("relative", "absolute", "none") (default "none")
7275
--version show vista version and exit
7376
```
@@ -76,6 +79,31 @@ The `--filter-skb-func` switch does an exact match on function names i.e.
7679
`--filter-skb-func=foo` only matches `foo()`; for a wildcarded match, try
7780
`--filter-skb-func=".*foo.*"` instead. The same applies to `--filter-sk-func`.
7881
82+
### Examples
83+
84+
#### Capture packets when --filter-trace-xdp and/or --filter-trace-tc is enabled
85+
86+
```bash
87+
$ sudo ./vista --filter-trace-xdp --filter-trace-tc --output-meta --output-tuple --output-limit-lines 4 --pcap-file vista.pcapng icmp
88+
2024/05/25 13:08:37 Tracing tc progs..
89+
2024/05/25 13:08:37 Tracing xdp progs..
90+
2024/05/25 13:08:37 Listening for events..
91+
SKB/SK CPU PROCESS FUNC
92+
0xffff990282314000 2 [<empty>(0)] dummy(xdp) netns=4026531840 mark=0x0 iface=2(ens33) proto=0x0000 mtu=1500 len=98 pkt_type=HOST 192.168.241.1->192.168.241.133(icmp request id=23089 seq=0)
93+
Saving this packet to vista.pcapng..
94+
0xffff990282314000 2 [<empty>(0)] dummy(xdp) netns=4026531840 mark=0x0 iface=2(ens33) proto=0x0000 mtu=1500 len=98 pkt_type=HOST 192.168.241.1->192.168.241.133(icmp request id=23089 seq=0)
95+
Saving this packet to vista.pcapng..
96+
0xffff990282314000 2 [<empty>(0)] dummy(tc) netns=4026531840 mark=0x0 iface=2(ens33) proto=0x0800 mtu=1500 len=98 pkt_type=HOST 192.168.241.1->192.168.241.133(icmp request id=23089 seq=0)
97+
Saving this packet to vista.pcapng..
98+
0xffff990282314000 2 [<empty>(0)] dummy(tc) netns=4026531840 mark=0x0 iface=2(ens33) proto=0x0800 mtu=1500 len=98 pkt_type=HOST 192.168.241.1->192.168.241.133(icmp request id=23089 seq=0)
99+
Saving this packet to vista.pcapng..
100+
2024/05/25 13:08:39 Printed 4 events, exiting program..
101+
```
102+
103+
There is enhanced packet information for each packet, like `comment`, `Interface queue` and `Verdict`.
104+
105+
![vista.pcapng](./vista-pcapng.png)
106+
79107
## Developing
80108
81109
### Dependencies

vista-pcapng.png

463 KB
Loading

0 commit comments

Comments
 (0)