2024-10-30 21:04:00
medium.com
You can use Raspberry Pi 4 (or Raspberry Pi 3B) as a network emulator. Raspberry Pi can be used to set up a bridged network, either using ethernet or WiFi.
You can download the prebuild image, and then download Etcher and install the image on the micro sdcard.
Once done, connect keyboard monitor, and ethernet, boot and login with username “pi” and password “raspberry”, then execute the following command to enable WiFi network:
rfkill unblock all
Then reboot, login again and make sure the network is working:
- using ping command to make sure the internet access is working
- Use cell phone to scan the wifi network and find ssid “piem”, and login with password “piemulator”, and make sure the internet access is working
- If not working, try run
sudo systemctl restart networking.service
and wait a few minutes
Then you can test network impairment:
- Run speed test on Raspberry Pi
sudo apt install speedtest-cli
speedtest-cli
Retrieving speedtest.net configuration...
Testing from Comcast Cable (98.37.129.143)...
Retrieving speedtest.net server list...
Selecting best server based on ping...
Hosted by Jefferson Union High School District (Daly City, CA) [62.00 km]: 16.523 ms
Testing download speed................................................................................
Download: 483.86 Mbit/s
Testing upload speed......................................................................................................
Upload: 112.79 Mbit/s
2. Run speed test on cell phone connected with WiFi “piem”. (The speed test may not be as good as you run it on Raspberry Pi, most likely due to interference, default the channel is set to 1)
3. Test rate limit, set downlink bandwidth to 3mbps, “192.168.1.185” is the IP address of the cellphone
sudo emulator.py add -b 3000 -f 192.168.1.185 -c downlink
4. Then run speed test on cell phone again to validate the settings
5. Remove the rate limit and test it again
sudo emulator.py remove -f 192.168.1.185 -c downlink
6. Run sudo emulator.py -h
for help
You can refer https://github.com/cellsim/piem for more details
Modify “/etc/hostapd/hostapd.conf”, change/add the following settings:
- Use 5GHz network
- Search for the channel with the least interferences
- Enable 802.11n support
- Enable 802.11ac support
- Enable QoS support
- Enable HT40 with short guard intervals
hw_mode=a
channel=0
ieee80211n=1
ieee80211ac=1
wmm_enabled=1
ht_capab=[HT40+][SHORT-GI-40]
Then restart hostapd:
sudo systemctl restart networking.servic
There are chances that channel = 0
doesn’t work (at least for me), and you won’t be able to find “piem” network anymore. You can enable logging by adding the following line in “/etc/default/hostapd”:
DAEMON_OPTS="-dd -t -f /tmp/hostapd.log"
Restart hostapd and make sure it runs successfully by checking systemctl status hostapd.service
, otherwise check error log.
If channel auto selection doesn’t work, change that to channel = 36
or other Non-DFS Channels like: 40, 44, 48, 149, 153, 157, 161, 165. Use the following command on Raspberry Pi to check the channel in use nearby:
sudo iwlist wlan0 scan | grep "Channel"
After making those changes, you should be able to see the performance boost (my test shows 3x improvement, around 60mbps ~ 80mbps).
Support Techcratic
If you find value in Techcratic’s insights and articles, consider supporting us with Bitcoin. Your support helps me, as a solo operator, continue delivering high-quality content while managing all the technical aspects, from server maintenance to blog writing, future updates, and improvements. Support Innovation! Thank you.
Bitcoin Address:
bc1qlszw7elx2qahjwvaryh0tkgg8y68enw30gpvge
Please verify this address before sending funds.
Bitcoin QR Code
Simply scan the QR code below to support Techcratic.
Please read the Privacy and Security Disclaimer on how Techcratic handles your support.
Disclaimer: As an Amazon Associate, Techcratic may earn from qualifying purchases.