Implementing Mixed P-EDCA Networks in NS-3

🎯 Overview

This blog post documents the implementation of a mixed P-EDCA (Prioritized Enhanced Distributed Channel Access) network simulation in NS-3, where stations with and without P-EDCA support compete for channel access in the same wireless network. This work provides a foundation for future P-EDCA performance analysis when the feature becomes fully implemented in NS-3.

πŸš€ What We Built

The Challenge

Traditional WiFi simulations assume homogeneous network conditions where all stations have identical capabilities. However, real-world networks often consist of mixed device types with varying feature support. Our goal was to create a simulation framework that can:

  1. Support mixed station typesΒ - Some stations with P-EDCA support, others without

  2. Track individual performanceΒ - Separate throughput measurements for each station type

  3. Enable fair comparisonΒ - Same network conditions for both station types

  4. Prepare for future P-EDCA implementationΒ - Ready framework when NS-3 adds full P-EDCA support

The Solution Architecture

      [Access Point]
            |
     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
     β”‚             β”‚
[P-EDCA STAs]  [Non-P-EDCA STAs]
   Port 9001       Port 9002
   
   Separate traffic tracking
   Individual throughput analysis

πŸ”§ Implementation Details

1. NS-3 Core Modifications

WiFi MAC Layer Enhancement (wifi-mac.hΒ andΒ wifi-mac.cc)

We extended the NS-3 WiFi MAC layer to support P-EDCA capability advertisement:

Header file additions (wifi-mac.h):

/**
 * Enable or disable P-EDCA capability.
 * \param enable true if P-EDCA should be supported, false otherwise
 */
void SetPedcaSupported(bool enable);

/**
 * Return whether P-EDCA capability is supported.
 * \return true if P-EDCA capability is supported, false otherwise
 */
bool GetPedcaSupported() const;

private:
    bool m_pedcaSupported;         ///< flag indicating whether P-EDCA is supported

Implementation (wifi-mac.cc):

// TypeId attribute registration
.AddAttribute("PedcaSupported",
              "Whether P-EDCA capability is supported.",
              BooleanValue(false),
              MakeBooleanAccessor(&WifiMac::SetPedcaSupported,
                                  &WifiMac::GetPedcaSupported),
              MakeBooleanChecker())

// Setter method
void
WifiMac::SetPedcaSupported(bool enable)
{
    NS_LOG_FUNCTION(this << enable);
    m_pedcaSupported = enable;
}

// Getter method
bool
WifiMac::GetPedcaSupported() const
{
    return m_pedcaSupported;
}

2. Mixed Network Simulation Framework

Parameters Structure

struct Parameters
{
    std::string testName;          //!< Test name
    bool enableErpProtection;      //!< True to enable ERP protection
    std::string erpProtectionMode; //!< ERP protection mode
    bool enableShortSlotTime;      //!< True to enable short slot time
    bool enableShortPhyPreamble;   //!< True to enable short PHY preamble
    uint32_t nWifiStationsPedca;   //!< Number of 802.11n stations WITH P-EDCA
    uint32_t nWifiStationsNoPedca; //!< Number of 802.11n stations WITHOUT P-EDCA
    bool hasTraffic;               //!< True if stations generate traffic
    bool isUdp;                    //!< True to generate UDP traffic
    uint32_t payloadSize;          //!< Payload size in bytes
    Time simulationTime;           //!< Simulation time
};

Key Design Decisions

1. Separate Node Containers

// Create separate containers for different station types
NodeContainer wifiStaNodesPedca;      // P-EDCA stations
wifiStaNodesPedca.Create(nWifiStationsPedca);

NodeContainer wifiStaNodesNoPedca;    // Non-P-EDCA stations
wifiStaNodesNoPedca.Create(nWifiStationsNoPedca);

2. Distinct WiFi Configuration

// P-EDCA stations configuration
mac.SetType("ns3::StaWifiMac",
            "Ssid", SsidValue(ssid),
            "BE_BlockAckThreshold", UintegerValue(2),
            "ShortSlotTimeSupported", BooleanValue(params.enableShortSlotTime),
            "PedcaSupported", BooleanValue(true)); // Enable P-EDCA
staDevicesPedca = wifi.Install(phy, mac, wifiStaNodesPedca);

// Non-P-EDCA stations configuration  
mac.SetType("ns3::StaWifiMac",
            "Ssid", SsidValue(ssid),
            "BE_BlockAckThreshold", UintegerValue(2),
            "ShortSlotTimeSupported", BooleanValue(params.enableShortSlotTime),
            "PedcaSupported", BooleanValue(false)); // Disable P-EDCA
staDevicesNoPedca = wifi.Install(phy, mac, wifiStaNodesNoPedca);

3. Individual Throughput Tracking

// Separate UDP servers for tracking individual performance
uint16_t pedcaPort = 9001;      // P-EDCA stations traffic
uint16_t noPedcaPort = 9002;    // Non-P-EDCA stations traffic

// Server for P-EDCA stations
UdpServerHelper pedcaServer(pedcaPort);
pedcaServerApp = pedcaServer.Install(wifiApNode);

// Server for non-P-EDCA stations
UdpServerHelper noPedcaServer(noPedcaPort);
noPedcaServerApp = noPedcaServer.Install(wifiApNode);

4. Circular Topology for Fair Testing

// Arrange all stations in a circle around AP for equal distance
for (uint32_t i = 0; i < totalStations; i++)
{
    double angle = 2.0 * M_PI * i / totalStations;
    double radius = 5.0; // 5 meters from AP
    positionAlloc->Add(Vector(radius * cos(angle), radius * sin(angle), 0.0));
}

πŸ“Š Testing Framework

Test Scenarios

Our simulation runs three comprehensive test scenarios:

1. Mixed P-EDCA Network

  • Configuration: 1 P-EDCA station + 1 non-P-EDCA station

  • Purpose: Direct competition analysis between different station types

  • Key Insight: Shows how mixed networks perform under realistic conditions

2. Homogeneous P-EDCA Network

  • Configuration: 2 P-EDCA stations

  • Purpose: Baseline performance for P-EDCA-capable devices

  • Key Insight: Maximum potential throughput for P-EDCA networks

3. Homogeneous Non-P-EDCA Network

  • Configuration: 2 non-P-EDCA stations

  • Purpose: Baseline performance for legacy devices

  • Key Insight: Traditional WiFi performance benchmark

Sample Results

========================================
   Mixed P-EDCA Comparison Test
========================================

Test: Mixed P-EDCA (1 P-EDCA STA + 1 non-P-EDCA STA)
---------------------------------------------------
=== Throughput Results ===
P-EDCA stations (1 STAs) throughput: 19.8885 Mbit/s
Average per P-EDCA station: 19.8885 Mbit/s
Non-P-EDCA stations (1 STAs) throughput: 17.5592 Mbit/s
Average per non-P-EDCA station: 17.5592 Mbit/s
Total throughput: 37.4477 Mbit/s

========================================
   Final Comparison Summary
========================================
Mixed (1 P-EDCA + 1 non-P-EDCA): 37.4477 Mbit/s
All P-EDCA (2 STAs):             37.4029 Mbit/s
All non-P-EDCA (2 STAs):         37.3876 Mbit/s

πŸš€ Usage Instructions

Building and Running

# Navigate to NS-3 directory
cd /path/to/ns-3-dev

# Configure with examples
./ns3 configure --enable-examples

# Build the simulation
./ns3 build pedca-mixed

# Run with custom simulation time
./ns3 run "pedca-mixed --time=10"

Customization Options

# Different simulation time
./ns3 run "pedca-mixed --time=30"

# The main parameters can be modified in the code:
# - nWifiStationsPedca: Number of P-EDCA stations
# - nWifiStationsNoPedca: Number of non-P-EDCA stations  
# - payloadSize: UDP packet size
# - simulationTime: Total simulation duration

πŸ“ Code Repository Structure

ns-3-dev/
β”œβ”€β”€ scratch/
β”‚   └── pedca-mixed.cc          # Main simulation script
β”œβ”€β”€ src/wifi/model/
β”‚   β”œβ”€β”€ wifi-mac.h              # Enhanced with P-EDCA support
β”‚   └── wifi-mac.cc             # P-EDCA implementation
└── PEDCA_MIXED_NETWORK_BLOG.md # This documentation

For questions, suggestions, or collaboration opportunities, please contact fathan.pranaya@wilusgroup.com

Keywords: NS-3, P-EDCA, WiFi simulation, mixed networks, 802.11n, network performance analysis, wireless communication

Updated on