4285ch02.fm Draft Document for Review May 4, 2007 11:35 am
54 Linux Performance and Tuning Guidelines
There are many other useful options. Please check man page. The following example
displays sample output of socket information.
Example 2-21 Showing socket information with netstat
[root@lnxsu5 ~]# netstat -natuw
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:2207 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:36285 127.0.0.1:12865 TIME_WAIT
tcp 0 0 10.0.0.5:37322 10.0.0.4:33932 TIME_WAIT
tcp 0 1 10.0.0.5:55351 10.0.0.4:33932 SYN_SENT
tcp 0 1 10.0.0.5:55350 10.0.0.4:33932 LAST_ACK
tcp 0 0 10.0.0.5:64093 10.0.0.4:33932 TIME_WAIT
tcp 0 0 10.0.0.5:35122 10.0.0.4:12865 ESTABLISHED
tcp 0 0 10.0.0.5:17318 10.0.0.4:33932 TIME_WAIT
tcp 0 0 :::22 :::* LISTEN
tcp 0 2056 ::ffff:192.168.0.254:22 ::ffff:192.168.0.1:3020 ESTABLISHED
udp 0 0 0.0.0.0:111 0.0.0.0:*
udp 0 0 0.0.0.0:631 0.0.0.0:*
udp 0 0 :::5353 :::*
Socket information
Proto The protocol (tcp, udp, raw) used by the socket.
Recv-Q The count of bytes not copied by the user program connected to this
socket.
Send-Q The count of bytes not acknowledged by the remote host.
Local Address Address and port number of the local end of the socket. Unless the
--numeric (-n) option is specified, the socket address is resolved to its
canonical host name (FQDN), and the port number is translated into the
corresponding service name.
Foreign Address Address and port number of the remote end of the socket.
State The state of the socket. Since there are no states in raw mode and
usually no states used in UDP, this column may be left blank. For possible
states, see Figure 1-28, “TCP connection state diagram” on page32 and
man page.
2.3.12 iptraf
iptraf monitors TCP/IP traffic in a real time manner and generates real time reports. It shows
TCP/IP traffic statistics by each session, by interface and by protocol. The iptraf utility is
provided by iptraf package.
The iptraf give us some reports like following
򐂰IP traffic monitor: Network traffic statistics by TCP connection
򐂰General interface statistics: IP traffic statistics by network interface
򐂰Detailed interface statistics: Network traffic statistics by protocol
򐂰Statistical breakdowns: Network traffic statistics by TCP/UDP port and by packet size
򐂰LAN station monitor: Network traffic statistics by Layer2 address
Following are a few of the reports iptraf generates.