3 snoopy \- spy on network packets
35 matches them to a filter (by default anything matches), and writes
36 matching packets to standard output either in human readable form (default)
37 or in a binary trace format that can be later read by
40 can be the name of an Ethernet
46 or a file of captured packets.
48 The human readable format consists of multiple lines per packet.
49 The first line contains the milliseconds since the
50 trace was started. Subsequent ones are indented with a tab
51 and each contains the dump of a single protocol header. The last line
52 contains the dump of any contained data. For example, a
54 packet would look like:
58 ether(s=0000929b1b54 d=ffffffffffff pr=0800 ln=342)
59 ip(s=135.104.9.62 d=255.255.255.255 id=5099 frag=0000...
60 udp(s=68 d=67 ck=d151 ln= 308)
61 bootp(t=Req ht=1 hl=16 hp=0 xid=217e5f27 sec=0 fl=800...
62 dhcp(t=Request clientid=0152415320704e7266238ebf01030...
65 The binary format consists of:
67 2 bytes of packet length, msb first
69 8 bytes of nanosecond time, msb first
73 Filters are expressions specifying protocols to be traced
74 and specific values for fields in the protocol headers.
78 \fIexpr\fP: \fIprotocol\fP
79 | \fIfield\fP '=' \fIvalue\fP
80 | \fIfield\fP '!=' \fIvalue\fP
81 | \fIprotocol\fP '(' \fIexpr\fP ')'
83 | \fIexpr\fP '||' \fIexpr\fP
84 | \fIexpr\fP '&&' \fIexpr\fP
95 option. With no arguments, it lists the known protocols.
96 Otherwise it prints, for each protocol specified,
97 which subprotocols it can multiplex to,
98 and which fields can be used for filtering.
99 For example, the listing for ethernet is currently:
102 ether's filter attributes:
104 d - destination address
105 a - source|destination address
106 sd - source|destination address
109 0x0800 ip 0x8863 pppoe_disc
110 0x0806 arp 0x8864 pppoe_sess
111 0x0806 rarp 0x888e eapol
117 depends on context. In general,
118 ethernet addresses are entered as a string of hex
119 digits; IP numbers in the canonical `.' format for v4 and `:' format
120 for v6; and ports in decimal.
126 compute the correct checksum for each packet;
127 on mismatch, add a field
131 is the correct checksum.
134 output will be a binary trace file in Unix pcap format.
137 output will be a binary trace file.
140 input is a binary trace file as generated with the
145 do not enter promiscuous mode. Only packets to
146 this interface will be seen.
149 force one output line per packet. The
150 default is multiline.
153 discard all but the first
155 bytes of each packet. The default is to keep the entire packet.
156 This option is most useful when writing packets to a file with the
163 data bytes per packet. The default is 32.
168 to filter the packet stream. The default is
169 to match all packets.
172 assume the first header per packet to be of the
185 % snoopy -f 'arp || bootp'
186 after optimize: ether(arp || ip(udp(bootp)))
189 The first line of output shows the completed filter
192 will fill in other protocols as necessary to complete
193 the filter and then optimize to remove redundant
196 To save all packets between 135.104.9.2 to 135.104.9.6 and
197 later display those to/from TCP port 80:
201 % snoopy -df 'ip(s=135.104.9.2 && d=135.104.9.6) ||\\
202 ip(s=135.104.9.6 && d=135.104.9.2)' > /tmp/quux
203 <interrupt from the keyboard>
204 % snoopy -tf 'tcp(sd=80)' /tmp/quux
211 .B /sys/src/cmd/ip/snoopy
214 only dumps ethernet packets, because there's
215 no device to get IP packets without a media header.