Sources of Network Slowness
- NIC duplex and speed incompatibilities
- Network congestion
- Poor routing
- Bad cabling
- Electrical interference
- An overloaded server at the remote end of the connection
- Misconfigured DNS
TEST YOUR NIC
It is always a good practice in troubleshooting to be versed in monitoring the status of your NIC card from the command line. The following sections introduce a few commands that will be useful.
The ifconfig command without any arguments gives you all the active interfaces on your system. Interfaces will not appear if they are shut down:
[root@bigboy tmp]# ifconfig
Note: Interfaces will appear if they are activated, but have no link.
DHCP Considerations
DHCP clients automatically give their NICs and IP address starting with 169.254.x.x until they can make contact with their DHCP server. When contact is made they reconfigure their IP addresses to the values provided by the DHC server. An interface with a 169.254.x.x address signifies a failure to communicate with the DHCP server. Check your cabling, routing and DHCP server configuration to rectify such a problem.
Testing Link Status from the Command Line
Link Status Output from ethtool
[root@test.com tmp]# ethtool eth0
Settings for eth0:
Supported ports: [ TP MII ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
Advertised auto-negotiation: No
Speed: 100Mb/s
Duplex: Full
Port: MII
PHYAD: 1
Transceiver: internal
Auto-negotiation: off
Supports Wake-on: g
Wake-on: g
Current message level: 0x00000007 (7)
Link detected: yes
[root@test.com tmp]#
Testing Web sites with the curl
Using curl
The curl utility acts like a text based Web browser in which you can select to see either the header or complete body of a Web page’s HTML code displayed on your screen.
A good start is to use the curl command with the -I flag to view just the Web page’s header and HTTP status code. By not using the -I command you will see all the Web page’s HTML code displayed on the screen. Either method can provide a good idea of your server’s performance.
[root@ bigboy tmp]# curl -I www.testing.com
HTTP/1.1 200 OK
Date: Tue, 19 Oct 2004 05:11:22 GMT
Server: Apache/2.0.51 (Fedora)
Accept-Ranges: bytes
Vary: Accept-Encoding,User-Agent
Connection: close
Content-Type: text/html; charset=UTF-8
[root@test.com tmp]#
Using netcat to Test Network Bandwidth
Most Linux distributions contain the netcat or nc packages which can be used to create a TCP socket over which you can transfer data. The syntax can also vary between distributions so you should refer to your system’s man pages if you have any questions.
The netcat server can be easily created with the -l switch that signifies the program should listen, and not talk. The desired TCP port then follows. In this case the server is listening on TCP port 7777.
[root@smallfry tmp]# nc -l 7777
The netcat client only needs to specify the server’s IP address followed by server’s the TCP listener port.
[root@bigboy ~]# nc 192.168.2.50 7777
Any text typed to the console screen of the client;
[root@bigboy ~]# nc 192.168.2.50 7777 This is a test of the NetCat program! [root@bigboy ~]#
will also be visible on the server’s console.
[root@smallfry tmp]# nc -l 7777 This is a test of the NetCat program! [root@smallfry tmp]#
If you want to transfer a file, you only need to use some simple command line redirection. In this case, the server will output all data it receives on port 7777 to a file called FC-6-i386-disc1.iso, and the client pipes the output of the cat command to the netcat client that points to our server.
[root@smallfry tmp]# nc -l 7777 > FC-6-i386-disc1.iso [root@bigboy ~]# cat /tmp/FC-6-i386-disc1.iso | nc 192.168.2.50 7777
All Linux systems have a black hole file named /dev/null which automatically discards any data written to it. If you want to test file transfers without filling your disk storage, or having the server’s disk I/O be a bottleneck, then use this as your output file instead.
[root@smallfry tmp]# nc -l 7777 > /dev/null
All Linux systems also have a have a continuous random data source located at /dev/random. Instead of using a file in your tests, you can use this instead for a data stream or infinite duration.
[root@bigboy ~]# cat /dev/random | nc 192.168.2.50 7777