You can determine the number of input packets and bytes and output packets and byes on a network interface and check for errors on a Mac OS X system using the command
netstat -bI interface
where interface is a particular network interface
on the system, e.g., en0 or en1 or, alternatively, check all interfaces using
netstat -bi
.
-b With the interface display (option -i, as described below), show the number of bytes
in and out.
-d With either interface display (option -i or an interval, as described below), show
the number of dropped packets.
-I interface
Show information about the specified interface; used with a wait interval as
described below. If the -s option is present, show per-interface protocol statis-
tics on the interface for the specified address_family or protocol, or for all pro-
tocol families.
-i Show the state of interfaces which have been auto-configured (interfaces statically
configured into a system, but not located at boot time are not shown). If the -a
options is also present, multicast addresses currently in use are shown for each
Ethernet interface and for each IP interface address. Multicast addresses are shown
on separate lines following the interface address with which they are associated.
If the -s option is present, show per-interface statistics on all interfaces for the
specified address_family or protocol, or for all protocol families.
E.g., using -bI
to see information for particular
interfaces:
$ netstat -bI en0 Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll en0 1500 <Link#4> d4:9a:20:0d:e6:ec 0 0 0 0 0 836 0 $ netstat -bI en1 Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll en1 1500 <Link#5> f8:1e:df:d9:2b:64 22184840 0 13047081883 29605843 0 6652036717 0 en1 1500 gsod0009627 fe80:5::fa1e:dfff 22184840 - 13047081883 29605843 - 6652036717 - en1 1500 192.168.3 192.168.3.4 22184840 - 13047081883 29605843 - 6652036717 -
Or -bi
for all interfaces:
$ netstat -bi Name Mtu Network Address Ipkts Ierrs Ibytes Opkts Oerrs Obytes Coll lo0 16384 <Link#1> 684926 0 46641907 684926 0 46641907 0 lo0 16384 localhost fe80:1::1 684926 - 46641907 684926 - 46641907 - lo0 16384 127 localhost 684926 - 46641907 684926 - 46641907 - lo0 16384 localhost ::1 684926 - 46641907 684926 - 46641907 - gif0* 1280 <Link#2> 0 0 0 0 0 0 0 stf0* 1280 <Link#3> 0 0 0 0 0 0 0 en0 1500 <Link#4> d4:9a:20:0d:e6:ec 0 0 0 0 0 836 0 en1 1500 <Link#5> f8:1e:df:d9:2b:64 22186588 0 13047529007 29606897 0 6652193662 0 en1 1500 gsod0009627 fe80:5::fa1e:dfff 22186588 - 13047529007 29606897 - 6652193662 - en1 1500 192.168.3 192.168.3.4 22186588 - 13047529007 29606897 - 6652193662 - fw0 4078 <Link#6> d4:9a:20:ff:fe:0d:e6:ec 0 0 0 0 0 346 0 p2p0 2304 <Link#7> 0a:1e:df:d9:2b:64 0 0 0 0 0 0 0 vmnet 1500 <Link#9> 00:50:56:c0:00:01 0 0 0 0 0 0 0 vmnet 1500 192.168.49 192.168.49.1 0 - 0 0 - 0 - vmnet 1500 <Link#10> 00:50:56:c0:00:08 0 0 0 0 0 0 0 vmnet 1500 172.16.79/24 172.16.79.1 0 - 0 0 - 0 - utun0 1400 <Link#8> 4355 0 2689781 5506 10 2466553 0 utun0 1400 192.168.225.1 vpn-192-168-225 4355 - 2689781 5506 - 2466553 -
You can also use netstat -dI
or netstat -di
to check for errors and dropped packets.
$ netstat -dI en1 Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop en1 1500 <Link#5> f8:1e:df:d9:2b:64 22188430 0 29608300 0 0 en1 1500 gsod0009627 fe80:5::fa1e:dfff 22188430 - 29608300 - - - en1 1500 192.168.3 192.168.3.4 22188430 - 29608300 - - - $ netstat -di Name Mtu Network Address Ipkts Ierrs Opkts Oerrs Coll Drop lo0 16384 <Link#1> 685020 0 685020 0 0 lo0 16384 localhost fe80:1::1 685020 - 685020 - - - lo0 16384 127 localhost 685020 - 685020 - - - lo0 16384 localhost ::1 685020 - 685020 - - - gif0* 1280 <Link#2> 0 0 0 0 0 stf0* 1280 <Link#3> 0 0 0 0 0 en0 1500 <Link#4> d4:9a:20:0d:e6:ec 0 0 0 0 0 en1 1500 <Link#5> f8:1e:df:d9:2b:64 22188931 0 29608571 0 0 en1 1500 gsod0009627 fe80:5::fa1e:dfff 22188931 - 29608571 - - - en1 1500 192.168.3 192.168.3.4 22188931 - 29608571 - - - fw0 4078 <Link#6> d4:9a:20:ff:fe:0d:e6:ec 0 0 0 0 0 p2p0 2304 <Link#7> 0a:1e:df:d9:2b:64 0 0 0 0 0 vmnet 1500 <Link#9> 00:50:56:c0:00:01 0 0 0 0 0 vmnet 1500 192.168.49 192.168.49.1 0 - 0 - - - vmnet 1500 <Link#10> 00:50:56:c0:00:08 0 0 0 0 0 vmnet 1500 172.16.79/24 172.16.79.1 0 - 0 - - - utun0 1400 <Link#8> 5088 0 6597 10 0 utun0 1400 192.168.225.1 vpn-192-168-225 5088 - 6597 - - -
If you would like comprehensive per-protocol statisitics for TCP,
UDP, and ICMP, you can use netstat -s
.
-s Show per-protocol statistics. If this option is repeated, counters with a value of
zero are suppressed.
E.g.:
$ netstat -s tcp: 29261464 packets sent 17057982 data packets (1342507929 bytes) 25181 data packets (11210523 bytes) retransmitted 0 resends initiated by MTU discovery 10449225 ack-only packets (7938 delayed) 0 URG only packets 508 window probe packets 767946 window update packets 961091 control packets 0 data packets sent after flow control 21404953 packets received 8137595 acks (for 1341998962 bytes) 377994 duplicate acks 0 acks for unsent data 13805067 packets (1284085790 bytes) received in-sequence 14783 completely duplicate packets (8462565 bytes) 69 old duplicate packets 83 packets with some dup. data (50503 bytes duped) 126989 out-of-order packets (165558655 bytes) 108 packets (126046 bytes) of data after window 18 window probes 3196 window update packets 10932 packets received after close 13 bad resets 0 discarded for bad checksums 0 discarded for bad header offset fields 0 discarded because packet too short 697585 connection requests 825 connection accepts 9 bad connection attempts 0 listen queue overflows 265086 connections established (including accepts) 700724 connections closed (including 167300 drops) 4971 connections updated cached RTT on close 4971 connections updated cached RTT variance on close 2672 connections updated cached ssthresh on close 64419 embryonic connections dropped 4638680 segments updated rtt (of 4788660 attempts) 3759189 retransmit timeouts 3379 connections dropped by rexmit timeout 0 connections dropped after retransmitting FIN 1219 persist timeouts 6 connections dropped by persist timeout 261605 keepalive timeouts 200056 keepalive probes sent 55755 connections dropped by keepalive 4620911 correct ACK header predictions 12309843 correct data packet header predictions 15932 SACK recovery episodes 3124 segment rexmits in SACK recovery episodes 3960674 byte rexmits in SACK recovery episodes 31573 SACK options (SACK blocks) received 124018 SACK options (SACK blocks) sent 0 SACK scoreboard overflow udp: 2731040 datagrams received 0 with incomplete header 0 with bad data length field 0 with bad checksum 127081 dropped due to no socket 692901 broadcast/multicast datagrams dropped due to no socket 1 dropped due to full socket buffers 0 not for hashed pcb 1911057 delivered 18196924 datagrams output ip: 27677449 total packets received 0 bad header checksums 0 with size smaller than minimum 0 with data size < data length 0 with ip length > max ip packet size 0 with header length < data size 0 with data length < header length 0 with bad options 0 with incorrect version number 443 fragments received 0 fragments dropped (dup or out of space) 0 fragments dropped after timeout 141 packets reassembled ok 24114721 packets for this host 11749 packets for unknown/unsupported protocol 0 packets forwarded (0 packets fast forwarded) 805 packets not forwardable 3549872 packets received for unknown multicast group 0 redirects sent 47854947 packets sent from this host 101 packets sent with fabricated ip header 0 output packets dropped due to no bufs, etc. 11620 output packets discarded due to no route 51 output datagrams fragmented 102 fragments created 0 datagrams that can't be fragmented 0 tunneling packets that can't find gif 130 datagrams with bad address in header 0 packets dropped due to no bufs for control data icmp: 127081 calls to icmp_error 0 errors not generated 'cuz old message was icmp Output histogram: echo reply: 340 destination unreachable: 127081 0 messages with bad code fields 0 messages < minimum length 0 bad checksums 0 messages with bad length 0 multicast echo requests ignored 0 multicast timestamp requests ignored Input histogram: echo reply: 639 destination unreachable: 7646 routing redirect: 2468 echo: 340 time exceeded: 136 time stamp: 17 information request: 2 address mask request: 17 UDP: 5 340 message responses generated ICMP address mask responses are disabled igmp: 11768 messages received 0 messages received with too few bytes 30 messages received with wrong TTL 0 messages received with bad checksum 11676 V1/V2 membership queries received 29 V3 membership queries received 0 membership queries received with invalid field(s) 11705 general queries received 0 group queries received 0 group-source queries received 0 group-source queries dropped 32 membership reports received 0 membership reports received with invalid field(s) 32 membership reports received for groups to which we belong 0 V3 reports received without Router Alert 11118 membership reports sent ipsec: 0 inbound packets processed successfully 0 inbound packets violated process security policy 0 inbound packets with no SA available 0 invalid inbound packets 0 inbound packets failed due to insufficient memory 0 inbound packets failed getting SPI 0 inbound packets failed on AH replay check 0 inbound packets failed on ESP replay check 0 inbound packets considered authentic 0 inbound packets failed on authentication 0 outbound packets processed successfully 0 outbound packets violated process security policy 0 outbound packets with no SA available 0 invalid outbound packets 0 outbound packets failed due to insufficient memory 0 outbound packets with no route ip6: 467000 total packets received 0 with size smaller than minimum 0 with data size < data length 0 with bad options 0 with incorrect version number 94 fragments received 0 fragments dropped (dup or out of space) 1 fragment dropped after timeout 0 fragments that exceeded limit 35 packets reassembled ok 32768 packets for this host 0 packets forwarded 415268 packets not forwardable 0 redirects sent 10803 packets sent from this host 0 packets sent with fabricated ip header 0 output packets dropped due to no bufs, etc. 48739 output packets discarded due to no route 1025 output datagrams fragmented 2050 fragments created 0 datagrams that can't be fragmented 0 packets that violated scope rules 415268 multicast packets which we don't join Input histogram: hop by hop: 30801 TCP: 10 UDP: 422348 fragment: 94 ICMP6: 13747 Mbuf statistics: 10 one mbuf two or more mbuf: lo0= 9624 457366 one ext mbuf 0 two or more ext mbuf 0 packets whose headers are not continuous 0 tunneling packets that can't find gif 0 packets discarded due to too may headers 0 failures of source address selection 0 forward cache hit 0 forward cache miss 0 packets dropped due to no bufs for control data icmp6: 0 calls to icmp_error 0 errors not generated because old message was icmp error or so 0 errors not generated because rate limitation Output histogram: router solicitation: 443 neighbor solicitation: 171 neighbor advertisement: 133 MLDv2 listener report: 377 0 messages with bad code fields 0 messages < minimum length 0 bad checksums 0 messages with bad length Input histogram: multicast listener query: 11644 MLDv1 listener report: 23 neighbor solicitation: 7 neighbor advertisement: 7290 Histogram of error messages to be generated: 0 no route 0 administratively prohibited 0 beyond scope 0 address unreachable 0 port unreachable 0 packet too big 0 time exceed transit 0 time exceed reassembly 0 erroneous header field 0 unrecognized next header 0 unrecognized option 0 redirect 0 unknown 0 message responses generated 0 messages with too many ND options 0 messages with bad ND options 0 bad neighbor solicitation messages 0 bad neighbor advertisement messages 0 bad router solicitation messages 0 bad router advertisement messages 0 bad redirect messages 0 path MTU changes ipsec6: 0 inbound packets processed successfully 0 inbound packets violated process security policy 0 inbound packets with no SA available 0 invalid inbound packets 0 inbound packets failed due to insufficient memory 0 inbound packets failed getting SPI 0 inbound packets failed on AH replay check 0 inbound packets failed on ESP replay check 0 inbound packets considered authentic 0 inbound packets failed on authentication 0 outbound packets processed successfully 0 outbound packets violated process security policy 0 outbound packets with no SA available 0 invalid outbound packets 0 outbound packets failed due to insufficient memory 0 outbound packets with no route rip6: 0 messages received 0 checksum calcurations on inbound 0 messages with bad checksum 0 messages dropped due to no socket 0 multicast messages dropped due to no socket 0 messages dropped due to full socket buffers 0 delivered 0 datagrams output pfkey: 242 requests sent to userland 3872 bytes sent to userland histogram by message type: register: 122 flush: 60 x_spdflush: 60 0 messages with invalid length field 0 messages with invalid version field 0 messages with invalid message type field 0 messages too short 0 messages with memory allocation failure 0 messages with duplicate extension 0 messages with invalid extension type 0 messages with invalid sa type 0 messages with invalid address extension 242 requests sent from userland 14064 bytes sent from userland histogram by message type: register: 122 flush: 60 x_spdflush: 60 0 messages toward single socket 120 messages toward all sockets 60 messages toward registered sockets 0 messages with memory allocation failure
You can have the display of counters with a value of zero omitted using
the options -ss
, instead of -s
. E.g.:
$ netstat -ss tcp: 29262147 packets sent 17058355 data packets (1342573989 bytes) 25181 data packets (11210523 bytes) retransmitted 10449497 ack-only packets (7938 delayed) 508 window probe packets 767946 window update packets 961129 control packets 21405439 packets received 8137921 acks (for 1342065132 bytes) 378012 duplicate acks 13805277 packets (1284149452 bytes) received in-sequence 14785 completely duplicate packets (8462978 bytes) 69 old duplicate packets 83 packets with some dup. data (50503 bytes duped) 126989 out-of-order packets (165558655 bytes) 108 packets (126046 bytes) of data after window 18 window probes 3196 window update packets 10932 packets received after close 13 bad resets 697607 connection requests 825 connection accepts 9 bad connection attempts 265103 connections established (including accepts) 700745 connections closed (including 167300 drops) 4971 connections updated cached RTT on close 4971 connections updated cached RTT variance on close 2672 connections updated cached ssthresh on close 64422 embryonic connections dropped 4638941 segments updated rtt (of 4788924 attempts) 3759239 retransmit timeouts 3379 connections dropped by rexmit timeout 1219 persist timeouts 6 connections dropped by persist timeout 261618 keepalive timeouts 200066 keepalive probes sent 55758 connections dropped by keepalive 4621122 correct ACK header predictions 12309982 correct data packet header predictions 15932 SACK recovery episodes 3124 segment rexmits in SACK recovery episodes 3960674 byte rexmits in SACK recovery episodes 31573 SACK options (SACK blocks) received 124018 SACK options (SACK blocks) sent udp: 2731110 datagrams received 127082 dropped due to no socket 692942 broadcast/multicast datagrams dropped due to no socket 1 dropped due to full socket buffers 1911085 delivered 18197031 datagrams output ip: 27678514 total packets received 443 fragments received 141 packets reassembled ok 24115277 packets for this host 11749 packets for unknown/unsupported protocol 805 packets not forwardable 3550381 packets received for unknown multicast group 47855748 packets sent from this host 101 packets sent with fabricated ip header 11620 output packets discarded due to no route 51 output datagrams fragmented 102 fragments created 130 datagrams with bad address in header icmp: 127082 calls to icmp_error Output histogram: echo reply: 340 destination unreachable: 127082 Input histogram: echo reply: 639 destination unreachable: 7646 routing redirect: 2468 echo: 340 time exceeded: 136 time stamp: 17 information request: 2 address mask request: 17 UDP: 5 340 message responses generated ICMP address mask responses are disabled igmp: 11768 messages received 30 messages received with wrong TTL 11676 V1/V2 membership queries received 29 V3 membership queries received 11705 general queries received 32 membership reports received 32 membership reports received for groups to which we belong 11118 membership reports sent ipsec: ip6: 467000 total packets received 94 fragments received 1 fragment dropped after timeout 35 packets reassembled ok 32768 packets for this host 415268 packets not forwardable 10803 packets sent from this host 48739 output packets discarded due to no route 1025 output datagrams fragmented 2050 fragments created 415268 multicast packets which we don't join Input histogram: hop by hop: 30801 TCP: 10 UDP: 422348 fragment: 94 ICMP6: 13747 Mbuf statistics: 10 one mbuf two or more mbuf: lo0= 9624 457366 one ext mbuf 0 two or more ext mbuf icmp6: Output histogram: router solicitation: 443 neighbor solicitation: 171 neighbor advertisement: 133 MLDv2 listener report: 377 Input histogram: multicast listener query: 11644 MLDv1 listener report: 23 neighbor solicitation: 7 neighbor advertisement: 7290 Histogram of error messages to be generated: 0 no route 0 administratively prohibited 0 beyond scope 0 address unreachable 0 port unreachable 0 packet too big 0 time exceed transit 0 time exceed reassembly 0 erroneous header field 0 unrecognized next header 0 unrecognized option 0 redirect 0 unknown ipsec6: rip6: pfkey: 242 requests sent to userland 3872 bytes sent to userland histogram by message type: register: 122 flush: 60 x_spdflush: 60 242 requests sent from userland 14064 bytes sent from userland histogram by message type: register: 122 flush: 60 x_spdflush: 60 120 messages toward all sockets 60 messages toward registered sockets