Association of AP and STA

95 views
Skip to first unread message

Hiroya Okuma

unread,
Nov 3, 2019, 2:36:14 AM11/3/19
to ns-3-users
Hello Everybody,
I am trying to simulate wireless communication using WiFi with the topology shown in the attached file with ns-3.
Assume that three access networks are connected to the server.
In the access network, one router node is connected to one AP node, and I want to configure a simulator in which one user node connects to one AP node. As shown in the attachment "unintended behaiver", they are communicating between different access networks.

ーーーーーーーーーーーーーーーーーーーーーーーー
  int main (int argc, char *argv[])
  {
    std::string phyMode ("DsssRate1Mbps");
    uint32_t staNum = 3;// consumer
    int apNum = 3;// number of AP nodes
    int range = 10;// meter
    double endtime = 2000.0;
  
    CommandLine cmd;
    cmd.Parse (argc, argv);
    
    ////// Reading file for topology setup
    AnnotatedTopologyReader topologyReader("", 1);
    topologyReader.SetFileName("src/ndnSIM/examples/LScale-topo.txt");
    topologyReader.Read();

    ////// Getting containers for the producer/wifi-ap
    Ptr<Node> producer = Names::Find<Node>("root");
    Ptr<Node> wifiApNodes[3] = {Names::Find<Node>("ap1"),
                                Names::Find<Node>("ap2"),
                                Names::Find<Node>("ap3")};
    
    Ptr<Node> routers[4] = {Names::Find<Node>("r1"),
                                Names::Find<Node>("r2"),
                                Names::Find<Node>("r3"),
                                Names::Find<Node>("r0")};

    ////// disable fragmentation, RTS/CTS for frames below 2200 bytes and fix non-unicast data rate
    Config::SetDefault("ns3::WifiRemoteStationManager::FragmentationThreshold", StringValue("2200"));
    Config::SetDefault ("ns3::WifiRemoteStationManager::RtsCtsThreshold", StringValue("2200"));
    Config::SetDefault ("ns3::WifiRemoteStationManager::NonUnicastMode", StringValue(phyMode));

    ////// The below set of helpers will help us to put together the wifi NICs we want
    WifiHelper wifi;
    wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
    YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();

    ////// This is one parameter that matters when using FixedRssLossModel
    ////// set it to zero; otherwise, gain will be added
    // wifiPhy.Set ("RxGain", DoubleValue (0) );

    ////// ns-3 supports RadioTap and Prism tracing extensions for 802.11b
    wifiPhy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);

    YansWifiChannelHelper wifiChannel;

    wifiChannel.SetPropagationDelay("ns3::ConstantSpeedPropagationDelayModel");
    // wifiChannel.AddPropagationLoss("ns3::NakagamiPropagationLossModel");

    ////// The below FixedRssLossModel will cause the rss to be fixed regardless of the distance between the two stations, and the transmit power
    // wifiChannel.AddPropagationLoss ("ns3::FixedRssLossModel","Rss",DoubleValue(rss));

    ////// the following has an absolute cutoff at distance > range (range == radius)
    wifiChannel.AddPropagationLoss ("ns3::RangePropagationLossModel",
                                    "MaxRange", DoubleValue(range));
    wifiPhy.SetChannel (wifiChannel.Create ());
    wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
                                  "DataMode", StringValue (phyMode),
                                  "ControlMode", StringValue (phyMode));

    ////// Setup the rest of the upper mac
    ////// Setting SSID, optional. Modified net-device to get Bssid, mandatory for AP unicast
    Ssid ssid = Ssid ("wifi-default");
    // wifi.SetRemoteStationManager ("ns3::ArfWifiManager");

    ////// Add a non-QoS upper mac of STAs, and disable rate control
    NqosWifiMacHelper wifiMacHelper = NqosWifiMacHelper::Default ();
    ////// Active associsation of STA to AP via probing.
    wifiMacHelper.SetType ("ns3::StaWifiMac", "Ssid", SsidValue (ssid),
                           "ActiveProbing", BooleanValue (true),
                           "ProbeRequestTimeout", TimeValue(Seconds(0.25)));

    ////// Creating 2 mobile nodes
    NodeContainer consumers;
    consumers.Create(staNum);

    // 1. Install WiFi
    NetDeviceContainer staDevice = wifi.Install (wifiPhy, wifiMacHelper, consumers);
    NetDeviceContainer devices = staDevice;
    //NetDeviceContainer staDevice1 = wifi.Install (wifiPhy, wifiMacHelper, consumers[1]);
    //devices.Add (staDevice1);

    ////// Setup AP.
    NqosWifiMacHelper wifiMac = NqosWifiMacHelper::Default ();
    wifiMac.SetType ("ns3::ApWifiMac", "Ssid", SsidValue (ssid),
                     "BeaconGeneration", BooleanValue(false));
    for (int i = 0; i < apNum; i++)
    {
        NetDeviceContainer apDevice = wifi.Install (wifiPhy, wifiMac, wifiApNodes[i]);
        devices.Add (apDevice);
    }

    ////// Note that with FixedRssLossModel, the positions below are not
    ////// used for received signal strength.
    
    ////// set positions for APs
    MobilityHelper sessile;
    Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
    int XposAp = 0;
    for (int i=0; i < apNum; i++) {
        positionAlloc->Add(Vector(10+XposAp, -10, 0.0));
        XposAp += 20;
    }
    sessile.SetPositionAllocator (positionAlloc);
    for (int i = 0; i < apNum; i++) {
        sessile.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
        sessile.Install (wifiApNodes[i]);
    }
    
    ////// Setting mobility model and movement parameters for mobile nodes
    ////// ConstantVelocityMobilityModel is a subclass of MobilityModel
    MobilityHelper sessileConsumer;
    Ptr<ListPositionAllocator> positionConsumer = CreateObject<ListPositionAllocator> ();
    int XposSta = 0;
    for (int i=0; i<int(staNum); i++){
      positionConsumer->Add(Vector(10+XposSta, 0.0, 0.0));
      XposSta += 20;
    }
    sessileConsumer.SetPositionAllocator (positionConsumer);
    for (int i=0; i<int(staNum); i++){
      sessileConsumer.SetMobilityModel("ns3::ConstantVelocityMobilityModel");
      sessileConsumer.Install(consumers.Get(i));
    }
/*
    ////// Setting each sessileConsumer 100m apart from each other
    int nxt = 0;
    for (uint32_t i=0; i<staNum ; i++) {
        Ptr<ConstantVelocityMobilityModel> cvmm = consumers.Get(i)->GetObject<ConstantVelocityMobilityModel> ();
        Vector pos (0-nxt, 0, 0);
        Vector vel (speed, 0, 0);
        cvmm->SetPosition(pos);
        cvmm->SetVelocity(vel);
        nxt += 100;
    }
*/

    // 3. Install NDN stack on all nodes
    NS_LOG_INFO("Installing NDN stack");
    ndn::StackHelper ndnHelper;
    ndnHelper.setCsSize(1000);
    ndnHelper.InstallAll();

    // Choosing forwarding strategy
    ndn::StrategyChoiceHelper::InstallAll("/prefix", "/localhost/nfd/strategy/best-route");
    //ndn::StrategyChoiceHelper::InstallAll("/", "/localhost/nfd/strategy/best-route");

    // Installing global routing interface on all nodes
    ndn::GlobalRoutingHelper ndnGlobalRoutingHelper;
    ndnGlobalRoutingHelper.InstallAll();

・・・Below, the part concerning the application is omitted
ーーーーーーーーーーーーーーーーーーーーーーーー

It's been a while since I started using ns-3, and I don't have much knowledge.

Best Regards,
Hiroya Okuma
topology.png
unintended behavior.PNG

fordev user

unread,
Apr 20, 2020, 3:04:30 PM4/20/20
to ns-3-...@googlegroups.com
Hello, 

Please how can you get this image is it from netanim? 

--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/0d81556e-ca28-4bcd-9f89-068f40f50a23%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages