Skip to content

Instantly share code, notes, and snippets.

@SzymonSzott
Last active April 28, 2023 09:36
Show Gist options
  • Select an option

  • Save SzymonSzott/5ba70ef55ba2effe0b388dfb0020f036 to your computer and use it in GitHub Desktop.

Select an option

Save SzymonSzott/5ba70ef55ba2effe0b388dfb0020f036 to your computer and use it in GitHub Desktop.
Wi-Fi collision probability in ns-3
#!/usr/bin/env bash
Nsta=3 #Number of Wi-Fi stations
export 'NS_LOG=HeFrameExchangeManager'; #Enable logging (change FrameExchangeManager accordingly)
./waf --run "scratch/skrypt --Nsta=$Nsta" &> output.log #Run simulation
cat output.log | grep StartFrameExchange > output-tx.log #Store log of all TX attempts
cat output.log | grep "receive ack" > output-rx.log #Store log of all successful TXs #TODO: update this line to latest ns-3
# Calculate per-station statistics
for i in `seq 1 $Nsta`
do
mac=$(printf '%02x\n' $i)
tx[$i]=$(cat output-tx.log | grep mac=00:00:00:00:00:$mac | wc -l)
rx[$i]=$(cat output-rx.log | grep mac=00:00:00:00:00:$mac | wc -l)
echo $i,${tx[$i]},${rx[$i]} >> results.csv #Station ID, number of TX attempts, number of successful TXs
done
unset NS_LOG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment