tcpdump笔记

tcpdump笔记

tcpdump --help

tcpdump version 4.9.3
libpcap version 1.7.4
OpenSSL 1.0.2g  1 Mar 2016
Usage: tcpdump [-aAbdDefhHIJKlLnNOpqStuUvxX#] [ -B size ] [ -c count ]
		[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
		[ -i interface ] [ -j tstamptype ] [ -M secret ] [ --number ]
		[ -Q in|out|inout ]
		[ -r file ] [ -s snaplen ] [ --time-stamp-precision precision ]
		[ --immediate-mode ] [ -T type ] [ --version ] [ -V file ]
		[ -w file ] [ -W filecount ] [ -y datalinktype ] [ -z postrotate-command ]
		[ -Z user ] [ expression ]

tcpdump expression

expression
              selects which packets will be dumped.  If no expression is given, all packets on the net will be dumped.  Otherwise, only packets for which expression is `true' will be dumped.

              For the expression syntax, see pcap-filter(7).

              The  expression argument can be passed to tcpdump as either a single Shell argument, or as multiple Shell arguments, whichever is more convenient.  Generally, if the expression contains Shell metacharacters, such as backslashes used to escape proto‐
              col names, it is easier to pass it as a single, quoted argument rather than to escape the Shell metacharacters.  Multiple arguments are concatenated with spaces before being parsed.

常用命令

抓取目标端口5060的UDP数据

tcpdump -i any -w /tmp/sip.cap udp dst port 5060

终端输出SIP报文

tcpdump -n -v -s 1500 -i any udp port 5060 or udp portrange 50000-54000

直接输出udp信令制定IP和端口

tcpdump -n -v -s 1500 -i any dst host 192.168.1.37 and udp dst port 15060

目标IP地址过滤

tcpdump -n -v -s 1500 -i any dst host 120.53.223.230

双方根据IP抓取单项UDP包

# UDP接收端使用命令,117.158.134.217为发送端IP地址
tcpdump -n -v -i any udp and src host 117.158.134.217
# UDP发送端使用命令,1.192.88.134为接受端IP地址
tcpdump -n -v -i any udp and dst host 1.192.88.134

翻译

谷歌翻译

名称
       tcpdump - 转储网络上的流量

概要
       tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
               [ -c count ]
               [ -C file_size ] [ -G rotate_seconds ] [ -F file ]
               [ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M秘密]
               [ --number ] [ -Q in|out|inout ]
               [ -r file ] [ -V file ] [ -s snaplen ] [ -T type ] [ -w file ]
               [ -W filecount ]
               [ -E spi @ipaddr 算法:secret,... ]
               [ -y datalinktype ] [ -z postrotate-command ] [ -Z user ]
               [ --time-stamp-precision=tstamp_precision ]
               [ --immediate-mode ] [ --version ]
               [ 表达 ]

描述
       Tcpdump 打印出网络接口上与布尔表达式匹配的数据包内容的描述;描述前面有一个时间戳,默认情况下,打印为小时、分钟、秒和自午夜以来的几分之一秒。
       它也可以使用 -w 标志运行,这使其将数据包数据保存到文件中以供以后分析,和/或使用 -r 标志运行,使其从保存的数据包文件中读取而不是读取数据包来自网络接口(请注意 tcpdump
       是通过 Ubuntu 中的强制 apparmor(7) 配置文件保护的,该配置文件限制了 tcpdump 可以访问的文件)。它也可以使用 -V 标志运行,这会导致它读取保存的数据包文件列表。在所有情况下,只有匹配表达式的数据包才会被
       由 tcpdump 处理。

       如果不使用 -c 标志运行,Tcpdump 将继续捕获数据包,直到它被 SIGINT 信号(例如,通过键入您的中断字符,通常是 control-C 生成)或 SIGTERM 信号(通常由 kill 生成)中断(1)
       命令);如果使用 -c 标志运行,它将捕获数据包,直到它被 SIGINT 或 SIGTERM 信号中断或已处理指定数量的数据包。

       当 tcpdump 完成捕获数据包时,它将报告以下计数:

              “捕获的”数据包(这是 tcpdump 已接收和处理的数据包数量);

              数据包“由过滤器接收”(其含义取决于您运行 tcpdump 的操作系统,也可能取决于操作系统的配置方式 - 如果在命令行上指定了过滤器,则在某些操作系统上它很重要包而不管
              他们是否是由过滤器表达式和匹配,即使他们被过滤表达式匹配,不论是否tcpdump的已经阅读并处理他们的是,在其他操作系统也只计算被过滤
              表达式不管 tcpdump 是否已经读取和处理它们,并且在其他操作系统上,它只计算过滤表达式匹配并由 tcpdump 处理的数据包);

              “内核丢弃的数据包”(这是由于缺少缓冲区空间而被运行 tcpdump 的操作系统中的数据包捕获机制丢弃的数据包数量,如果操作系统向应用程序报告该信息;如果不是,则
              报告为0)。

       在支持 SIGINFO 信号的平台上,例如大多数 BSD(包括 Mac OS X)和 Digital/Tru64 UNIX,它会在收到 SIGINFO 信号(例如,通过键入“状态”字符生成)时报告这些计数, 通常是 control-T,
       虽然在某些平台上,例如 Mac OS X,默认情况下没有设置 ``status'' 字符,因此您必须使用 stty(1) 设置它才能使用它) 并将继续捕获数据包。在不支持 SIGINFO 信号的平台上,同样可以
       通过使用 SIGUSR1 信号来实现。

       从网络接口读取数据包可能需要您具有特殊权限;有关详细信息,请参阅 pcap (3PCAP) 手册页。读取保存的数据包文件不需要特殊权限。

选项
       -A 以 ASCII 格式打印每个数据包(减去其链接级标头)。方便捕捉网页。

       -b 以 ASDOT 表示法而不是 ASPLAIN 表示法打印 BGP 数据包中的 AS 编号。

       -B buffer_size
       --buffer-size=buffer_size
              将操作系统捕获缓冲区大小设置为 buffer_size,单位为 KiB(1024 字节)。

       -c count
              收到count包后退出。

       -C file_size
              在将原始数据包写入保存文件之前,检查文件当前是否大于 file_size,如果是,则关闭当前保存文件并打开一个新文件。第一个保存文件之后的保存文件将具有使用 -w 标志指定的名称,
              其后带有一个数字,从 1 开始并继续向上。file_size 的单位是百万字节(1,000,000 字节,而不是 1,048,576 字节)。

       -d 将编译后的数据包匹配代码以人类可读的形式转储到标准输出并停止。

       -dd 将数据包匹配代码转储为 C 程序片段。

       -ddd 将数据包匹配代码转储为十进制数(以计数开头)。

       -D
       --list-interfaces
              打印系统上可用的网络接口列表以及 tcpdump 可以在其上捕获数据包的网络接口。对于每个网络接口,会打印一个编号和一个接口名称,可能后跟该接口的文本描述。可以将接口
              名称或编号提供给 -i 标志以指定要捕获的接口。

              这在没有列出它们的命令的系统上很有用(例如,Windows 系统或缺少 ifconfig -a 的 UNIX 系统);该数字在 Windows 2000 和更高版本的系统上很有用,其中接口名称是一个有点复杂的字符串。

              如果 tcpdump 是使用缺少 pcap_findalldevs() 函数的旧版 libpcap 构建的,则将不支持 -D 标志。

       -e 在每个转储行上打印链接级标头。例如,这可用于打印以太网和 IEEE 802.11 等协议的 MAC 层地址。

       -E 使用 spi@ipaddr algo:secret 来解密寻址到 addr 并包含安全参数索引值 spi 的 IPsec ESP 数据包。这种组合可以用逗号或换行符分隔重复。

              请注意,此时支持为 IPv4 ESP 数据包设置密钥。

              算法可能是 des-cbc、3des-cbc、blowfish-cbc、rc3-cbc、cast128-cbc 或无。默认值为 des-cbc。只有在启用加密的情况下编译 tcpdump 时,才能解密数据包。

              secret 是 ESP 密钥的 ASCII 文本。如果前面有 0x,则将读取十六进制值。

              该选项假定 RFC2406 ESP,而不是 RFC1827 ESP。该选项仅用于调试目的,不鼓励将此选项与真正的“秘密”密钥一起使用。通过在命令行上显示 IPsec 密钥,您可以通过
              ps(1) 和其他场合使其对其他人可见。

              除了上面的语法,语法文件名可以用来让 tcpdump 读入提供的文件。该文件在收到第一个 ESP 数据包时打开,因此任何 tcpdump 可能被赋予的特殊权限应该已经被
              放弃.

       -f 以数字而非符号方式打印“外国”IPv4 地址(此选项旨在绕过 Sun 的 NIS 服务器中的严重脑损伤——通常它在翻译非本地互联网号码时永远挂起)。

              “外部”IPv4 地址的测试是使用进行捕获的接口的 IPv4 地址和网络掩码完成的。如果该地址或网络掩码不可用,可用,要么是因为正在执行捕获的接口
              没有地址或网络掩码,要么是因为捕获是在 Linux“任何”接口上完成的,它可以在多个接口上捕获,此选项将无法正常工作。

       -F file
              使用 file 作为过滤器表达式的输入。命令行上给出的附加表达式将被忽略。

       -G rotate_seconds
              如果指定,则每隔rotate_seconds 秒轮换使用-w 选项指定的转储文件。保存文件将具有由 -w 指定的名称,其中应包含由 strftime(3) 定义的时间格式。如果没有指定时间格式,每个新文件
              都会覆盖以前的文件。

              如果与 -C 选项结合使用,文件名将采用 `file' 的形式。

       -h
       --help 打印 tcpdump 和 libpcap 版本字符串,打印使用信息,然后退出。

       --version
              打印 tcpdump 和 libpcap 版本字符串并退出。

       -H 尝试检测 802.11s 草案网格标头。

       -i interface
       --interface=interface
              监听接口。如果未指定,tcpdump 会在系统接口列表中搜索编号最低的、已配置的接口(不包括环回),结果可能是,例如,“eth0”。

              在具有 2.2 或更高版本内核的 Linux 系统上,接口参数“any”可用于从所有接口捕获数据包。请注意,“任何”设备上的捕获不会在混杂模式下完成。

              如果支持 -D 标志,则该标志打印的接口编号可以用作接口参数,如果系统上没有接口将该编号用作名称。

       -I
       --monitor-mode
              将界面置于“监控模式”;这仅在 IEEE 802.11 Wi-Fi 接口上受支持,并且仅在某些操作系统上受支持。

              请注意,在监控模式下,适配器可能会与与其关联的网络解除关联,因此您将无法通过该适配器使用任何无线网络。
              如果您在监控模式下捕获并且没有使用另一个适配器连接到另一个网络,这可能会阻止访问网络服务器上的文件,或解析主机名或网络地址。

              此标志将影响 -L 标志的输出。如果未指定 -I,则仅显示未处于监控模式时可用的链路层类型;如果指定了 -I,则仅显示处于监控模式时可用的那些链路层类型。

       --immediate-mode
              在“立即模式”中捕获。在这种模式下,数据包一到达就被传送到 tcpdump,而不是为了效率而被缓冲。如果数据包
              被打印到终端而不是文件或管道,这是打印数据包而不是将数据包保存到“保存文件”时的默认设置。

       -j tstamp_type
       --time-stamp-type=tstamp_type
              将捕获的时间戳类型设置为 tstamp_type。用于时间戳类型的名称在 pcap-tstamp(7) 中给出;并非所有列出的类型都对任何给定的接口都有效。

       -J
       --list-time-stamp-types
              列出接口支持的时间戳类型并退出。如果接口不能设置时间戳类型,则不列出时间戳类型。

       --time-stamp-precision=tstamp_precision
              捕获时,设置捕获的时间戳精度为tstamp_precision。请注意,高精度时间戳(纳秒)的可用性及其实际精度取决于平台和硬件。另请注意,将
              纳秒精度的捕获写入保存文件时,时间戳以纳秒分辨率写入,文件以不同的幻数写入,以指示时间戳以秒和纳秒为单位;并非所有读取
              pcap 保存文件的程序都能够读取这些捕获。

       读取保存文件时,将时间戳转换为时间戳精度指定的精度,并以该分辨率显示它们。如果指定的精度小于文件中时间戳的精度,则转换将失去精度。

       timestamp_precision 支持的值为 micro(用于微秒分辨率)和 nano(用于纳秒分辨率)。默认为微秒分辨率。

       -K
       --dont-verify-checksums
              不要尝试验证 IP、TCP 或 UDP 校验和。这对于在硬件中执行部分或全部校验和计算的接口很有用;否则,所有传出的 TCP 校验和都将被标记为错误。

       -l 使 stdout 行缓冲。如果您想在捕获数据时查看数据,则很有用。例如,

                     tcpdump -l | 开球日期

              或者

                     tcpdump -l > dat & tail -f dat

              请注意,在 Windows 上,“行缓冲”意味着“无缓冲”,因此如果指定了 -l,WinDump 将单独写入每个字符。

              -U 的行为与 -l 类似,但它会导致输出为“数据包缓冲”,因此输出将在每个数据包的末尾而不是在每一行的末尾写入 stdout;这是在所有平台上缓冲的,包括 Windows。

       -L
       --list-data-link-types
              列出接口的已知数据链路类型,在指定模式下,然后退出。已知数据链路类型的列表可能取决于指定的模式;例如,在某些平台上,Wi-Fi 接口
              在未处于监控模式时可能支持一组数据链路类型(例如,它可能仅支持假以太网标头,或者可能支持 802.11 标头但不支持带有无线电信息的 802.11 标头) 和另一组数据链路类型在监控模式下(例如,它可能
              支持 802.11 标头,或带有无线电信息的 802.11 标头,仅在监控模式下)。

       -m module
              从文件模块加载 SMI MIB 模块定义。此选项可多次使用以将多个 MIB 模块加载到 tcpdump 中。

       -M 秘密
              使用秘密作为共享秘密来验证在 TCP 段中找到的带有 TCP-MD5 选项 (RFC 2385) 的摘要(如果存在)。

       -n 不要将地址(即主机地址、端口号等)转换为名称。

       -N 不打印主机名的域名限定。例如,如果你给出这个标志,那么 tcpdump 将打印 ``nic'' 而不是 ``nic.ddn.mil''。

       -#
       --number 在行首
              打印可选的数据包编号。

       -O
       --no-optimize
              不要运行数据包匹配代码优化器。仅当您怀疑优化器中存在错误时,这才有用。

       -p
       --no-promiscuous-mode
              不要将接口置于混杂模式。请注意,由于某些其他原因,界面可能处于混杂模式;因此,“-p”不能用作“以太主机{local-hw-addr}或以太广播”的缩写。

       -Q direction
       --direction=direction
              选择应捕获数据包的发送/接收方向。可能的值为“in”、“out”和“inout”。并非在所有平台上都可用。

       -q 快速(安静?)输出。打印更少的协议信息,因此输出行更短。

       -r file
              从文件中读取数据包(使用 -w 选项或其他写入 pcap 或 pcap-ng 文件的工具创建)。如果文件是“-”,则使用标准输入。

       -S
       --absolute-tcp-sequence-numbers
              打印绝对而不是相对的 TCP 序列号。

       -s snaplen
       --snapshot-length=snaplen
              从每个数据包中获取 snaplen 字节的数据,而不是默认的 262144 字节。由于快照有限而被截断的数据包在输出中用“[|proto]”表示,其中 proto 是
              发生截断的协议级别的名称。请注意,拍摄更大的快照既会增加处理数据包所需的时间,也能有效地减少数据包缓冲量。这可能会导致数据包丢失。您应该将 snaplen 限制在
              将捕获您感兴趣的协议信息的最小数字。将 snaplen 设置为 0 会将其设置为默认值 262144,以便与最近的旧版本 tcpdump 向后兼容。

       -T type
              强制“表达式”选择的数据包被解释为指定的类型。目前已知的类型有 aodv(Ad-hoc On-demand 距离向量协议)、carp(通用地址冗余协议)、cnfp(Cisco NetFlow 协议)、lmp(链路管理
              协议)、pgm(Pragmatic General Multicast)、pgm_zmtp1(ZMTP/ 1.0 inside PGM/EPGM)、resp (REdis Serialization Protocol)、radius (RADIUS)、rpc (Remote Procedure Call)、rtp (Real-Time Applications protocol)、rtcp (Real-Time Applications control protocol
              )、snmp (Simple网络管理协议)、tftp(普通文件传输协议)、vat(视觉音频工具)、wb(分布式白板)、zmtp1(ZeroMQ 消息传输协议 1.0)和 vxlan(虚拟可扩展局域网)。

              请注意,上面的 pgm 类型仅影响 UDP 解释,无论如何,本地 PGM 始终被识别为 IP 协议 113。UDP 封装的 PGM 通常称为“EPGM”或“PGM/UDP”。

              请注意,上面的 pgm_zmtp1 类型会同时影响本地 PGM 和 UDP 的解释。在本地 PGM 解码期间,ODATA/RDATA 数据包的应用程序数据将被解码为带有 ZMTP/1.0 帧的 ZeroMQ 数据报。在 UDP
              解码期间,除此之外,任何 UDP 数据包都将被视为封装的 PGM 数据包。

       -t 不要在每个转储行上打印时间戳。

       -tt 在每个转储行上打印时间戳,以自 1970 年 1 月 1 日以来的秒数、00:00:00、UTC 以及自该时间以来的几分之一秒为单位。

       -ttt 在每个转储行上打印当前行和前一行之间的增量(微秒分辨率)。

       -tttt 在每个转储行上打印时间戳,以小时、分钟、秒和自午夜以来的秒的分数为单位,在日期之前。

       -ttttt 在每个转储行上打印当前行和第一行之间的增量(微秒分辨率)。

       -u 打印未解码的 NFS 句柄。

       -U
       --packet-buffered
              如果未指定 -w 选项,则使打印的数据包输出为 ``packet-buffered'';即,当打印每个数据包内容的描述时,它将被写入标准输出,而不是在不写入终端时,
              仅在输出缓冲区填满时写入。

              如果指定了 -w 选项,则将保存的原始数据包输出为 ``packet-buffered'';即,当每个数据包被保存时,它将被写入输出文件,而不是仅在输出缓冲区填满时才写入。

              如果 tcpdump 是使用缺少 pcap_dump_flush() 函数的旧版 libpcap 构建的,则将不支持 -U 标志。

       -v 解析和打印时,生成(稍微多一点)详细的输出。例如,打印 IP 数据包中的生存时间、标识、总长度和选项。还启用额外的数据包完整性检查,例如验证 IP 和
              ICMP 标头校验和。

              使用 -w 选项写入文件时,每 10 秒报告一次捕获的数据包数。

       -vv 更详细的输出。例如,附加字段从 NFS 回复数据包中打印出来,并且 SMB 数据包被完全解码。

       -vvv 更详细的输出。例如,telnet SB ... SE 选项被完整打印。使用 -X Telnet 选项也以十六进制打印。

       -V file
              从文件中读取文件名列表。如果文件是“-”,则使用标准输入。

       -w file
              将原始数据包写入文件而不是解析并打印出来。稍后可以使用 -r 选项打印它们。如果文件是“-”,则使用标准输出。

              如果写入文件或管道,此输出将被缓冲,因此从文件或管道读取的程序可能在收到数据包后的任意时间内看不到数据包。使用 -U 标志使数据包在
              收到后立即写入。

              MIME 类型 application/vnd.tcpdump.pcap 已在 IANA 注册用于 pcap 文件。文件扩展名 .pcap 似乎是最常与 .cap 和 .dmp 一起使用的。Tcpdump 本身在读取捕获
              文件时不检查扩展名,并且在写入时不添加扩展名(它在文件头中使用幻数)。但是,许多操作系统和应用程序将使用扩展名(如果存在)并建议添加一个(例如 .pcap)。

              有关文件格式的说明,请参阅 pcap-savefile(5)。

       -W 与 -C 选项结合使用,这会将创建的文件数量限制为指定数量,并从头开始覆盖文件,从而创建一个“旋转”缓冲区。此外,它会以足够多的前导
              0 来命名文件,以支持最大数量的文件,从而使它们能够正确排序。

              与 -G 选项结合使用,这将限制创建的旋转转储文件的数量,达到限制时以状态 0 退出。如果也与 -C 一起使用,该行为将导致每个时间片循环文件。

       -x 解析和打印时,除了打印每个数据包的头之外,还要以十六进制打印每个数据包的数据(减去其链接级头)。将打印整个数据包或 snaplen 字节中较小的一个。请注意,这是整个
              链路层数据包,因此对于填充的链路层(例如以太网),当更高层数据包比所需的填充短时,也会打印填充字节。

       -xx 解析打印时,除了打印每个数据包的头部外,还要打印每个数据包的数据,包括其链接级头部,以十六进制表示。

       -X 解析和打印时,除了打印每个数据包的头之外,还要以十六进制和 ASCII 打印每个数据包的数据(减去其链接级头)。这对于分析新协议非常方便。

       -XX 解析打印的时候,除了打印每个包的header,还要打印每个包的数据,包括它的link level header,以hex和ASCII的形式。

       -y
       datalinktype --linktype=datalinktype
              将捕获数据包时使用的数据链路类型设置为datalinktype 。

       -z postrotate-command
              与 -C 或 -G 选项结合使用,这将使 tcpdump 运行“ postrotate-command file ”,其中 file 是每次旋转后关闭的保存文件。例如,指定 -z gzip 或 -z bzip2 将使用 gzip 或
              bzip2压缩每个保存文件。

              请注意,tcpdump 将与捕获并行运行命令,使用最低优先级,以便这不会干扰捕获过程。

              如果你想使用一个本身带有标志或不同参数的命令,你总是可以编写一个 shell 脚本,它将保存文件名作为唯一参数,进行标志和参数安排并执行
              你想要的命令。

       -Z user
       --relinquish-privileges=user
              如果 tcpdump 以 root 身份运行,在打开捕获设备或输入保存文件之后,但在打开任何保存文件进行输出之前,将用户 ID 更改为 user,将组 ID 更改为用户的主要组.

              此行为也可以在编译时默认启用。

        表达式
              选择将转储的数据包。如果没有给出表达式,则网络上的所有数据包都将被转储。否则,只会转储表达式为“true”的数据包。

              有关表达式语法,请参阅 pcap-filter(7)。

              表达式参数可以作为单个 Shell 参数或多个 Shell 参数传递给 tcpdump,以更方便的方式传递。通常,如果表达式包含 Shell 元字符,例如用于转义协议
              名称的反斜杠,则将其作为单个带引号的参数传递而不是转义 Shell 元字符会更容易。多个参数在解析之前用空格连接。

示例
       打印所有到达或离开日落的数据包:
              tcpdump host sundown

       要打印 helios 和 hot 或 ace 之间的流量:
              tcpdump host helios 和ħ ö吨ö ř一个Ç ëH这吨这r一个C和

       要打印 ace 和除 helios 之外的任何主机之间的所有 IP 数据包:
              tcpdump ip host ace 而不是 helios

       打印本地主机和伯克利主机之间的所有流量:
              tcpdump net ucb-ether

       要通过 Internet 网关 snup 打印所有 ftp 流量:(注意引用该表达式是为了防止 shell(错误)解释括号):
              tcpdump 'gateway snup and (port ftp or ftp-data)'

       打印既不是来自本地主机也不是本地主机的流量(如果你连接到另一个网络,这些东西永远不应该进入你的本地网络)。
              tcpdump ip 而不是 net localnet

       打印涉及非本地主机的每个 TCP 会话的开始和结束数据包(SYN 和 FIN 数据包)。
              tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 而不是 src 和 dst net localnet'

       打印所有进出端口 80 的 IPv4 HTTP 数据包,即仅打印包含数据的数据包,而不是,例如,SYN 和 FIN 数据包以及仅 ACK 数据包。(IPv6 留给读者作为练习。)
              tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0) >>2)) != 0)'

       打印通过网关 snup 发送的超过 576 字节的 IP 数据包:
              tcpdump 'gateway snup and ip[2:2] > 576'

       打印不是通过以太网广播或多播发送的 IP 广播或多播数据包:
              tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'

       要打印所有不是回显请求/回复的 ICMP 数据包(即,不是 ping 数据包):
              tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply'

输出格式
       tcpdump 的输出取决于协议。下面给出了大多数格式的简要说明和示例。

       时间戳

       默认情况下,所有输出行前面都有时间戳。时间戳是采用
              hh:mm:ss.frac形式的当前时钟时间,
       与内核时钟一样准确。时间戳反映内核对数据包应用时间戳的时间。没有尝试考虑网络接口完成从网络接收数据包到
       内核对数据包应用时间戳之间的时间延迟;该时间延迟可能包括网络接口完成从网络接收数据包的时间与将中断传递给内核以使其读取之间的延迟
       数据包和内核服务“新数据包”中断的时间和它对数据包应用时间戳的时间之间的延迟。

       链路级标头

       如果给出了 '-e' 选项,则打印出链接级标题。在以太网上,会打印源地址和目标地址、协议和数据包长度。

       在 FDDI 网络上,“-e”选项使 tcpdump 打印“帧控制”字段、源地址和目标地址以及数据包长度。(“帧控制”字段控制对数据包其余部分的解释。正常数据包(例如
       那些包含 IP 数据报的数据包)是“异步”数据包,优先级值在 0 到 7 之间;例如,“async4”。这样的假定数据包包含 802.2 逻辑链路控制 (LLC) 数据包;如果它不是 ISO 数据报或
       所谓的 SNAP 数据包,则打印 LLC 标头。

       在令牌环网络上,“-e”选项使 tcpdump 打印“访问控制”和“帧控制”字段、源地址和目标地址以及数据包长度。在 FDDI 网络上,假定数据包包含 LLC 数据包。无论
       是否指定了 '-e' 选项,都会为源路由数据包打印源路由信息。

       在 802.11 网络上,“-e”选项会导致 tcpdump 打印“帧控制”字段、802.11 标头中的所有地址以及数据包长度。在 FDDI 网络上,假定数据包包含 LLC 数据包。

       (注意:以下描述假设您熟悉 RFC-1144 中描述的 SLIP 压缩算法。)

       在 SLIP 链路上,打印出方向指示符(“I”表示入站,“O”表示出站)、数据包类型和压缩信息。首先打印数据包类型。这三种类型是 ip、utcp 和 ctcp。不会为
       ip 数据包打印更多链接信息。对于 TCP 数据包,连接标识符打印在类型之后。如果数据包被压缩,它的编码头被打印出来。特殊情况打印为 *S+n 和 *SA+n,其中 n 是序列号
       (或序列号和 ack)改变的数量。如果不是特殊情况,则打印零个或多个更改。变化由 U(紧急指针)、W(窗口)、A(确认)、S(序列号)和 I(数据包 ID)表示,后跟一个增量(+n 或 -n),或一个新的
       值 (=n)。最后,打印数据包中的数据量和压缩包头长度。

       例如,下面这行显示了一个出站的压缩 TCP 数据包,带有隐式连接标识符;ack变了6,序号变了49,包ID变了6;有 3 个字节的数据和 6 个字节的压缩头:
              O ctcp * A+6 S+49 I+6 3 (6)

       ARP/RARP 数据包

       Arp/rarp 输出显示请求的类型及其参数。该格式旨在是不言自明的。下面是一个`rlogin的开始从主机RTSG采取以主机CSAM一个简短的样本:
              ARP谁,有CSAM告诉RTSG
              ARP应答CSAM是,在CSAM
       第一行说,RTSG发送一个ARP包,询问以太网地址的互联网主机 csam。Csam 回复其以太网地址(在此示例中,以太网地址以大写字母表示,互联网地址以小写字母表示)。

       如果我们执行了 tcpdump -n:
              arp who-has 128.3.254.6 tell 128.3.254.68
              arp reply 128.3.254.6 is-at 02:07:01:00:01:c4,这看起来就不那么多余了

       如果我们执行了 tcpdump -e,那么第一个数据包是广播的,第二个数据包是点对点的,这一事实将是可见的:
              RTSG Broadcast 0806 64: arp who-has csam tell rtsg
              CSAM RTSG 0806 64: arp reply csam is -at CSAM
       对于第一个数据包,它表示以太网源地址是 RTSG,目标是以太网广播地址,类型字段包含十六进制 0806(类型 ETHER_ARP),总长度为 64 字节。

       IPv4 数据包

       如果没有打印链路层报头,对于 IPv4 数据包,IP 打印在时间戳之后。

       如果指定了 -v 标志,则来自 IPv4 标头的信息显示在 IP 或链路层标头之后的括号中。这个信息的一般格式是:
              tos tos, ttl ttl, id id, offset offset, flags [flags], proto proto, length length, options(options)
       tos是服务字段的类型;如果 ECN 位非零,则报告为 ECT(1)、ECT(0) 或 CE。ttl 是生存时间;如果为零则不报告。id 是 IP 标识字段。offset 是片段偏移字段;它被打印
       这是否是碎片数据报的一部分。flags 是 MF 和 DF 标志;如果设置了MF,则报告+,如果设置了F,则报告DFP。如果两者都没有设置, . 被报道。proto 是协议 ID 字段。length 是总长度字段。
       options 是 IP 选项,如果有的话。

       接下来,对于 TCP 和 UDP 数据包,将打印源 IP 地址和目标 IP 地址以及 TCP 或 UDP 端口,每个 IP 地址与其对应的端口之间有一个点,用 > 分隔源和目标。对于其他协议,
       将打印地址,用 > 分隔源和目标。之后将打印更高级别的协议信息(如果有)。

       对于分片的 IP 数据报,第一个分片包含更高级别的协议头;第一个之后的片段不包含更高级别的协议头。
       如上所述,分片信息将仅与 -v 标志一起打印在 IP 标头信息中。

       TCP数据包

       (注意:以下描述假设您熟悉 RFC-793 中描述的 TCP 协议。如果您不熟悉该协议,则此描述对您没有多大用处。)

       TCP协议行的一般格式是:
              src > dst: Flags [tcpflags], seq data-seqno, ack ackno, win window, urg Emergency, options [opts], length len
       src和dst是源IP地址和目的IP地址和端口。Tcpflags 是 S (SYN)、F (FIN)、P (PUSH)、R (RST)、U (URG)、W (ECN CWR)、E (ECN-Echo) 或 `.' 的某种组合。(ACK),如果没有设置标志,则为“none”。Data-seqno 描述了
       这个包中的数据所覆盖的序列空间部分(见下面的例子)。Ackno 是下一个数据的序列号,预期在此连接上的另一个方向。Window 是另一个方向上可用的接收缓冲区空间的字节数
       联系。Urg 表示数据包中有“紧急”数据。选项是 TCP 选项(例如,mss 1024)。Len 是有效载荷数据的长度。

       Iptype、Src、dst 和标志始终存在。其他字段取决于数据包的 TCP 协议标头的内容,并且仅在适当时输出。

       这是从主机 rtsg 到主机 csam 的 rlogin 的开头部分。
              IP rtsg.1023 > csam.login: Flags [S], seq 768512:768512, win 4096, opts [mss 1024]
              IP csam.login > rtsg.1023: Flags [S.], seq8:9473644 , win 4096, opts [mss 1024]
              IP rtsg.1023 > csam.login: Flags [.], ack 1, win 4096
              IP rtsg.1023 > csam.login: Flags [P.], seq 1:2, ack 1 , win 4096, length 1
              IP csam.login > rtsg.1023: Flags [.], ack 2, win 4096
              IP rtsg.1023 > csam.login: Flags [P.], seq 2:21, ack 1, win 4096 , 长度 19
              IP csam.login > rtsg.1023: Flags [P.], seq 1:2, ack 21, win 4077, length 1
              IP csam.login > rtsg.1023: Flags [P.], seq 2:3, ack 21, win 4077, urg 1, length 1
              IP csam.login > rtsg.1023: Flags [P.], seq 3:4 , ack 21, win 4077, urg 1, length 1
       第一行说rtsg上的TCP端口1023发送了一个数据包到csam上的登录端口。S 表示设置了 SYN 标志。数据包序列号为 768512,其中不包含任何数据。(符号是“first:last”,意思是“序列号
       先到但不包括最后。)没有捎带确认,可用的接收窗口是 4096 字节,并且有一个 max-segment-size 选项请求一个1024 字节的 mss。

       Csam 回复了一个类似的数据包,除了它包含一个对 rtsg 的 SYN 的捎带确认。Rtsg 然后确认 csam 的 SYN。'.' 表示设置了 ACK 标志。数据包不包含数据,因此没有数据序列号或长度。请注意,ack
       序列号是一个小整数(1)。tcpdump 第一次看到 TCP 的“对话”时,它会打印数据包中的序列号。在对话的后续数据包上,
       打印当前数据包的序列号和这个初始序列号之间的差异。这意味着第一个之后的序列号可以解释为对话数据流中的相对字节位置(每个方向的第一个数据字节为“1”)。`-S' 会覆盖这个特性,因为
       输入要输出的原始序列号。

       在第 6 行,rtsg 向 csam 发送 19 个字节的数据(对话的 rtsg → csam 一侧的字节 2 到 20)。PUSH 标志在数据包中设置。在第 7 行,csam 说它接收到 rtsg 发送的数据,但不包括字节 21。
       由于 csam 的接收窗口变小了 19 个字节,因此大部分数据显然位于套接字缓冲区中。Csam 还在此数据包中向 rtsg 发送一个字节的数据。在第 8 行和第 9 行,csam 将两个字节的紧急推送数据发送到 rtsg。

       如果快照足够小以至于 tcpdump 没有捕获完整的 TCP 标头,它会尽可能多地解释标头,然后报告“[|tcp]”以指示无法解释其余部分。如果标头包含一个虚假选项(一个
       长度太小或超出标头末尾的选项),tcpdump 会将其报告为“[bad opt]”并且不解释任何进一步的选项(因为无法分辨)他们开始的地方)。如果报头长度指示选项存在,但
       IP 数据报长度不足以使选项实际存在,tcpdump 将其报告为“[bad hdr length]”。

       捕获具有特定标志组合(SYN-ACK、URG-ACK 等)的 TCP 数据包

       TCP 报头的控制位部分有 8 位:

              CWR | 欧洲经委会 URG | 确认 | PSH | RST | 同步 | 鳍

       让我们假设我们要观察用于建立 TCP 连接的数据包。回想一下,TCP 在初始化新连接时使用了 3 次握手协议;TCP 控制位的连接顺序是

              1) 呼叫方发送 SYN
              2) 接收方用 SYN、ACK 响应
              3) 呼叫方发送 ACK

       现在我们对捕获仅设置了 SYN 位的数据包感兴趣(步骤 1)。请注意,我们不想要来自第 2 步(SYN-ACK)的数据包,只需要一个普通的初始 SYN。我们需要的是一个正确的 tcpdump 过滤表达式。

       回想一下没有选项的 TCP 标头的结构:

        0 15 31
       ----------------------------------------------- ------------------
       | 源端口 | 目的港|
       -------------------------------------------------- ---------------
       | 序号 |
       -------------------------------------------------- ---------------
       | 确认编号 |
       -------------------------------------------------- ---------------
       | HL | rsvd |C|E|U|A|P|R|S|F| 窗口大小|
       -------------------------------------------------- ---------------
       | TCP校验和| 紧急指针|
       -------------------------------------------------- ---------------

       除非存在选项,否则 TCP 标头通常包含 20 个八位字节的数据。该图的第一行包含八位字节 0 - 3,第二行显示八位字节 4 - 7 等。

       从 0 开始计数,相关的 TCP 控制位包含在八位字节 13 中:

        0 7| 15| 23| 31
       ---------------- | --------------- | --------------- | ----------------
       | HL | rsvd |C|E|U|A|P|R|S|F| 窗口大小|
       ----------------|---------------|--------------|- ---------------
       | | 第 13 个八位字节 | | |

       让我们仔细看看八位字节号。13:

                       | |
                       |---------------|
                       |C|E|U|A|P|R|S|F|
                       |---------------|
                       |7 5 3 0|

       这些是我们感兴趣的 TCP 控制位。 我们将这个八位字节中的位从 0 到 7,从右到左编号,所以 PSH 位是第 3 位,而 URG 位是第 5 位。

       回想一下,我们只想捕获设置了 SYN 的数据包。让我们看看如果 TCP 数据报到达时在其报头中设置了 SYN 位,八位字节 13 会发生什么:

                       |C|E|U|A|P|R|S|F|
                       |---------------|
                       |0 0 0 0 0 0 1 0|
                       |---------------|
                       |7 6 5 4 3 2 1 0|

       查看控制位部分,我们看到仅设置了位号 1 (SYN)。

       假设八位字节数 13 是一个网络字节序的 8 位无符号整数,这个八位字节的二进制值为

              00000010

       它的十进制表示是

          7     6     5     4     3     2     1     0
       0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2  =  2

       我们差不多完成了,因为现在我们知道如果只设置了 SYN,则 TCP 标头中的第 13 个八位字节的值,当解释为网络字节顺序中的 8 位无符号整数时,必须正好是 2。

       这种关系可以表示为
              tcp[13] == 2

       我们可以使用这个表达式作为 tcpdump 的过滤器来观察只有 SYN 设置的数据包:
              tcpdump -i xl0 tcp[13] == 2

       表达式说“让 TCP 数据报的第 13 个八位字节具有十进制值 2”,这正是我们想要的。

       现在,让我们假设我们需要捕获 SYN 数据包,但我们不关心是否同时设置了 ACK 或任何其他 TCP 控制位。让我们看看当带有 SYN-ACK 集的 TCP 数据报到达时,八位字节 13 会发生什么:

            |C|E|U|A|P|R|S|F|
            |---------------|
            |0 0 0 1 0 0 1 0|
            |---------------|
            |7 6 5 4 3 2 1 0|

       现在位 1 和 4 设置在第 13 个八位字节中。八位字节 13 的二进制值是

                   00010010

       转换为十进制

          7     6     5     4     3     2     1     0
       0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2   = 18

       现在我们不能在 tcpdump 过滤器表达式中只使用 'tcp[13] == 18',因为这将只选择那些设置了 SYN-ACK 的数据包,而不是那些只设置了 SYN 的数据包。请记住,只要
       设置了SYN,我们就不关心是否设置了 ACK 或任何其他控制位。

       为了实现我们的目标,我们需要将八位字节 13 的二进制值与其他值进行逻辑与运算,以保留 SYN 位。我们知道我们希望在任何情况下都设置 SYN,因此我们将第 13 个八位字节中的值与
       SYN的二进制值进行逻辑与运算:

                 00010010 SYN-ACK 00000010 SYN
            AND 00000010(我们想要SYN)AND 00000010(我们想要SYN)
                 -------- --------
            = 00000010 = 00000010

       我们看到,无论是否设置了 ACK 或另一个 TCP 控制位,此 AND 操作都会产生相同的结果。AND 值的十进制表示以及此操作的结果是 2(二进制 00000010),因此我们知道对于
       设置了 SYN 的数据包,以下关系必须成立:

              ( (八位字节 13 的值) AND ( 2 ) ) == ( 2 )

       这将我们指向 tcpdump 过滤器表达式
                   tcpdump -i xl0 'tcp[13] & 2 == 2'

       某些偏移量和字段值可以表示为名称而不是数字值。例如,tcp[13] 可以替换为 tcp[tcpflags]。以下 TCP 标志字段值也可用:tcp-fin、tcp-syn、tcp-rst、tcp-push、tcp-act、tcp-urg。

       这可以证明为:
                   tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0'

       请注意,您应该在表达式中使用单引号或反斜杠来隐藏 shell 中的 AND ('&') 特殊字符。

       UDP数据包

       UDP 格式由这个 rwho 数据包说明:
              actinide.who > broadcast.who: udp 84
       这表示主机 actinide 上的端口 who 发送了一个 udp 数据报到主机上广播的端口 who ,即 Internet 广播地址。该数据包包含 84 字节的用户数据。

       某些 UDP 服务被识别(从源或目标端口号)并打印更高级别的协议信息。特别是对 NFS 的域名服务请求 (RFC-1034/1035) 和 Sun RPC 调用 (RFC-1050)。

       UDP 名称服务器请求

       (注意:以下描述假设您熟悉 RFC-1035 中描述的域服务协议。如果您不熟悉该协议,则以下描述似乎是用希腊语编写的。)

       名称服务器请求的格式为
              src > dst: id op? 标志 qtype qclass 名称 (len)
              h2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu。(37)
       主机 h2opolo 向 helios 上的域服务器询问与名称 ucbvax.berkeley.edu 相关联的地址记录 (qtype=A)。查询 ID 为“3”。“+”表示设置了递归期望标志。查询长度为 37 字节,不包括 UDP
       和 IP 协议头。查询操作是正常的查询操作,因此省略了 op 字段。如果 op 是其他任何东西,它将被打印在“3”和“+”之间。同样,qclass 是正常的,C_IN,并被省略。
       任何其他 qclass 都会在“A”之后立即打印。

       检查一些异常并可能导致包含在方括号中的额外字段:如果查询包含答案、规范记录或附加记录部分、ancount、nscount 或 arcount 打印为“[na]”、“[nn]”或“[nau]”,其中 n 是
       适当的计数。如果设置了任何响应位(AA、RA 或 rcode)或在字节 2 和 3 中设置了任何“必须为零”位,则打印“[b2&3=x]”,其中 x 是头字节二和三。

       UDP 名称服务器响应

       名称服务器响应的格式为
              src > dst: id op rcode flags a/n/au type class data (len)
              helios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
              helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)
       在第一个示例中,helios 使用 3 个回答记录、3 个名称服务器记录和 7 个附加记录响应来自 h2opolo 的查询 ID 3。第一个应答记录类型为 A(地址),其数据为 Internet 地址 128.32.137.3。
       响应的总大小为 273 字节,不包括 UDP 和 IP 标头。省略了操作(查询)和响应代码(NoError),以及 A 记录的类(C_IN)。

       在第二个示例中,helios 使用不存在域 (NXDomain) 的响应代码响应查询 2,没有答案、一个名称服务器且没有权限记录。“*”表示设置了权威回答位。因为没有答案,所以
       没有打印类型、类或数据。

       其他可能出现的标志字符是“-”(递归可用,RA,未设置)和“|” (截断的消息,TC,设置)。如果 `question' 部分不包含一个条目,则打印 `[nq]'。

       SMB/CIFS 解码

       tcpdump 现在包括相当广泛的 SMB/CIFS/NBT 解码,用于 UDP/137、UDP/138 和 TCP/139 上的数据。还完成了 IPX 和 NetBEUI SMB 数据的一些原始解码。

       默认情况下,完成了相当少的解码,如果使用 -v 则完成更详细的解码。请注意,使用 -va 单个 SMB 数据包可能会占用一页或更多页,因此只有在您真的想要所有详细信息时才使用 -v。

       有关 SMB 数据包格式和所有字段含义的信息,请参见 www.cifs.org 或您最喜欢的 samba.org 镜像站点上的 pub/samba/specs/ 目录。SMB 补丁由 Andrew Tridgell ([email protected]) 编写。

       NFS 请求和回复

       Sun NFS(网络文件系统)请求和回复打印为:
              src.sport > dst.nfs: NFS request xid xid len op args
              src.nfs > dst.dport: NFS reply xid xid reply stat len op
              resultsushi.1023 > wrl.nfs:NFS 请求 xid 26377
                   112 readlink fh 21,24/10.73165
              wrl.nfs>sushi.1023:NFS 回复 xid 26377
                   回复 ok 40 readlink "
              ../var"sushi.1022 > wrl.nfs: wrl.nfs:
                   144 查找 fh 9,74/4096.6878 "xcolors"
              wrl.nfs > sushi.1022:NFS 回复 xid 8219
                   回复正常 128 查找 fh 9,74/4134.3150
       在第一行,主机sushi 向wrl 发送一个id 为26377 的事务。请求为 112 字节,不包括 UDP 和 IP 标头。该操作是对文件句柄 (fh) 21,24/10.731657119 的读取链接(读取符号链接)。(如果幸运的话,在这种
       情况下,文件句柄可以解释为一个主次设备号对,后跟 inode 号和生成号。)在第二行中,wrl 用相同的事务回复“ok” id 和链接的内容。

       在第三行中,sushi 要求(使用新的事务 ID)wrl 在目录文件 9,74/4096.6878 中查找名称“xcolors”。在第四行中,wrl 发送带有相应事务 ID 的回复。

       请注意,打印的数据取决于操作类型。如果与 NFS 协议规范一起阅读,则该格式旨在是不言自明的。另请注意,旧版本的 tcpdump 以稍微不同的格式打印 NFS 数据包:
       将打印事务 ID (xid) 而不是数据包的非 NFS 端口号。

       如果给出 -v(详细)标志,则打印附加信息。例如:
              sushi.1023 > wrl.nfs: NFS request xid 79658
                   148 read fh 21,11/12.195 8192 bytes @ 24576
              wrl.nfs >sushi.1023: NFS 回复 xid 79658
                   回复 ok 141706 REG14706 z 读取29388
       (-v 还打印 IP 标头 TTL、ID、长度和分段字段,在本示例中已省略。)在第一行中,sushi 要求 wrl 从文件 21,11/12.195 中读取 8192 个字节,位于字节偏移量 24576。Wrl 回复“ok”;显示的数据包
       第二行是回复的第一个片段,因此只有 1472 字节长(其他字节将跟随在后续片段中,但这些片段没有 NFS 甚至 UDP 标头,因此可能不会打印,具体取决于过滤器使用的表达式
       )。因为给出了 -v 标志,所以会打印一些文件属性(除了文件数据之外还返回):文件类型(“REG”,对于常规文件)、文件模式(八进制)、 uid 和 gid 以及文件大小。

       如果多次给出 -v 标志,则会打印更多详细信息。

       请注意,NFS 请求非常大,除非增加 snaplen,否则不会打印大部分细节。尝试使用 `-s 192' 来观察 NFS 流量。

       NFS 回复数据包不明确标识 RPC 操作。相反,tcpdump 会跟踪“最近”的请求,并使用事务 ID 将它们与回复进行匹配。如果回复没有紧跟相应的请求,则可能无法
       解析。

       AFS 请求和回复

       Transarc AFS(安德鲁文件系统)请求和回复打印为:

              src.sport > dst.dport: rx packet-type
              src.sport > dst.dport: rx packet-type service call call-name args
              src.sport > dst.dport: rx packet-type service reply call-name args
              elvis。 7001> pike.afsfs:
                   RX数据FS叫命名旧裂536876964/1/1 “.newsrc.new”
                   新裂536876964/1/1 “.newsrc”
              pike.afsfs> elvis.7001:RX数据FS回复命名
       在第一行,主机 elvis 向 pike 发送一个 RX 数据包。这是到 fs(文件服务器)服务的 RX 数据包,并且是 RPC 调用的开始。RPC 调用是重命名,旧目录文件 ID 为 536876964/1/1,旧文件名
       `.newsrc.new',以及一个新的目录文件 id 536876964/1/1 和一个新的文件名 `.newsrc'。主机 pike 以对重命名调用的 RPC 回复进行响应(这是成功的,因为它是一个数据包而不是一个中止包)。

       通常,所有 AFS RPC 都至少通过 RPC 调用名称进行解码。大多数 AFS RPC 至少解码了一些参数(通常只有“有趣的”参数,对于一些有趣的定义)。

       该格式旨在用于自我描述,但对于不熟悉 AFS 和 RX 工作原理的人来说,它可能没有用处。

       如果 -v(详细)标志被给出两次,确认数据包和附加的头信息被打印出来,例如 RX 呼叫 ID、呼叫号码、序列号、序列号和 RX 数据包标志。

       如果 -v 标志给出两次,则会打印附加信息,例如 RX 呼叫 ID、序列号和 RX 数据包标志。MTU 协商信息也从 RX ack 数据包中打印出来。

       如果 -v 标志被给出 3 次,则打印安全索引和服务 ID。

       为中止数据包打印错误代码,但 Ubik 信标数据包除外(因为中止数据包用于表示对 Ubik 协议的赞成票)。

       请注意,AFS 请求非常大,除非增加 snaplen,否则不会打印许多参数。尝试使用 `-s 256' 来观察 AFS 流量。

       AFS 回复数据包不明确标识 RPC 操作。相反,tcpdump 会跟踪“最近”的请求,并使用呼叫号码和服务 ID 将它们与回复进行匹配。如果回复没有紧跟相应的请求,则
       可能无法解析。

       KIP AppleTalk(UDP 中的 DDP)

       封装在UDP 数据报中的AppleTalk DDP 数据包被解封装并转储为DDP 数据包(即丢弃所有UDP 报头信息)。文件 /etc/atalk.names 用于将 AppleTalk 网络和节点编号转换为名称。此
       文件中的行具有表单
              编号名称

              1.254 ether
              16.1 icsd-net
              1.254.110 ace
       前两行给出了 AppleTalk 网络的名称。第三行给出了特定主机的名称(主机与网络的区别在于数字中的第三个八位字节 - 网络号必须有两个八位字节,主机号必须有三个八位字节。)
       数字和名称应该分开按空格(空格或制表符)。/etc/atalk.names 文件可能包含空行或注释行(以“#”开头的行)。

       AppleTalk 地址以
              net.host.port形式打印

              144.1.209.2 > icsd-net.112.220 office.2
              > icsd-net.112.220
              jssmag.149.235 > icsd-net.2
       (如果 /etc/atalk.names 不存在或不包含某些 AppleTalk 的条目主机/网络号,地址以数字形式打印。)在第一个示例中,网络 144.1 节点 209 上的 NBP(DDP 端口 2)正在发送到正在侦听
       网络 icsd 节点 112 的端口 220 的任何对象。第二行是相同的除了源节点的全名是已知的(“办公室”)。第三行是从net jssmag节点149上的235端口发送到icsd-net NBP端口广播(注意广播地址(255)是
       由没有主机号的网络名称表示 - 因此,最好在 /etc/atalk.names 中保持节点名称和网络名称不同)。

       NBP(名称绑定协议)和 ATP(AppleTalk 事务协议)数据包的内容被解释。其他协议只是转储协议名称(如果没有为协议注册名称,则为数字)和数据包大小。

       NBP 数据包的格式如下例:
              icsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
              jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter @*" 250
              techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186
       第一行是由net icsd host 112发送并在net jssmag上广播的laserwriters的名称查找请求。用于查找的 nbp id 是 190。第二行显示来自主机 jssmag.209 的此请求的回复(请注意,它具有相同的 id)说它
       在端口 250 上注册了一个名为“RM1140”的激光写入器资源。

       ATP 数据包格式由以下示例演示:
              jssmag.209.165 > helios.132: atp-req 12266<0-7> 0xae030001
              helios.132 > jssmag.209.165: atp-resp 12266:0 (510040s.0 (
              51004001 )) jssmag.209.165: atp-resp 12266:1 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:2 (512) 0xae040000
              helios.16250x040000 helios.162000 helios.162500000000000000000000000000000000000000000000000000000000000
              helios.132> jssmag.209.165:ATP-RESP 12266:4(512)0xae040000
              helios.132> jssmag.209.165:ATP-RESP 12266:5(512)0xae040000
              helios.132> jssmag.209.165:ATP-RESP 12266:6 (512) 0xae040000
              helios.132> jssmag.209.165:ATP-RESP * 12266:7(512)0xae040000
              jssmag.209.165> helios.132:ATP-REQ 12266 <3,5> 0xae030001
              helios.132> jssmag.209.165:ATP-RESP 12266: 3(512)0xae040000
              helios.132> jssmag.209.165:ATP-RESP 12266:5(512)0xae040000
              jssmag.209.165> helios.132:ATP-REL 12266 <0-7> 0xae030001
              jssmag.209.133> helios.132:ATP -req* 12267<0-7> 0xae030002
       Jssmag.209 通过请求最多 8 个数据包(“<0-7>”)来启动与主机 helios 的事务 ID 12266。行尾的十六进制数是请求中“userdata”字段的值。

       Helios 以 8 个 512 字节的数据包响应。事务 id 后面的 `:digit' 给出了事务中的数据包序列号,括号中的数字是数据包中的数据量,不包括 atp 头。数据包 7 上的“*”表示
       EOM 位已设置。

       Jssmag.209 然后请求重新传输数据包 3 和 5。Helios 重新发送它们,然后 jssmag.209 释放交易。最后jssmag.209发起下一个请求。请求中的“*”表示未设置 XO(“恰好一次”)。


       另请参见stty(1)、pcap(3PCAP)、bpf(4)、nit(4P)、pcap-savefile(5)、pcap-filter(7)、pcap-tstamp(7)、apparmor(7)

              http://www.iana.org/assignments/media-types/application/vnd.tcpdump.pcap

作者
       原作者是:

       Van Jacobson、Craig Leres 和 Steven McCanne,加州大学伯克利分校劳伦斯伯克利国家实验室的所有成员。

       它目前由 tcpdump.org 维护。

       当前版本可通过 http:

              https://www.tcpdump.org/

       原始发行版可通过匿名 ftp 获得:

              ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z

       WIDE/KAME 项目添加了 IPv6/IPsec 支持。该程序在特定配置下使用 Eric Young 的 SSLeay 库。

BUGS
       要报告安全问题,请发送电子邮件至 [email protected]。

       要报告错误和其他问题、提供补丁、请求功能、提供通用反馈等,请参阅 tcpdump 源代码树根目录中的文件 CONTRIBUTING。

       NIT 不会让您查看自己的出站流量,BPF 会。我们建议您使用后者。

       在具有 2.0[.x] 内核的 Linux 系统上:

              环回设备上的数据包将被看到两次;

              包过滤无法在内核中进行,因此所有包必须从内核中复制才能在用户模式下进行过滤;

              所有数据包,而不仅仅是快照长度内的部分,将从内核复制(2.0[.x] 数据包捕获机制,如果要求仅将数据包的一部分复制到用户空间,将不会报告真实长度数据包;这将
              导致大多数 IP 数据包从 tcpdump 中获取错误);

              在某些 PPP 设备上捕获将无法正常工作。

       我们建议您升级到 2.2 或更高版本的内核。

       应该尝试重新组装 IP 片段,或者至少为更高级别的协议计算正确的长度。

       名称服务器反向查询未正确转储:打印(空)问题部分而不是答案部分中的真实查询。有些人认为反向查询本身就是一个错误,并且更愿意修复生成它们的程序而不是
       tcpdump。

       跨越夏令时更改的数据包跟踪将提供倾斜的时间戳(忽略时间更改)。

       除令牌环标头中的字段之外的字段上的过滤器表达式将无法正确处理源路由令牌环数据包。

       除 802.11 标头中的字段以外的字段上的过滤器表达式将无法正确处理设置了 To DS 和 From DS 的 802.11 数据包。

       ip6 proto 应该追逐头链,但此时它没有。为这种行为提供了 ip6 protochain。

       针对传输层标头的算术表达式,如 tcp[0],不适用于 IPv6 数据包。它只查看 IPv4 数据包。

英文原文

NAME
       tcpdump - dump traffic on a network

SYNOPSIS
       tcpdump [ -AbdDefhHIJKlLnNOpqStuUvxX# ] [ -B buffer_size ]
               [ -c count ]
               [ -C file_size ] [ -G rotate_seconds ] [ -F file ]
               [ -i interface ] [ -j tstamp_type ] [ -m module ] [ -M secret ]
               [ --number ] [ -Q in|out|inout ]
               [ -r file ] [ -V file ] [ -s snaplen ] [ -T type ] [ -w file ]
               [ -W filecount ]
               [ -E spi@ipaddr algo:secret,...  ]
               [ -y datalinktype ] [ -z postrotate-command ] [ -Z user ]
               [ --time-stamp-precision=tstamp_precision ]
               [ --immediate-mode ] [ --version ]
               [ expression ]

DESCRIPTION
       Tcpdump  prints  out  a description of the contents of packets on a network interface that match the boolean expression; the description is preceded by a time stamp, printed, by default, as hours, minutes, seconds, and fractions of a second since midnight.
       It can also be run with the -w flag, which causes it to save the packet data to a file for later analysis, and/or with the -r flag, which causes it to read from a saved packet file rather than to read packets from a network interface (please  note  tcpdump
       is  protected  via  an  enforcing apparmor(7) profile in Ubuntu which limits the files tcpdump may access).  It can also be run with the -V flag, which causes it to read a list of saved packet files. In all cases, only packets that match expression will be
       processed by tcpdump.

       Tcpdump will, if not run with the -c flag, continue capturing packets until it is interrupted by a SIGINT signal (generated, for example, by typing your interrupt character, typically control-C) or a SIGTERM signal (typically  generated  with  the  kill(1)
       command); if run with the -c flag, it will capture packets until it is interrupted by a SIGINT or SIGTERM signal or the specified number of packets have been processed.

       When tcpdump finishes capturing packets, it will report counts of:

              packets ``captured'' (this is the number of packets that tcpdump has received and processed);

              packets  ``received  by  filter''  (the  meaning  of  this depends on the OS on which you're running tcpdump, and possibly on the way the OS was configured - if a filter was specified on the command line, on some OSes it counts packets regardless of
              whether they were matched by the filter expression and, even if they were matched by the filter expression, regardless of whether tcpdump has read and processed them yet, on other OSes it counts only packets that were matched by the  filter  expres‐
              sion regardless of whether tcpdump has read and processed them yet, and on other OSes it counts only packets that were matched by the filter expression and were processed by tcpdump);

              packets ``dropped by kernel'' (this is the number of packets that were dropped, due to a lack of buffer space, by the packet capture mechanism in the OS on which tcpdump is running, if the OS reports that information to applications; if not, it will
              be reported as 0).

       On platforms that support the SIGINFO signal, such as most BSDs (including Mac OS X) and Digital/Tru64 UNIX, it will report those counts when it receives a SIGINFO signal (generated, for example, by typing your ``status''  character,  typically  control-T,
       although  on  some  platforms,  such  as Mac OS X, the ``status'' character is not set by default, so you must set it with stty(1) in order to use it) and will continue capturing packets. On platforms that do not support the SIGINFO signal, the same can be
       achieved by using the SIGUSR1 signal.

       Reading packets from a network interface may require that you have special privileges; see the pcap (3PCAP) man page for details.  Reading a saved packet file doesn't require special privileges.

OPTIONS
       -A     Print each packet (minus its link level header) in ASCII.  Handy for capturing web pages.

       -b     Print the AS number in BGP packets in ASDOT notation rather than ASPLAIN notation.

       -B buffer_size
       --buffer-size=buffer_size
              Set the operating system capture buffer size to buffer_size, in units of KiB (1024 bytes).

       -c count
              Exit after receiving count packets.

       -C file_size
              Before writing a raw packet to a savefile, check whether the file is currently larger than file_size and, if so, close the current savefile and open a new one.  Savefiles after the first savefile will have the name specified with the -w flag, with a
              number after it, starting at 1 and continuing upward.  The units of file_size are millions of bytes (1,000,000 bytes, not 1,048,576 bytes).

       -d     Dump the compiled packet-matching code in a human readable form to standard output and stop.

       -dd    Dump packet-matching code as a C program fragment.

       -ddd   Dump packet-matching code as decimal numbers (preceded with a count).

       -D
       --list-interfaces
              Print the list of the network interfaces available on the system and on which tcpdump can capture packets.  For each network interface, a number and an interface name, possibly followed by a text description of the interface, is printed.  The inter‐
              face name or the number can be supplied to the -i flag to specify an interface on which to capture.

              This can be useful on systems that don't have a command to list them (e.g., Windows systems, or UNIX systems lacking ifconfig -a); the number can be useful on Windows 2000 and later systems, where the interface name is a somewhat complex string.

              The -D flag will not be supported if tcpdump was built with an older version of libpcap that lacks the pcap_findalldevs() function.

       -e     Print the link-level header on each dump line.  This can be used, for example, to print MAC layer addresses for protocols such as Ethernet and IEEE 802.11.

       -E     Use spi@ipaddr algo:secret for decrypting IPsec ESP packets that are addressed to addr and contain Security Parameter Index value spi. This combination may be repeated with comma or newline separation.

              Note that setting the secret for IPv4 ESP packets is supported at this time.

              Algorithms may be des-cbc, 3des-cbc, blowfish-cbc, rc3-cbc, cast128-cbc, or none.  The default is des-cbc.  The ability to decrypt packets is only present if tcpdump was compiled with cryptography enabled.

              secret is the ASCII text for ESP secret key.  If preceded by 0x, then a hex value will be read.

              The option assumes RFC2406 ESP, not RFC1827 ESP.  The option is only for debugging purposes, and the use of this option with a true `secret' key is discouraged.  By presenting IPsec secret key onto command line you make it  visible  to  others,  via
              ps(1) and other occasions.

              In addition to the above syntax, the syntax file name may be used to have tcpdump read the provided file in. The file is opened upon receiving the first ESP packet, so any special permissions that tcpdump may have been given should already have been
              given up.

       -f     Print `foreign' IPv4 addresses numerically rather than symbolically (this option is intended to get around serious brain damage in Sun's NIS server — usually it hangs forever translating non-local internet numbers).

              The test for `foreign' IPv4 addresses is done using the IPv4 address and netmask of the interface on which capture is being done.  If that address or netmask are not available, available, either because the interface on which capture is  being  done
              has no address or netmask or because the capture is being done on the Linux "any" interface, which can capture on more than one interface, this option will not work correctly.

       -F file
              Use file as input for the filter expression.  An additional expression given on the command line is ignored.

       -G rotate_seconds
              If specified, rotates the dump file specified with the -w option every rotate_seconds seconds.  Savefiles will have the name specified by -w which should include a time format as defined by strftime(3).  If no time format is specified, each new file
              will overwrite the previous.

              If used in conjunction with the -C option, filenames will take the form of `file'.

       -h
       --help Print the tcpdump and libpcap version strings, print a usage message, and exit.

       --version
              Print the tcpdump and libpcap version strings and exit.

       -H     Attempt to detect 802.11s draft mesh headers.

       -i interface
       --interface=interface
              Listen on interface.  If unspecified, tcpdump searches the system interface list for the lowest numbered, configured up interface (excluding loopback), which may turn out to be, for example, ``eth0''.

              On Linux systems with 2.2 or later kernels, an interface argument of ``any'' can be used to capture packets from all interfaces.  Note that captures on the ``any'' device will not be done in promiscuous mode.

              If the -D flag is supported, an interface number as printed by that flag can be used as the interface argument, if no interface on the system has that number as a name.

       -I
       --monitor-mode
              Put the interface in "monitor mode"; this is supported only on IEEE 802.11 Wi-Fi interfaces, and supported only on some operating systems.

              Note that in monitor mode the adapter might disassociate from the network with which it's associated, so that you will not be able to use any wireless networks with that adapter.  This could prevent accessing files on a network server, or  resolving
              host names or network addresses, if you are capturing in monitor mode and are not connected to another network with another adapter.

              This flag will affect the output of the -L flag.  If -I isn't specified, only those link-layer types available when not in monitor mode will be shown; if -I is specified, only those link-layer types available when in monitor mode will be shown.

       --immediate-mode
              Capture  in  "immediate  mode".  In this mode, packets are delivered to tcpdump as soon as they arrive, rather than being buffered for efficiency.  This is the default when printing packets rather than saving packets to a ``savefile'' if the packets
              are being printed to a terminal rather than to a file or pipe.

       -j tstamp_type
       --time-stamp-type=tstamp_type
              Set the time stamp type for the capture to tstamp_type.  The names to use for the time stamp types are given in pcap-tstamp(7); not all the types listed there will necessarily be valid for any given interface.

       -J
       --list-time-stamp-types
              List the supported time stamp types for the interface and exit.  If the time stamp type cannot be set for the interface, no time stamp types are listed.

       --time-stamp-precision=tstamp_precision
              When capturing, set the time stamp precision for the capture to tstamp_precision.  Note that availability of high precision time stamps (nanoseconds) and their actual accuracy is platform and hardware dependent.  Also note that when writing captures
              made  with  nanosecond accuracy to a savefile, the time stamps are written with nanosecond resolution, and the file is written with a different magic number, to indicate that the time stamps are in seconds and nanoseconds; not all programs that read
              pcap savefiles will be able to read those captures.

       When reading a savefile, convert time stamps to the precision specified by timestamp_precision, and display them with that resolution.  If the precision specified is less than the precision of time stamps in the file, the conversion will lose precision.

       The supported values for timestamp_precision are micro for microsecond resolution and nano for nanosecond resolution.  The default is microsecond resolution.

       -K
       --dont-verify-checksums
              Don't attempt to verify IP, TCP, or UDP checksums.  This is useful for interfaces that perform some or all of those checksum calculation in hardware; otherwise, all outgoing TCP checksums will be flagged as bad.

       -l     Make stdout line buffered.  Useful if you want to see the data while capturing it.  E.g.,

                     tcpdump -l | tee dat

              or

                     tcpdump -l > dat & tail -f dat

              Note that on Windows,``line buffered'' means ``unbuffered'', so that WinDump will write each character individually if -l is specified.

              -U is similar to -l in its behavior, but it will cause output to be ``packet-buffered'', so that the output is written to stdout at the end of each packet rather than at the end of each line; this is buffered on all platforms, including Windows.

       -L
       --list-data-link-types
              List the known data link types for the interface, in the specified mode, and exit.  The list of known data link types may be dependent on the specified mode; for example, on some platforms, a Wi-Fi interface might support one set of data link  types
              when not in monitor mode (for example, it might support only fake Ethernet headers, or might support 802.11 headers but not support 802.11 headers with radio information) and another set of data link types when in monitor mode (for example, it might
              support 802.11 headers, or 802.11 headers with radio information, only in monitor mode).

       -m module
              Load SMI MIB module definitions from file module.  This option can be used several times to load several MIB modules into tcpdump.

       -M secret
              Use secret as a shared secret for validating the digests found in TCP segments with the TCP-MD5 option (RFC 2385), if present.

       -n     Don't convert addresses (i.e., host addresses, port numbers, etc.) to names.

       -N     Don't print domain name qualification of host names.  E.g., if you give this flag then tcpdump will print ``nic'' instead of ``nic.ddn.mil''.

       -#
       --number
              Print an optional packet number at the beginning of the line.

       -O
       --no-optimize
              Do not run the packet-matching code optimizer.  This is useful only if you suspect a bug in the optimizer.

       -p
       --no-promiscuous-mode
              Don't put the interface into promiscuous mode.  Note that the interface might be in promiscuous mode for some other reason; hence, `-p' cannot be used as an abbreviation for `ether host {local-hw-addr} or ether broadcast'.

       -Q direction
       --direction=direction
              Choose send/receive direction direction for which packets should be captured. Possible values are `in', `out' and `inout'. Not available on all platforms.

       -q     Quick (quiet?) output.  Print less protocol information so output lines are shorter.

       -r file
              Read packets from file (which was created with the -w option or by other tools that write pcap or pcap-ng files).  Standard input is used if file is ``-''.

       -S
       --absolute-tcp-sequence-numbers
              Print absolute, rather than relative, TCP sequence numbers.

       -s snaplen
       --snapshot-length=snaplen
              Snarf snaplen bytes of data from each packet rather than the default of 262144 bytes.  Packets truncated because of a limited snapshot are indicated in the output with ``[|proto]'', where proto is the name of the protocol level at which the  trunca‐
              tion  has  occurred.   Note  that  taking larger snapshots both increases the amount of time it takes to process packets and, effectively, decreases the amount of packet buffering.  This may cause packets to be lost.  You should limit snaplen to the
              smallest number that will capture the protocol information you're interested in.  Setting snaplen to 0 sets it to the default of 262144, for backwards compatibility with recent older versions of tcpdump.

       -T type
              Force packets selected by "expression" to be interpreted the specified type.  Currently known types are aodv (Ad-hoc On-demand Distance Vector protocol), carp (Common Address Redundancy Protocol), cnfp (Cisco NetFlow protocol), lmp (Link  Management
              Protocol), pgm (Pragmatic General Multicast), pgm_zmtp1 (ZMTP/1.0 inside PGM/EPGM), resp (REdis Serialization Protocol), radius (RADIUS), rpc (Remote Procedure Call), rtp (Real-Time Applications protocol), rtcp (Real-Time Applications control proto‐
              col), snmp (Simple Network Management Protocol), tftp (Trivial File Transfer Protocol), vat (Visual Audio Tool), wb (distributed White Board), zmtp1 (ZeroMQ Message Transport Protocol 1.0) and vxlan (Virtual eXtensible Local Area Network).

              Note that the pgm type above affects UDP interpretation only, the native PGM is always recognised as IP protocol 113 regardless. UDP-encapsulated PGM is often called "EPGM" or "PGM/UDP".

              Note that the pgm_zmtp1 type above affects interpretation of both native PGM and UDP at once. During the native PGM decoding the application data of an ODATA/RDATA packet would be decoded as a ZeroMQ datagram with ZMTP/1.0 frames.   During  the  UDP
              decoding in addition to that any UDP packet would be treated as an encapsulated PGM packet.

       -t     Don't print a timestamp on each dump line.

       -tt    Print the timestamp, as seconds since January 1, 1970, 00:00:00, UTC, and fractions of a second since that time, on each dump line.

       -ttt   Print a delta (micro-second resolution) between current and previous line on each dump line.

       -tttt  Print a timestamp, as hours, minutes, seconds, and fractions of a second since midnight, preceded by the date, on each dump line.

       -ttttt Print a delta (micro-second resolution) between current and first line on each dump line.

       -u     Print undecoded NFS handles.

       -U
       --packet-buffered
              If  the -w option is not specified, make the printed packet output ``packet-buffered''; i.e., as the description of the contents of each packet is printed, it will be written to the standard output, rather than, when not writing to a terminal, being
              written only when the output buffer fills.

              If the -w option is specified, make the saved raw packet output ``packet-buffered''; i.e., as each packet is saved, it will be written to the output file, rather than being written only when the output buffer fills.

              The -U flag will not be supported if tcpdump was built with an older version of libpcap that lacks the pcap_dump_flush() function.

       -v     When parsing and printing, produce (slightly more) verbose output.  For example, the time to live, identification, total length and options in an IP packet are printed.  Also enables additional packet integrity checks such as verifying  the  IP  and
              ICMP header checksum.

              When writing to a file with the -w option, report, every 10 seconds, the number of packets captured.

       -vv    Even more verbose output.  For example, additional fields are printed from NFS reply packets, and SMB packets are fully decoded.

       -vvv   Even more verbose output.  For example, telnet SB ... SE options are printed in full.  With -X Telnet options are printed in hex as well.

       -V file
              Read a list of filenames from file. Standard input is used if file is ``-''.

       -w file
              Write the raw packets to file rather than parsing and printing them out.  They can later be printed with the -r option.  Standard output is used if file is ``-''.

              This  output  will  be buffered if written to a file or pipe, so a program reading from the file or pipe may not see packets for an arbitrary amount of time after they are received.  Use the -U flag to cause packets to be written as soon as they are
              received.

              The MIME type application/vnd.tcpdump.pcap has been registered with IANA for pcap files. The filename extension .pcap appears to be the most commonly used along with .cap and .dmp. Tcpdump itself doesn't check  the  extension  when  reading  capture
              files and doesn't add an extension when writing them (it uses magic numbers in the file header instead). However, many operating systems and applications will use the extension if it is present and adding one (e.g. .pcap) is recommended.

              See pcap-savefile(5) for a description of the file format.

       -W     Used  in conjunction with the -C option, this will limit the number of files created to the specified number, and begin overwriting files from the beginning, thus creating a 'rotating' buffer.  In addition, it will name the files with enough leading
              0s to support the maximum number of files, allowing them to sort correctly.

              Used in conjunction with the -G option, this will limit the number of rotated dump files that get created, exiting with status 0 when reaching the limit. If used with -C as well, the behavior will result in cyclical files per timeslice.

       -x     When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex.  The smaller of the entire packet or snaplen bytes will be printed.  Note  that  this  is  the  entire
              link-layer packet, so for link layers that pad (e.g. Ethernet), the padding bytes will also be printed when the higher layer packet is shorter than the required padding.

       -xx    When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, including its link level header, in hex.

       -X     When parsing and printing, in addition to printing the headers of each packet, print the data of each packet (minus its link level header) in hex and ASCII.  This is very handy for analysing new protocols.

       -XX    When parsing and printing, in addition to printing the headers of each packet, print the data of each packet, including its link level header, in hex and ASCII.

       -y datalinktype
       --linktype=datalinktype
              Set the data link type to use while capturing packets to datalinktype.

       -z postrotate-command
              Used  in conjunction with the -C or -G options, this will make tcpdump run " postrotate-command file " where file is the savefile being closed after each rotation. For example, specifying -z gzip or -z bzip2 will compress each savefile using gzip or
              bzip2.

              Note that tcpdump will run the command in parallel to the capture, using the lowest priority so that this doesn't disturb the capture process.

              And in case you would like to use a command that itself takes flags or different arguments, you can always write a shell script that will take the savefile name as the only argument, make the flags & arguments arrangements and  execute  the  command
              that you want.

       -Z user
       --relinquish-privileges=user
              If tcpdump is running as root, after opening the capture device or input savefile, but before opening any savefiles for output, change the user ID to user and the group ID to the primary group of user.

              This behavior can also be enabled by default at compile time.

        expression
              selects which packets will be dumped.  If no expression is given, all packets on the net will be dumped.  Otherwise, only packets for which expression is `true' will be dumped.

              For the expression syntax, see pcap-filter(7).

              The  expression argument can be passed to tcpdump as either a single Shell argument, or as multiple Shell arguments, whichever is more convenient.  Generally, if the expression contains Shell metacharacters, such as backslashes used to escape proto‐
              col names, it is easier to pass it as a single, quoted argument rather than to escape the Shell metacharacters.  Multiple arguments are concatenated with spaces before being parsed.

EXAMPLES
       To print all packets arriving at or departing from sundown:
              tcpdump host sundown

       To print traffic between helios and either hot or ace:
              tcpdump host helios and \( hot or ace \)

       To print all IP packets between ace and any host except helios:
              tcpdump ip host ace and not helios

       To print all traffic between local hosts and hosts at Berkeley:
              tcpdump net ucb-ether

       To print all ftp traffic through internet gateway snup: (note that the expression is quoted to prevent the shell from (mis-)interpreting the parentheses):
              tcpdump 'gateway snup and (port ftp or ftp-data)'

       To print traffic neither sourced from nor destined for local hosts (if you gateway to one other net, this stuff should never make it onto your local net).
              tcpdump ip and not net localnet

       To print the start and end packets (the SYN and FIN packets) of each TCP conversation that involves a non-local host.
              tcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net localnet'

       To print all IPv4 HTTP packets to and from port 80, i.e. print only packets that contain data, not, for example, SYN and FIN packets and ACK-only packets.  (IPv6 is left as an exercise for the reader.)
              tcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'

       To print IP packets longer than 576 bytes sent through gateway snup:
              tcpdump 'gateway snup and ip[2:2] > 576'

       To print IP broadcast or multicast packets that were not sent via Ethernet broadcast or multicast:
              tcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'

       To print all ICMP packets that are not echo requests/replies (i.e., not ping packets):
              tcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply'

OUTPUT FORMAT
       The output of tcpdump is protocol dependent.  The following gives a brief description and examples of most of the formats.

       Timestamps

       By default, all output lines are preceded by a timestamp.  The timestamp is the current clock time in the form
              hh:mm:ss.frac
       and is as accurate as the kernel's clock.  The timestamp reflects the time the kernel applied a time stamp to the packet.  No attempt is made to account for the time lag between when the network interface finished receiving the packet from the network  and
       when  the  kernel  applied a time stamp to the packet; that time lag could include a delay between the time when the network interface finished receiving a packet from the network and the time when an interrupt was delivered to the kernel to get it to read
       the packet and a delay between the time when the kernel serviced the `new packet' interrupt and the time when it applied a time stamp to the packet.

       Link Level Headers

       If the '-e' option is given, the link level header is printed out.  On Ethernets, the source and destination addresses, protocol, and packet length are printed.

       On FDDI networks, the  '-e' option causes tcpdump to print the `frame control' field,  the source and destination addresses, and the packet length.  (The `frame control' field governs the interpretation of the rest of the packet.  Normal packets  (such  as
       those  containing  IP datagrams) are `async' packets, with a priority value between 0 and 7; for example, `async4'.  Such packets are assumed to contain an 802.2 Logical Link Control (LLC) packet; the LLC header is printed if it is not an ISO datagram or a
       so-called SNAP packet.

       On Token Ring networks, the '-e' option causes tcpdump to print the `access control' and `frame control' fields, the source and destination addresses, and the packet length.  As on FDDI networks, packets are assumed to contain an LLC packet.  Regardless of
       whether the '-e' option is specified or not, the source routing information is printed for source-routed packets.

       On 802.11 networks, the '-e' option causes tcpdump to print the `frame control' fields, all of the addresses in the 802.11 header, and the packet length.  As on FDDI networks, packets are assumed to contain an LLC packet.

       (N.B.: The following description assumes familiarity with the SLIP compression algorithm described in RFC-1144.)

       On  SLIP links, a direction indicator (``I'' for inbound, ``O'' for outbound), packet type, and compression information are printed out.  The packet type is printed first.  The three types are ip, utcp, and ctcp.  No further link information is printed for
       ip packets.  For TCP packets, the connection identifier is printed following the type.  If the packet is compressed, its encoded header is printed out.  The special cases are printed out as *S+n and *SA+n, where n is the amount by which the sequence number
       (or  sequence  number  and ack) has changed.  If it is not a special case, zero or more changes are printed.  A change is indicated by U (urgent pointer), W (window), A (ack), S (sequence number), and I (packet ID), followed by a delta (+n or -n), or a new
       value (=n).  Finally, the amount of data in the packet and compressed header length are printed.

       For example, the following line shows an outbound compressed TCP packet, with an implicit connection identifier; the ack has changed by 6, the sequence number by 49, and the packet ID by 6; there are 3 bytes of data and 6 bytes of compressed header:
              O ctcp * A+6 S+49 I+6 3 (6)

       ARP/RARP Packets

       Arp/rarp output shows the type of request and its arguments.  The format is intended to be self explanatory.  Here is a short sample taken from the start of an `rlogin' from host rtsg to host csam:
              arp who-has csam tell rtsg
              arp reply csam is-at CSAM
       The first line says that rtsg sent an arp packet asking for the Ethernet address of internet host csam.  Csam replies with its Ethernet address (in this example, Ethernet addresses are in caps and internet addresses in lower case).

       This would look less redundant if we had done tcpdump -n:
              arp who-has 128.3.254.6 tell 128.3.254.68
              arp reply 128.3.254.6 is-at 02:07:01:00:01:c4

       If we had done tcpdump -e, the fact that the first packet is broadcast and the second is point-to-point would be visible:
              RTSG Broadcast 0806  64: arp who-has csam tell rtsg
              CSAM RTSG 0806  64: arp reply csam is-at CSAM
       For the first packet this says the Ethernet source address is RTSG, the destination is the Ethernet broadcast address, the type field contained hex 0806 (type ETHER_ARP) and the total length was 64 bytes.

       IPv4 Packets

       If the link-layer header is not being printed, for IPv4 packets, IP is printed after the time stamp.

       If the -v flag is specified, information from the IPv4 header is shown in parentheses after the IP or the link-layer header.  The general format of this information is:
              tos tos, ttl ttl, id id, offset offset, flags [flags], proto proto, length length, options (options)
       tos is the type of service field; if the ECN bits are non-zero, those are reported as ECT(1), ECT(0), or CE.  ttl is the time-to-live; it is not reported if it is zero.  id is the IP identification field.  offset is the fragment offset field; it is printed
       whether  this  is  part  of  a  fragmented datagram or not.  flags are the MF and DF flags; + is reported if MF is set, and DFP is reported if F is set.  If neither are set, . is reported.  proto is the protocol ID field.  length is the total length field.
       options are the IP options, if any.

       Next, for TCP and UDP packets, the source and destination IP addresses and TCP or UDP ports, with a dot between each IP address and its corresponding port, will be printed, with a > separating the source and destination.  For other protocols, the addresses
       will be printed, with a > separating the source and destination.  Higher level protocol information, if any, will be printed after that.

       For fragmented IP datagrams, the first fragment contains the higher level protocol header; fragments after the first contain no higher level protocol header.  Fragmentation information will be printed only with the -v flag, in the IP header information, as
       described above.

       TCP Packets

       (N.B.:The following description assumes familiarity with the TCP protocol described in RFC-793.  If you are not familiar with the protocol, this description will not be of much use to you.)

       The general format of a TCP protocol line is:
              src > dst: Flags [tcpflags], seq data-seqno, ack ackno, win window, urg urgent, options [opts], length len
       Src and dst are the source and destination IP addresses and ports.  Tcpflags are some combination of S (SYN), F (FIN), P (PUSH), R (RST), U (URG), W (ECN CWR), E (ECN-Echo) or `.' (ACK), or `none' if no flags are set.  Data-seqno describes the  portion  of
       sequence  space covered by the data in this packet (see example below).  Ackno is sequence number of the next data expected the other direction on this connection.  Window is the number of bytes of receive buffer space available the other direction on this
       connection.  Urg indicates there is `urgent' data in the packet.  Opts are TCP options (e.g., mss 1024).  Len is the length of payload data.

       Iptype, Src, dst, and flags are always present.  The other fields depend on the contents of the packet's TCP protocol header and are output only if appropriate.

       Here is the opening portion of an rlogin from host rtsg to host csam.
              IP rtsg.1023 > csam.login: Flags [S], seq 768512:768512, win 4096, opts [mss 1024]
              IP csam.login > rtsg.1023: Flags [S.], seq, 947648:947648, ack 768513, win 4096, opts [mss 1024]
              IP rtsg.1023 > csam.login: Flags [.], ack 1, win 4096
              IP rtsg.1023 > csam.login: Flags [P.], seq 1:2, ack 1, win 4096, length 1
              IP csam.login > rtsg.1023: Flags [.], ack 2, win 4096
              IP rtsg.1023 > csam.login: Flags [P.], seq 2:21, ack 1, win 4096, length 19
              IP csam.login > rtsg.1023: Flags [P.], seq 1:2, ack 21, win 4077, length 1
              IP csam.login > rtsg.1023: Flags [P.], seq 2:3, ack 21, win 4077, urg 1, length 1
              IP csam.login > rtsg.1023: Flags [P.], seq 3:4, ack 21, win 4077, urg 1, length 1
       The first line says that TCP port 1023 on rtsg sent a packet to port login on csam.  The S indicates that the SYN flag was set.  The packet sequence number was 768512 and it contained no data.  (The notation is `first:last' which  means  `sequence  numbers
       first up to but not including last.)  There was no piggy-backed ack, the available receive window was 4096 bytes and there was a max-segment-size option requesting an mss of 1024 bytes.

       Csam  replies  with  a  similar  packet  except  it includes a piggy-backed ack for rtsg's SYN.  Rtsg then acks csam's SYN.  The `.' means the ACK flag was set.  The packet contained no data so there is no data sequence number or length.  Note that the ack
       sequence number is a small integer (1).  The first time tcpdump sees a TCP `conversation', it prints the sequence number from the packet.  On subsequent packets of the conversation, the difference between the current packet's sequence number and this  ini‐
       tial  sequence number is printed.  This means that sequence numbers after the first can be interpreted as relative byte positions in the conversation's data stream (with the first data byte each direction being `1').  `-S' will override this feature, caus‐
       ing the original sequence numbers to be output.

       On the 6th line, rtsg sends csam 19 bytes of data (bytes 2 through 20 in the rtsg → csam side of the conversation).  The PUSH flag is set in the packet.  On the 7th line, csam says it's received data sent by rtsg up to but not including byte 21.   Most  of
       this data is apparently sitting in the socket buffer since csam's receive window has gotten 19 bytes smaller.  Csam also sends one byte of data to rtsg in this packet.  On the 8th and 9th lines, csam sends two bytes of urgent, pushed data to rtsg.

       If the snapshot was small enough that tcpdump didn't capture the full TCP header, it interprets as much of the header as it can and then reports ``[|tcp]'' to indicate the remainder could not be interpreted.  If the header contains a bogus option (one with
       a length that's either too small or beyond the end of the header), tcpdump reports it as ``[bad opt]'' and does not interpret any further options (since it's impossible to tell where they start).  If the header length indicates options are present but  the
       IP datagram length is not long enough for the options to actually be there, tcpdump reports it as ``[bad hdr length]''.

       Capturing TCP packets with particular flag combinations (SYN-ACK, URG-ACK, etc.)

       There are 8 bits in the control bits section of the TCP header:

              CWR | ECE | URG | ACK | PSH | RST | SYN | FIN

       Let's assume that we want to watch packets used in establishing a TCP connection.  Recall that TCP uses a 3-way handshake protocol when it initializes a new connection; the connection sequence with regard to the TCP control bits is

              1) Caller sends SYN
              2) Recipient responds with SYN, ACK
              3) Caller sends ACK

       Now we're interested in capturing packets that have only the SYN bit set (Step 1).  Note that we don't want packets from step 2 (SYN-ACK), just a plain initial SYN.  What we need is a correct filter expression for tcpdump.

       Recall the structure of a TCP header without options:

        0                            15                              31
       -----------------------------------------------------------------
       |          source port          |       destination port        |
       -----------------------------------------------------------------
       |                        sequence number                        |
       -----------------------------------------------------------------
       |                     acknowledgment number                     |
       -----------------------------------------------------------------
       |  HL   | rsvd  |C|E|U|A|P|R|S|F|        window size            |
       -----------------------------------------------------------------
       |         TCP checksum          |       urgent pointer          |
       -----------------------------------------------------------------

       A TCP header usually holds 20 octets of data, unless options are present.  The first line of the graph contains octets 0 - 3, the second line shows octets 4 - 7 etc.

       Starting to count with 0, the relevant TCP control bits are contained in octet 13:

        0             7|             15|             23|             31
       ----------------|---------------|---------------|----------------
       |  HL   | rsvd  |C|E|U|A|P|R|S|F|        window size            |
       ----------------|---------------|---------------|----------------
       |               |  13th octet   |               |               |

       Let's have a closer look at octet no. 13:

                       |               |
                       |---------------|
                       |C|E|U|A|P|R|S|F|
                       |---------------|
                       |7   5   3     0|

       These are the TCP control bits we are interested in.  We have numbered the bits in this octet from 0 to 7, right to left, so the PSH bit is bit number 3, while the URG bit is number 5.

       Recall that we want to capture packets with only SYN set.  Let's see what happens to octet 13 if a TCP datagram arrives with the SYN bit set in its header:

                       |C|E|U|A|P|R|S|F|
                       |---------------|
                       |0 0 0 0 0 0 1 0|
                       |---------------|
                       |7 6 5 4 3 2 1 0|

       Looking at the control bits section we see that only bit number 1 (SYN) is set.

       Assuming that octet number 13 is an 8-bit unsigned integer in network byte order, the binary value of this octet is

              00000010

       and its decimal representation is

          7     6     5     4     3     2     1     0
       0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 0*2 + 1*2 + 0*2  =  2

       We're almost done, because now we know that if only SYN is set, the value of the 13th octet in the TCP header, when interpreted as a 8-bit unsigned integer in network byte order, must be exactly 2.

       This relationship can be expressed as
              tcp[13] == 2

       We can use this expression as the filter for tcpdump in order to watch packets which have only SYN set:
              tcpdump -i xl0 tcp[13] == 2

       The expression says "let the 13th octet of a TCP datagram have the decimal value 2", which is exactly what we want.

       Now, let's assume that we need to capture SYN packets, but we don't care if ACK or any other TCP control bit is set at the same time.  Let's see what happens to octet 13 when a TCP datagram with SYN-ACK set arrives:

            |C|E|U|A|P|R|S|F|
            |---------------|
            |0 0 0 1 0 0 1 0|
            |---------------|
            |7 6 5 4 3 2 1 0|

       Now bits 1 and 4 are set in the 13th octet.  The binary value of octet 13 is

                   00010010

       which translates to decimal

          7     6     5     4     3     2     1     0
       0*2 + 0*2 + 0*2 + 1*2 + 0*2 + 0*2 + 1*2 + 0*2   = 18

       Now  we can't just use 'tcp[13] == 18' in the tcpdump filter expression, because that would select only those packets that have SYN-ACK set, but not those with only SYN set.  Remember that we don't care if ACK or any other control bit is set as long as SYN
       is set.

       In order to achieve our goal, we need to logically AND the binary value of octet 13 with some other value to preserve the SYN bit.  We know that we want SYN to be set in any case, so we'll logically AND the value in the 13th octet with the binary value  of
       a SYN:

                 00010010 SYN-ACK              00000010 SYN
            AND  00000010 (we want SYN)   AND  00000010 (we want SYN)
                 --------                      --------
            =    00000010                 =    00000010

       We  see that this AND operation delivers the same result regardless whether ACK or another TCP control bit is set.  The decimal representation of the AND value as well as the result of this operation is 2 (binary 00000010), so we know that for packets with
       SYN set the following relation must hold true:

              ( ( value of octet 13 ) AND ( 2 ) ) == ( 2 )

       This points us to the tcpdump filter expression
                   tcpdump -i xl0 'tcp[13] & 2 == 2'

       Some offsets and field values may be expressed as names rather than as numeric values. For example tcp[13] may be replaced with tcp[tcpflags]. The following TCP flag field values are also available: tcp-fin, tcp-syn, tcp-rst, tcp-push, tcp-act, tcp-urg.

       This can be demonstrated as:
                   tcpdump -i xl0 'tcp[tcpflags] & tcp-push != 0'

       Note that you should use single quotes or a backslash in the expression to hide the AND ('&') special character from the shell.

       UDP Packets

       UDP format is illustrated by this rwho packet:
              actinide.who > broadcast.who: udp 84
       This says that port who on host actinide sent a udp datagram to port who on host broadcast, the Internet broadcast address.  The packet contained 84 bytes of user data.

       Some UDP services are recognized (from the source or destination port number) and the higher level protocol information printed.  In particular, Domain Name service requests (RFC-1034/1035) and Sun RPC calls (RFC-1050) to NFS.

       UDP Name Server Requests

       (N.B.:The following description assumes familiarity with the Domain Service protocol described in RFC-1035.  If you are not familiar with the protocol, the following description will appear to be written in greek.)

       Name server requests are formatted as
              src > dst: id op? flags qtype qclass name (len)
              h2opolo.1538 > helios.domain: 3+ A? ucbvax.berkeley.edu. (37)
       Host h2opolo asked the domain server on helios for an address record (qtype=A) associated with the name ucbvax.berkeley.edu.  The query id was `3'.  The `+' indicates the recursion desired flag was set.  The query length was 37 bytes, not including the UDP
       and  IP  protocol headers.  The query operation was the normal one, Query, so the op field was omitted.  If the op had been anything else, it would have been printed between the `3' and the `+'.  Similarly, the qclass was the normal one, C_IN, and omitted.
       Any other qclass would have been printed immediately after the `A'.

       A few anomalies are checked and may result in extra fields enclosed in square brackets:  If a query contains an answer, authority records or additional records section, ancount, nscount, or arcount are printed as `[na]', `[nn]' or  `[nau]' where n  is  the
       appropriate count.  If any of the response bits are set (AA, RA or rcode) or any of the `must be zero' bits are set in bytes two and three, `[b2&3=x]' is printed, where x is the hex value of header bytes two and three.

       UDP Name Server Responses

       Name server responses are formatted as
              src > dst:  id op rcode flags a/n/au type class data (len)
              helios.domain > h2opolo.1538: 3 3/3/7 A 128.32.137.3 (273)
              helios.domain > h2opolo.1537: 2 NXDomain* 0/1/0 (97)
       In  the  first  example,  helios  responds  to query id 3 from h2opolo with 3 answer records, 3 name server records and 7 additional records.  The first answer record is type A (address) and its data is internet address 128.32.137.3.  The total size of the
       response was 273 bytes, excluding UDP and IP headers.  The op (Query) and response code (NoError) were omitted, as was the class (C_IN) of the A record.

       In the second example, helios responds to query 2 with a response code of non-existent domain (NXDomain) with no answers, one name server and no authority records.  The `*' indicates that the authoritative answer bit was set.  Since there were no  answers,
       no type, class or data were printed.

       Other flag characters that might appear are `-' (recursion available, RA, not set) and `|' (truncated message, TC, set).  If the `question' section doesn't contain exactly one entry, `[nq]' is printed.

       SMB/CIFS decoding

       tcpdump now includes fairly extensive SMB/CIFS/NBT decoding for data on UDP/137, UDP/138 and TCP/139.  Some primitive decoding of IPX and NetBEUI SMB data is also done.

       By default a fairly minimal decode is done, with a much more detailed decode done if -v is used.  Be warned that with -v a single SMB packet may take up a page or more, so only use -v if you really want all the gory details.

       For information on SMB packet formats and what all the fields mean see www.cifs.org or the pub/samba/specs/ directory on your favorite samba.org mirror site.  The SMB patches were written by Andrew Tridgell ([email protected]).

       NFS Requests and Replies

       Sun NFS (Network File System) requests and replies are printed as:
              src.sport > dst.nfs: NFS request xid xid len op args
              src.nfs > dst.dport: NFS reply xid xid reply stat len op results
              sushi.1023 > wrl.nfs: NFS request xid 26377
                   112 readlink fh 21,24/10.73165
              wrl.nfs > sushi.1023: NFS reply xid 26377
                   reply ok 40 readlink "../var"
              sushi.1022 > wrl.nfs: NFS request xid 8219
                   144 lookup fh 9,74/4096.6878 "xcolors"
              wrl.nfs > sushi.1022: NFS reply xid 8219
                   reply ok 128 lookup fh 9,74/4134.3150
       In  the  first line, host sushi sends a transaction with id 26377 to wrl.  The request was 112 bytes, excluding the UDP and IP headers.  The operation was a readlink (read symbolic link) on file handle (fh) 21,24/10.731657119.  (If one is lucky, as in this
       case, the file handle can be interpreted as a major,minor device number pair, followed by the inode number and generation number.) In the second line, wrl replies `ok' with the same transaction id and the contents of the link.

       In the third line, sushi asks (using a new transaction id) wrl to lookup the name `xcolors' in directory file 9,74/4096.6878. In the fourth line, wrl sends a reply with the respective transaction id.

       Note that the data printed depends on the operation type.  The format is intended to be self explanatory if read in conjunction with an NFS protocol spec.  Also note that older versions of tcpdump printed NFS packets in a  slightly  different  format:  the
       transaction id (xid) would be printed instead of the non-NFS port number of the packet.

       If the -v (verbose) flag is given, additional information is printed.  For example:
              sushi.1023 > wrl.nfs: NFS request xid 79658
                   148 read fh 21,11/12.195 8192 bytes @ 24576
              wrl.nfs > sushi.1023: NFS reply xid 79658
                   reply ok 1472 read REG 100664 ids 417/0 sz 29388
       (-v  also prints the IP header TTL, ID, length, and fragmentation fields, which have been omitted from this example.)  In the first line, sushi asks wrl to read 8192 bytes from file 21,11/12.195, at byte offset 24576.  Wrl replies `ok'; the packet shown on
       the second line is the first fragment of the reply, and hence is only 1472 bytes long (the other bytes will follow in subsequent fragments, but these fragments do not have NFS or even UDP headers and so might not be printed, depending on the filter expres‐
       sion used).  Because the -v flag is given, some of the file attributes (which are returned in addition to the file data) are printed: the file type (``REG'', for regular file), the file mode (in octal), the uid and gid, and the file size.

       If the -v flag is given more than once, even more details are printed.

       Note that NFS requests are very large and much of the detail won't be printed unless snaplen is increased.  Try using `-s 192' to watch NFS traffic.

       NFS  reply  packets do not explicitly identify the RPC operation.  Instead, tcpdump keeps track of ``recent'' requests, and matches them to the replies using the transaction ID.  If a reply does not closely follow the corresponding request, it might not be
       parsable.

       AFS Requests and Replies

       Transarc AFS (Andrew File System) requests and replies are printed as:

              src.sport > dst.dport: rx packet-type
              src.sport > dst.dport: rx packet-type service call call-name args
              src.sport > dst.dport: rx packet-type service reply call-name args
              elvis.7001 > pike.afsfs:
                   rx data fs call rename old fid 536876964/1/1 ".newsrc.new"
                   new fid 536876964/1/1 ".newsrc"
              pike.afsfs > elvis.7001: rx data fs reply rename
       In the first line, host elvis sends a RX packet to pike.  This was a RX data packet to the fs (fileserver) service, and is the start of an RPC call.  The RPC call was a rename, with the old directory  file  id  of  536876964/1/1  and  an  old  filename  of
       `.newsrc.new', and a new directory file id of 536876964/1/1 and a new filename of `.newsrc'.  The host pike responds with a RPC reply to the rename call (which was successful, because it was a data packet and not an abort packet).

       In general, all AFS RPCs are decoded at least by RPC call name.  Most AFS RPCs have at least some of the arguments decoded (generally only the `interesting' arguments, for some definition of interesting).

       The format is intended to be self-describing, but it will probably not be useful to people who are not familiar with the workings of AFS and RX.

       If the -v (verbose) flag is given twice, acknowledgement packets and additional header information is printed, such as the RX call ID, call number, sequence number, serial number, and the RX packet flags.

       If the -v flag is given twice, additional information is printed, such as the RX call ID, serial number, and the RX packet flags.  The MTU negotiation information is also printed from RX ack packets.

       If the -v flag is given three times, the security index and service id are printed.

       Error codes are printed for abort packets, with the exception of Ubik beacon packets (because abort packets are used to signify a yes vote for the Ubik protocol).

       Note that AFS requests are very large and many of the arguments won't be printed unless snaplen is increased.  Try using `-s 256' to watch AFS traffic.

       AFS  reply  packets  do not explicitly identify the RPC operation.  Instead, tcpdump keeps track of ``recent'' requests, and matches them to the replies using the call number and service ID.  If a reply does not closely follow the corresponding request, it
       might not be parsable.

       KIP AppleTalk (DDP in UDP)

       AppleTalk DDP packets encapsulated in UDP datagrams are de-encapsulated and dumped as DDP packets (i.e., all the UDP header information is discarded).  The file /etc/atalk.names is used to translate AppleTalk net and node numbers to names.  Lines  in  this
       file have the form
              number    name

              1.254          ether
              16.1      icsd-net
              1.254.110 ace
       The  first two lines give the names of AppleTalk networks.  The third line gives the name of a particular host (a host is distinguished from a net by the 3rd octet in the number - a net number must have two octets and a host number must have three octets.)
       The number and name should be separated by whitespace (blanks or tabs).  The /etc/atalk.names file may contain blank lines or comment lines (lines starting with a `#').

       AppleTalk addresses are printed in the form
              net.host.port

              144.1.209.2 > icsd-net.112.220
              office.2 > icsd-net.112.220
              jssmag.149.235 > icsd-net.2
       (If the /etc/atalk.names doesn't exist or doesn't contain an entry for some AppleTalk host/net number, addresses are printed in numeric form.)  In the first example, NBP (DDP port 2) on net 144.1 node 209 is sending to whatever is listening on port 220  of
       net  icsd  node  112.   The  second line is the same except the full name of the source node is known (`office').  The third line is a send from port 235 on net jssmag node 149 to broadcast on the icsd-net NBP port (note that the broadcast address (255) is
       indicated by a net name with no host number - for this reason it's a good idea to keep node names and net names distinct in /etc/atalk.names).

       NBP (name binding protocol) and ATP (AppleTalk transaction protocol) packets have their contents interpreted.  Other protocols just dump the protocol name (or number if no name is registered for the protocol) and packet size.

       NBP packets are formatted like the following examples:
              icsd-net.112.220 > jssmag.2: nbp-lkup 190: "=:LaserWriter@*"
              jssmag.209.2 > icsd-net.112.220: nbp-reply 190: "RM1140:LaserWriter@*" 250
              techpit.2 > icsd-net.112.220: nbp-reply 190: "techpit:LaserWriter@*" 186
       The first line is a name lookup request for laserwriters sent by net icsd host 112 and broadcast on net jssmag.  The nbp id for the lookup is 190.  The second line shows a reply for this request (note that it has the same id) from  host  jssmag.209  saying
       that it has a laserwriter resource named "RM1140" registered on port 250.  The third line is another reply to the same request saying host techpit has laserwriter "techpit" registered on port 186.

       ATP packet formatting is demonstrated by the following example:
              jssmag.209.165 > helios.132: atp-req  12266<0-7> 0xae030001
              helios.132 > jssmag.209.165: atp-resp 12266:0 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:1 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:2 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:4 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:6 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp*12266:7 (512) 0xae040000
              jssmag.209.165 > helios.132: atp-req  12266<3,5> 0xae030001
              helios.132 > jssmag.209.165: atp-resp 12266:3 (512) 0xae040000
              helios.132 > jssmag.209.165: atp-resp 12266:5 (512) 0xae040000
              jssmag.209.165 > helios.132: atp-rel  12266<0-7> 0xae030001
              jssmag.209.133 > helios.132: atp-req* 12267<0-7> 0xae030002
       Jssmag.209 initiates transaction id 12266 with host helios by requesting up to 8 packets (the `<0-7>').  The hex number at the end of the line is the value of the `userdata' field in the request.

       Helios  responds  with 8 512-byte packets.  The `:digit' following the transaction id gives the packet sequence number in the transaction and the number in parens is the amount of data in the packet, excluding the atp header.  The `*' on packet 7 indicates
       that the EOM bit was set.

       Jssmag.209 then requests that packets 3 & 5 be retransmitted.  Helios resends them then jssmag.209 releases the transaction.  Finally, jssmag.209 initiates the next request.  The `*' on the request indicates that XO (`exactly once') was not set.

SEE ALSO
       stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(5), pcap-filter(7), pcap-tstamp(7), apparmor(7)

              http://www.iana.org/assignments/media-types/application/vnd.tcpdump.pcap

AUTHORS
       The original authors are:

       Van Jacobson, Craig Leres and Steven McCanne, all of the Lawrence Berkeley National Laboratory, University of California, Berkeley, CA.

       It is currently being maintained by tcpdump.org.

       The current version is available via http:

              https://www.tcpdump.org/

       The original distribution is available via anonymous ftp:

              ftp://ftp.ee.lbl.gov/old/tcpdump.tar.Z

       IPv6/IPsec support is added by WIDE/KAME project.  This program uses Eric Young's SSLeay library, under specific configurations.

BUGS
       To report a security issue please send an e-mail to [email protected].

       To report bugs and other problems, contribute patches, request a feature, provide generic feedback etc please see the file CONTRIBUTING in the tcpdump source tree root.

       NIT doesn't let you watch your own outbound traffic, BPF will.  We recommend that you use the latter.

       On Linux systems with 2.0[.x] kernels:

              packets on the loopback device will be seen twice;

              packet filtering cannot be done in the kernel, so that all packets must be copied from the kernel in order to be filtered in user mode;

              all of a packet, not just the part that's within the snapshot length, will be copied from the kernel (the 2.0[.x] packet capture mechanism, if asked to copy only part of a packet to userland, will not report the true length of the packet; this would
              cause most IP packets to get an error from tcpdump);

              capturing on some PPP devices won't work correctly.

       We recommend that you upgrade to a 2.2 or later kernel.

       Some attempt should be made to reassemble IP fragments or, at least to compute the right length for the higher level protocol.

       Name  server  inverse  queries are not dumped correctly: the (empty) question section is printed rather than real query in the answer section.  Some believe that inverse queries are themselves a bug and prefer to fix the program generating them rather than
       tcpdump.

       A packet trace that crosses a daylight savings time change will give skewed time stamps (the time change is ignored).

       Filter expressions on fields other than those in Token Ring headers will not correctly handle source-routed Token Ring packets.

       Filter expressions on fields other than those in 802.11 headers will not correctly handle 802.11 data packets with both To DS and From DS set.

       ip6 proto should chase header chain, but at this moment it does not.  ip6 protochain is supplied for this behavior.

       Arithmetic expression against transport layer headers, like tcp[0], does not work against IPv6 packets.  It only looks at IPv4 packets.

你可能感兴趣的:(二把刀运维,tcpdump,网络,tcp/ip)