Network slowdowns manifest in various ways - from delayed file transfers to sluggish intranet browsing. Before diving into solutions, let's establish proper monitoring first.
Start with these terminal commands to gather baseline metrics:
# Continuous ping test
ping -t [server_IP]
# Network interface statistics
netstat -i
# TCP connection details
netstat -s -t
Add DNS lookup timing to your diagnostics. Here's a Python example:
import dns.resolver
import time
def check_dns(hostname):
start = time.time()
answers = dns.resolver.resolve(hostname)
return time.time() - start
print(f"DNS resolution time: {check_dns('your-intranet-site.com')} seconds")
For Windows environments, capture traffic with PowerShell:
# Start packet capture
New-NetCaptureSession -CaptureType Physical -LocalIP Any -RemoteIP Any -SaveOnStop
# After reproduction period
Stop-NetCaptureSession
Implement connection pooling for HTTP requests. Node.js example:
const http = require('http');
const agent = new http.Agent({
keepAlive: true,
maxSockets: 10,
maxFreeSockets: 5,
timeout: 60000
});
const options = {
hostname: 'intranet-server',
port: 80,
path: '/resource',
method: 'GET',
agent: agent
};
For SMB/CIFS shares, adjust these registry settings:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanWorkstation\Parameters]
"DisableBandwidthThrottling"=dword:00000001
"FileInfoCacheEntriesMax"=dword:00000100
"DirectoryCacheEntriesMax"=dword:00000100
Create a simple bandwidth test script:
# PowerShell bandwidth test
$source = "\\server\share\testfile.dat"
$dest = "C:\temp\testfile.dat"
Measure-Command { Copy-Item $source $dest } | Select-Object TotalSeconds
For web applications, implement proper caching headers:
// Express.js middleware example
app.use((req, res, next) => {
res.set('Cache-Control', 'public, max-age=3600');
next();
});
When users report sluggish network performance, we typically see symptoms like:
- File transfers stalling at particular percentages
- Inconsistent ping response times (e.g., alternating between 2ms and 500ms)
- TCP retransmissions visible in packet captures
Start with these command-line utilities that every developer should have in their toolkit:
# Continuous ping test (Linux/Mac)
ping -i 0.2 -c 100 destination_host | tee ping_results.log
# Windows equivalent
Test-NetConnection -ComputerName server -TraceRoute -InformationLevel Detailed
# Bandwidth measurement with iPerf3
iperf3 -c server.example.com -t 30 -P 8 # 8 parallel streams for 30 seconds
Wireshark filters for common network issues:
# High latency between SYN and SYN-ACK
tcp.flags.syn==1 && tcp.flags.ack==0 && frame.time_delta > 0.5
# Retransmissions
tcp.analysis.retransmission || tcp.analysis.fast_retransmission
# Window size issues
tcp.window_size < 1460 && tcp.len > 0
Here's a Python script to test HTTP request latency:
import requests
import time
def test_endpoint(url, iterations=10):
latencies = []
for _ in range(iterations):
start = time.time()
try:
r = requests.get(url, timeout=5)
latency = (time.time() - start) * 1000
latencies.append(latency)
print(f"Status {r.status_code} - {latency:.2f}ms")
except Exception as e:
print(f"Error: {str(e)}")
if latencies:
avg = sum(latencies)/len(latencies)
print(f"\nAverage latency: {avg:.2f}ms")
test_endpoint("http://intranet/internal_api")
Common DNS issues can masquerade as network problems:
# Check DNS resolution times
dig +stats intranet.example.com
nslookup -debug intranet.example.com
# Flush local DNS cache (Windows)
ipconfig /flushdns
# Linux systemd-resolved
sudo systemd-resolve --flush-caches
For Linux servers handling many connections, consider these sysctl tweaks:
# Increase TCP window sizes
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
# Improve congestion control
net.ipv4.tcp_congestion_control = bbr
# Reuse TIME-WAIT sockets
net.ipv4.tcp_tw_reuse = 1
For Wi-Fi networks, these commands help identify issues:
# Linux wireless tools
iwconfig wlan0
iw dev wlan0 scan | grep -i signal
# Windows equivalent
netsh wlan show interfaces
netsh wlan show networks mode=bssid
A simple bash script to monitor interface traffic:
#!/bin/bash
IFACE="eth0"
INTERVAL=5
while true; do
RX1=$(cat /sys/class/net/$IFACE/statistics/rx_bytes)
TX1=$(cat /sys/class/net/$IFACE/statistics/tx_bytes)
sleep $INTERVAL
RX2=$(cat /sys/class/net/$IFACE/statistics/rx_bytes)
TX2=$(cat /sys/class/net/$IFACE/statistics/tx_bytes)
RX=$(( (RX2 - RX1) / INTERVAL / 1024 ))
TX=$(( (TX2 - TX1) / INTERVAL / 1024 ))
echo "RX: $RX KB/s | TX: $TX KB/s | $(date)"
done