Wireless Networking - themactep/thingino-firmware GitHub Wiki

Wireless Networking for IP Cameras

This article covers best practices and technical considerations for setting up your IP camera on a Wi-Fi network. A stable wireless connection is crucial for achieving a reliable, high-quality video feed.

Contents

Wi-Fi Standards

https://en.wikipedia.org/wiki/IEEE_802.11

IEEE Standard Link rate 2.4 GHz 5 GHz 6 GHz Generation
802.11 1–2 Mbit/s x
802.11b 1–11 Mbit/s x
802.11a 6–54 Mbit/s x
802.11g 6–54 Mbit/s x
802.11n 6.5–600 Mbit/s x x Wi-Fi 4
802.11ac 6.5–6933 Mbit/s x Wi-Fi 5
802.11ax 0.4–9608 Mbit/s x x in 6E Wi-Fi 6
802.11be 0.4–23059 Mbit/s x x x Wi-Fi 7
802.11bn 100000 Mbit/s x x x Wi-Fi 8

Most IP cameras communicate using one or more variants of the IEEE 802.11 wireless standard. The supported standard determines the camera's maximum potential speed and compatibility.

  • 802.11b/g/n: These are the most common standards found on IP cameras. They operate on the 2.4 GHz band.
  • 802.11a/n/ac/ax: Cameras that support these standards can also operate on the cleaner 5 GHz band (see below). While still less common than 2.4 GHz models, 5 GHz-capable cameras are becoming more prevalent.

The legacy 802.11b standard is slow and can cause high latency, resulting in an unstable video feed or disconnections. If your network does not have older devices that require it, it is highly advised to disable 802.11b mode on your wireless router to improve overall network stability for your cameras and other devices.

Frequency Bands

Modern Wi-Fi primarily uses two frequency bands, each with its own advantages and disadvantages.

2.4 GHz Band

Pros:

  • Better Range: Signals in the 2.4 GHz band travel farther and penetrate solid obstacles (like walls and floors) more effectively than 5 GHz signals.

Cons:

  • High Congestion: This band is crowded. It's used by many Wi-Fi networks, Bluetooth devices, baby monitors, and microwave ovens, leading to interference.
  • Fewer Channels: Only 3 non-overlapping channels (1, 6, 11) are available, increasing the chance of interference from neighboring networks.

2.4 GHz band is best for cameras that are located far from the router or in areas with many physical obstructions, where maximum range is the priority.

5 GHz Band

Pros:

  • Less Congestion: Far fewer devices use the 5 GHz band, resulting in less interference and a more stable connection.
  • More Channels: The band offers significantly more non-overlapping channels, drastically reducing interference from other networks.
  • Higher Speed: Generally supports faster data rates, which can benefit high-resolution video streams.

Cons:

  • Shorter Range: Higher frequency signals cannot penetrate solid objects as well and have a shorter effective range.

5 GHz band is best for cameras located closer to the router in environments with many other wireless networks and devices. A camera that supports 5 GHz will typically experience fewer issues on a congested network.

Optimizing Your Wireless Signal

A strong, stable signal is key to performance. Wireless networking works best when there is a clear, unobstructed path between the access point (your router) and the camera.

Reduce Physical Obstacles

Minimize the number of walls, ceilings, and large metal objects between your camera and router. Position the router in a central, elevated location if possible.

Antenna Orientation

If your router or camera has external antennas, their orientation matters. A vertical antenna radiates signal horizontally, which is ideal for a single-story home. For multiple floors, angling some antennas horizontally can help distribute signal vertically. Refer to your device's manual for recommendations.

Choose the Right Channel

Use your router's administration page to scan for the least congested Wi-Fi channel and manually select it. On the 2.4 GHz band, stick to channels 1, 6, or 11.

Check Signal Strength

Most camera apps or software will display the wireless signal strength (measured in dBm or as "bars"). Aim for at least -67 dBm (2-3 bars) for a reliable video stream. A value closer to -30 dBm is excellent, while anything below -80 dBm is likely too weak.

Troubleshooting Common Issues

Video is Choppy or Freezes:

This is often due to a weak or unstable signal. Move the camera closer to the router, reduce obstacles, or try switching bands (to 5 GHz if available and feasible).

Camera Frequently Disconnects:

Check for interference from other devices (like microwaves or cordless phones). Change your Wi-Fi channel to a less congested one. Ensure 802.11b mode and HT40 (40 MHz channel width) are disabled on your router.

HT20 and HT40 refer to Wi-Fi channel widths in 802.11n/ac standards. HT20 uses a 20 MHz channel, offering lower bandwidth but better stability and less interference, ideal for crowded environments like apartments. HT40 uses a 40 MHz channel, doubling potential throughput but increasing interference risk, better suited for open spaces with fewer networks. HT20 is more reliable in dense settings, while HT40 maximizes speed where interference is minimal.

Cannot Connect to Camera:

Verify the Wi-Fi password was entered correctly during setup. Ensure the camera is within a reasonable range of the router for the initial configuration.

WPA Supplicant Settings

ap_scan parameter in wpa_supplicant.conf means:

  • ap_scan=0: wpa_supplicant does not perform scanning or roaming; driver handles it.
  • ap_scan=1: wpa_supplicant requests scans and uses results to select AP.
  • ap_scan=2: wpa_supplicant attempts to associate with configured networks one by one without scanning, using the SSID and security policy (but not BSSID). It's for cases like hidden SSIDs or proprietary drivers, but not recommended for the nl80211 driver, as it can cause failures.

FAQ

Q: What can cause invalid crypt error and excessive retries?

 # iwconfig wlan0

 › wlan0     IEEE 802.11  ESSID:"thingino"                                                                                                                     
           Mode:Managed  Frequency:2.412 GHz  Access Point: 8E:D8:1B:DD:3E:C8                                                                                  
           Bit Rate=65 Mb/s   Tx-Power:32 dBm                                                                                                                  
           Retry limit:15   RTS thr:off   Fragment thr:off                                                                                                     
           Encryption key:off                                                                                                                                  
           Power Management:off                                                                                                                                
           Link Quality=5/5  Signal level=-34 dBm  Noise level=-91 dBm                                                                                         
           Rx invalid nwid:0  Rx invalid crypt:1  Rx invalid frag:0
           Tx excessive retries:32  Invalid misc:0   Missed beacon:0

Rx invalid crypt

Count of received frames that were marked “protected” but failed decryption/MIC check.

Common causes (even on an open network):

  • Overlapping neighbors on the same channel that use WPA/WEP; your radio still hears their traffic and the driver counts failed decrypts.
  • Corrupted frames (collisions/interference) causing MIC/ICV failures.
  • Real key/crypto mismatch if your own link were encrypted (not your case since Encryption key: off).
  • One-off or slowly increasing small numbers (like 1) are normal and harmless.

Tx excessive retries

Your station sent a unicast frame, didn’t get an ACK, and retried up to the retry limit (15) — then gave up. This indicates transmission problems at the MAC layer.

Common causes:

  • Co-channel interference/congestion (busy 2.4 GHz channel → collisions, no ACK).
  • Hidden-node conditions (another station can hear the AP but not you, or vice‑versa).
  • Rate control too aggressive for conditions (trying 65 Mb/s when airtime is noisy).
  • Near/far or front-end saturation (very strong signals/tx power, poor linearity).
  • Antenna/connector issues or poor placement/orientation.
  • Non‑Wi‑Fi interferers (Bluetooth, microwave, etc.) on 2.4 GHz.

Things to check/try (low risk)

Channel selection

  • Use channel 6 or 11 instead of 1 if possible; 2.4 GHz congestion is the top cause of retries.
  • On the AP: survey/noise/usage if available; on the client: iw dev wlan0 survey dump to see channel busy time.

Power and rate sanity

  • Set Power Management off.
  • Consider capping the data rate to something more robust to reduce retries: iw dev wlan0 set bitrates legacy-2.4 24.
  • Or cap HT MCS to, say, mcs 0–5 if your driver supports: iw dev wlan0 set bitrates ht-mcs-2.4 0-5.
  • Optionally reduce txpower a bit (e.g., 15–18 dBm) to avoid near‑field overdrive and reduce collision footprint: iwconfig wlan0 txpower 15.

Collision mitigation

  • Enable RTS/CTS at a moderate threshold to help with hidden nodes: iwconfig wlan0 rts 512.
  • Fragmentation (fragment thr) can help in very hostile RF, but adds overhead; try only if needed.

Physical placement

  • Ensure antennas/connectors are snug and oriented well; avoid metal obstructions and very tight near‑field proximity to the AP.

Camera to PC Wireless Link Troubleshooting

If you have a wireless IP camera and a laptop or desktop connected via wireless link, troubleshooting such a setup could be hard due to multiple points of failure.

Start with eliminating PC side connection issues - connected the client machine to the router with an Ethernet cable. If that improves stability - the culprit is your PC connection. If not - than it's on the camera or the AP/router side.

Check for periodic latency spikes with ping from your PC to the camera IP address:

ping -i 0.1 -s 1400 192.168.1.123

Watch for spikes/loss every few seconds. If you see them, it's the Wi‑Fi link, not content.

Dual capture for gap location

Run on camera via SSH

tcpdump -i wlan0 -s 0 -w /tmp/cam.pcap tcp and host YOUR_PC_IP and port 8081

On the PC run

sudo tcpdump -i wlan0 -s 0 -w /tmp/pc.pcap tcp and host YOUR_CAMERA_IP and port 8081

Compare resulting files. If cam.pcap has steady data but pc.pcap shows a few seconds gaps, AP→PC is the issue. If both show gaps, camera→AP is the issue (or AP is pausing the uplink).

Common root causes of short stalls on 2.4 GHz

  • AP features that "slice" airtime. Airtime fairness, Smart QoS/Media prioritization, Band steering. These can starve a lone TCP stream periodically.
  • Background scanning on the PC Wi‑Fi NIC. Some drivers scan frequently, causing brief receive blackouts.
  • Co‑channel congestion/hidden nodes on the channel. Collisions trigger TCP backoff bursts you perceive as pauses.
  • Near/far and overdrive. Camera at in close proximity can saturate the front‑end; reducing txpower often stabilizes.

Targeted fixes to try (fast, reversible)

On the AP

  • Fix channel to 6 or 11 (20 MHz), not "auto"
  • Disable Airtime Fairness, Band Steering, and any Smart QoS shaping
  • DTIM = 1, beacon = 100 ms, keep WMM enabled

On the camera:

  • Force a robust fixed data rate (drops 11n, reduces retries): iwconfig wlan0 rate 24M fixed. Try 24M; if not stable, try 18M or 12M.
  • Reduce TX power to avoid near-field overdrive and shrink collision domain: iwconfig wlan0 txpower 15. 15 dBm; try 12–18 if needed.
  • Enable RTS/CTS to cut hidden-node/collisions: iwconfig wlan0 rts 512. 512 bytes; use 256 if needed.
  • Optional: fragment in very noisy RF (adds overhead; try only if pauses persist): iwconfig wlan0 frag 512.
  • Roll back to defaults if needed: iwconfig wlan0 rts off frag off rate auto txpower auto

On the PC:

  • Disable Wi‑Fi power save: iwconfig wlan0 power off
  • If you must stay on Wi‑Fi, try 5 GHz for the PC while keeping the camera on 2.4 GHz (separate bands reduces contention).