Skip to content

Instantly share code, notes, and snippets.

View SzymonSzott's full-sized avatar

Szymon Szott SzymonSzott

View GitHub Profile
from os import system
import os, glob
path = "./sys/kernel/debug/ieee80211/"
path += os.listdir(path)[0]+"/" # Add single 'phy' directory
path += glob.glob('*wl*',root_dir=path)[0]+"/stations/" # Add 'netdev\:wl*' directory
path += os.listdir(path)[0]+"/rate_scale_table" # Add single MAC directory
filePath_Intel8260 = path
print(filePath_Intel8260)
@SzymonSzott
SzymonSzott / channel-access.sh
Last active April 28, 2023 09:36
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
@SzymonSzott
SzymonSzott / PopulateARPcache.cc
Created February 21, 2019 11:39
Populate ARP cache (for ns-3 Wi-Fi simulations)
// Function to populate ARP cache of all nodes in ns-3, prevents ARP blocking in Wi-Fi networks
// Execute after assigning IP addresses
// Author: Pavel Boyko?
// https://groups.google.com/d/msg/ns-3-users/L_ZfZ9L1_b0/dCuzc859ENcJ
void PopulateARPcache () {
Ptr<ArpCache> arp = CreateObject<ArpCache> ();
arp->SetAliveTimeout (Seconds (3600 * 24 * 365) );
for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
@SzymonSzott
SzymonSzott / installTrafficGenerator.cc
Created December 4, 2018 12:39
Generic traffic generator installer for ns-3
void installTrafficGenerator(Ptr<ns3::Node> fromNode, Ptr<ns3::Node> toNode, int port, std::string offeredLoad, int packetSize, int simulationTime, int warmupTime ) {
Ptr<Ipv4> ipv4 = toNode->GetObject<Ipv4> (); // Get Ipv4 instance of the node
Ipv4Address addr = ipv4->GetAddress (1, 0).GetLocal (); // Get Ipv4InterfaceAddress of xth interface.
ApplicationContainer sourceApplications, sinkApplications;
uint8_t tosValue = 0x70; //AC_BE
//Add random fuzz to app start time
@SzymonSzott
SzymonSzott / iterate-over-node-container.cc
Created October 24, 2018 10:17
[ns-3] Iterate over node container
NodeContainer c;
c.Create (numNodes);
/*...*/
for(NodeContainer::Iterator n = c.Begin (); n != c.End (); n++)
{
Ptr<Node> object = *n;
uint32_t id = object->GetId();
std::cout <<"Node Number "<< id << std::endl;
}