⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcpdump.1

📁 TCPDUMP的C语言源代码,是在数据链路层的应用
💻 1
📖 第 1 页 / 共 4 页
字号:
the amount of time it takes to process packets and, effectively,decreases the amount of packet buffering.This may cause packets to belost.You should limit \fIsnaplen\fP to the smallest number that willcapture the protocol information you're interested in.Setting\fIsnaplen\fP to 0 means use the required length to catch whole packets..TP.B \-TForce packets selected by "\fIexpression\fP" to be interpreted thespecified \fItype\fR.Currently known types are\fBaodv\fR (Ad-hoc On-demand Distance Vector protocol),\fBcnfp\fR (Cisco NetFlow protocol),\fBrpc\fR (Remote Procedure Call),\fBrtp\fR (Real-Time Applications protocol),\fBrtcp\fR (Real-Time Applications control protocol),\fBsnmp\fR (Simple Network Management Protocol),\fBtftp\fR (Trivial File Transfer Protocol),\fBvat\fR (Visual Audio Tool),and\fBwb\fR (distributed White Board)..TP.B \-t\fIDon't\fP print a timestamp on each dump line..TP.B \-ttPrint an unformatted timestamp on each dump line..TP.B \-tttPrint a delta (micro-second resolution) between current and previous lineon each dump line..TP.B \-ttttPrint a timestamp in default format proceeded by date on each dump line..TP.B \-tttttPrint a delta (micro-second resolution) between current and first lineon each dump line..TP.B \-uPrint undecoded NFS handles..TP.B \-UMake output saved via the.B \-woption ``packet-buffered''; i.e., as each packet is saved, it will bewritten to the output file, rather than being written only when theoutput buffer fills..IPThe.B \-Uflag will not be supported if.I tcpdumpwas built with an older version of.I libpcapthat lacks the.B pcap_dump_flush()function..TP.B \-vWhen 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 theIP and ICMP header checksum..IPWhen writing to a file with the.B \-woption, report, every 10 seconds, the number of packets captured..TP.B \-vvEven more verbose output.For example, additional fields areprinted from NFS reply packets, and SMB packets are fully decoded..TP.B \-vvvEven more verbose output.For example,telnet \fBSB\fP ... \fBSE\fP optionsare printed in full.With.B \-XTelnet options are printed in hex as well..TP.B \-wWrite the raw packets to \fIfile\fR rather than parsing and printingthem out.They can later be printed with the \-r option.Standard output is used if \fIfile\fR is ``-''..TP.B \-WUsed in conjunction with the .B \-C option, this will limit the numberof files created to the specified number, and begin overwriting filesfrom the beginning, thus creating a 'rotating' buffer. In addition, it will namethe files with enough leading 0s to support the maximum number offiles, allowing them to sort correctly..IPUsed in conjunction with the .B \-Goption, this will limit the number of rotated dump files that getcreated, exiting with status 0 when reaching the limit. If used with.B \-Cas well, the behavior will result in cyclical files per timeslice..TP.B \-xWhen parsing and printing,in addition to printing the headers of each packet, print the data ofeach packet (minus its link level header) in hex. The smaller of the entire packet or.I snaplenbytes will be printed.  Note that this is the entire link-layerpacket, so for link layers that pad (e.g. Ethernet), the padding byteswill also be printed when the higher layer packet is shorter than therequired padding..TP.B \-xxWhen parsing and printing,in addition to printing the headers of each packet, print the data ofeach packet,.I includingits link level header, in hex..TP.B \-XWhen parsing and printing,in addition to printing the headers of each packet, print the data ofeach packet (minus its link level header) in hex and ASCII.This is very handy for analysing new protocols..TP.B \-XXWhen parsing and printing,in addition to printing the headers of each packet, print the data ofeach packet,.I includingits link level header, in hex and ASCII..TP.B \-ySet the data link type to use while capturing packets to \fIdatalinktype\fP..TP.B \-zUsed in conjunction with the.B -Cor.B -Goptions, this will make.I tcpdumprun ".I command file" where.I fileis the savefile being closed after each rotation. For example, specifying.B \-z gzipor.B \-z bzip2will compress each savefile using gzip or bzip2..IPNote that tcpdump will run the command in parallel to the capture, usingthe lowest priority so that this doesn't disturb the capture process..IPAnd in case you would like to use a command that itself takes flags ordifferent arguments, you can always write a shell script that will take thesavefile name as the only argument, make the flags & arguments arrangementsand execute the command that you want..TP.B \-ZDrops privileges (if root) and changes user ID to.I userand the group ID to the primary group of.IR user ..IPThis behavior can also be enabled by default at compile time..IP "\fI expression\fP".RSselects which packets will be dumped.If no \fIexpression\fPis given, all packets on the net will be dumped.Otherwise,only packets for which \fIexpression\fP is `true' will be dumped..LPFor the \fIexpression\fP syntax, see.BR pcap-filter (4)..LPExpression arguments can be passed to \fItcpdump\fP as either a singleargument or as multiple arguments, whichever is more convenient.Generally, if the expression contains Shell metacharacters, it iseasier to pass it as a single, quoted argument.Multiple arguments are concatenated with spaces before being parsed..SH EXAMPLES.LPTo print all packets arriving at or departing from \fIsundown\fP:.RS.nf\fBtcpdump host sundown\fP.fi.RE.LPTo print traffic between \fIhelios\fR and either \fIhot\fR or \fIace\fR:.RS.nf\fBtcpdump host helios and \\( hot or ace \\)\fP.fi.RE.LPTo print all IP packets between \fIace\fR and any host except \fIhelios\fR:.RS.nf\fBtcpdump ip host ace and not helios\fP.fi.RE.LPTo print all traffic between local hosts and hosts at Berkeley:.RS.nf.Btcpdump net ucb-ether.fi.RE.LPTo print all ftp traffic through internet gateway \fIsnup\fP:(note that the expression is quoted to prevent the shell from(mis-)interpreting the parentheses):.RS.nf.Btcpdump 'gateway snup and (port ftp or ftp-data)'.fi.RE.LPTo print traffic neither sourced from nor destined for local hosts(if you gateway to one other net, this stuff should never make itonto your local net)..RS.nf.Btcpdump ip and not net \fIlocalnet\fP.fi.RE.LPTo print the start and end packets (the SYN and FIN packets) of eachTCP conversation that involves a non-local host..RS.nf.Btcpdump 'tcp[tcpflags] & (tcp-syn|tcp-fin) != 0 and not src and dst net \fIlocalnet\fP'.fi.RE.LPTo print all IPv4 HTTP packets to and from port 80, i.e. print onlypackets that contain data, not, for example, SYN and FIN packets andACK-only packets.  (IPv6 is left as an exercise for the reader.).RS.nf.Btcpdump 'tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)'.fi.RE.LPTo print IP packets longer than 576 bytes sent through gateway \fIsnup\fP:.RS.nf.Btcpdump 'gateway snup and ip[2:2] > 576'.fi.RE.LPTo print IP broadcast or multicast packets that were.I notsent via Ethernet broadcast or multicast:.RS.nf.Btcpdump 'ether[0] & 1 = 0 and ip[16] >= 224'.fi.RE.LPTo print all ICMP packets that are not echo requests/replies (i.e., notping packets):.RS.nf.Btcpdump 'icmp[icmptype] != icmp-echo and icmp[icmptype] != icmp-echoreply'.fi.RE.SH OUTPUT FORMAT.LPThe output of \fItcpdump\fP is protocol dependent.The followinggives a brief description and examples of most of the formats..de HD.sp 1.5.B...HDLink Level Headers.LPIf 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..LPOn FDDI networks, the  '-e' option causes \fItcpdump\fP to printthe `frame control' field,  the source and destination addresses,and the packet length.(The `frame control' field governs theinterpretation of the rest of the packet.Normal packets (suchas those containing IP datagrams) are `async' packets, with a priorityvalue between 0 and 7; for example, `\fBasync4\fR'.Such packetsare assumed to contain an 802.2 Logical Link Control (LLC) packet;the LLC header is printed if it is \fInot\fR an ISO datagram or aso-called SNAP packet..LPOn Token Ring networks, the '-e' option causes \fItcpdump\fP to printthe `access control' and `frame control' fields, the source anddestination addresses, and the packet length.As on FDDI networks,packets are assumed to contain an LLC packet.Regardless of whetherthe '-e' option is specified or not, the source routing information isprinted for source-routed packets..LPOn 802.11 networks, the '-e' option causes \fItcpdump\fP to printthe `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..LP\fI(N.B.: The following description assumes familiarity withthe SLIP compression algorithm described in RFC-1144.)\fP.LPOn 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 \fIip\fP, \fIutcp\fP, and \fIctcp\fP.No further link information is printed for \fIip\fR 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\fB*S+\fIn\fR and \fB*SA+\fIn\fR, where \fIn\fR is the amount by whichthe 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 lengthare printed..LPFor 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 ofdata and 6 bytes of compressed header:.RS.nf\fBO ctcp * A+6 S+49 I+6 3 (6)\fP.fi.RE.HDARP/RARP Packets.LPArp/rarp output shows the type of request and its arguments.Theformat is intended to be self explanatory.Here is a short sample taken from the start of an `rlogin' fromhost \fIrtsg\fP to host \fIcsam\fP:.RS.nf.sp .5\f(CWarp who-has csam tell rtsgarp reply csam is-at CSAM\fR.sp .5.fi.REThe first line says that rtsg sent an arp packet askingfor the Ethernet address of internet host csam.Csamreplies with its Ethernet address (in this example, Ethernet addressesare in caps and internet addresses in lower case)..LPThis would look less redundant if we had done \fItcpdump \-n\fP:.RS.nf.sp .5\f(CWarp who-has 128.3.254.6 tell 128.3.254.68arp reply 128.3.254.6 is-at 02:07:01:00:01:c4\fP.fi.RE.LPIf we had done \fItcpdump \-e\fP, the fact that the first packet isbroadcast and the second is point-to-point would be visible:.RS.nf.sp .5\f(CWRTSG Broadcast 0806  64: arp who-has csam tell rtsgCSAM RTSG 0806  64: arp reply csam is-at CSAM\fR.sp .5.fi.REFor the first packet this says the Ethernet source address is RTSG, thedestination is the Ethernet broadcast address, the type fieldcontained hex 0806 (type ETHER_ARP) and the total length was 64 bytes..HDTCP Packets.LP\fI(N.B.:The following description assumes familiarity withthe TCP protocol described in RFC-793.If you are not familiarwith the protocol, neither this description nor \fItcpdump\fP willbe of much use to you.)\fP.LPThe general format of a tcp protocol line is:.RS.nf.sp .5\fIsrc > dst: flags data-seqno ack window urgent options\fP.sp .5.fi.RE\fISrc\fP and \fIdst\fP are the source and destination IPaddresses and ports.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -