examples/wireless/simple-wifi-frame-aggregation.cc
changeset 6674 52f8688d6d01
parent 6673 ec22aa763e2d
child 6821 203367ae7433
equal deleted inserted replaced
6673:ec22aa763e2d 6674:52f8688d6d01
    47 {
    47 {
    48   //LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG);
    48   //LogComponentEnable ("EdcaTxopN", LOG_LEVEL_DEBUG);
    49   LogComponentEnable ("MsduAggregator", LOG_LEVEL_INFO);
    49   LogComponentEnable ("MsduAggregator", LOG_LEVEL_INFO);
    50   LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
    50   LogComponentEnable ("UdpEchoClientApplication", LOG_LEVEL_INFO);
    51   LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
    51   LogComponentEnable ("UdpEchoServerApplication", LOG_LEVEL_INFO);
    52   
    52 
    53   uint32_t nWifi = 1;
    53   uint32_t nWifi = 1;
    54   CommandLine cmd;
    54   CommandLine cmd;
    55   cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
    55   cmd.AddValue ("nWifi", "Number of wifi STA devices", nWifi);
    56   cmd.Parse (argc,argv);
    56   cmd.Parse (argc,argv);
    57 
    57 
    71   Ssid ssid = Ssid ("ns-3-802.11n");
    71   Ssid ssid = Ssid ("ns-3-802.11n");
    72   mac.SetType ("ns3::StaWifiMac",
    72   mac.SetType ("ns3::StaWifiMac",
    73                "Ssid", SsidValue (ssid),
    73                "Ssid", SsidValue (ssid),
    74                "ActiveProbing", BooleanValue (false));
    74                "ActiveProbing", BooleanValue (false));
    75   mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
    75   mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
    76                                      "MaxAmsduSize", UintegerValue (3839));
    76                               "MaxAmsduSize", UintegerValue (3839));
    77   
    77 
    78   NetDeviceContainer staDevices;
    78   NetDeviceContainer staDevices;
    79   staDevices = wifi.Install (phy, mac, wifiNodes);
    79   staDevices = wifi.Install (phy, mac, wifiNodes);
    80   
    80 
    81   mac.SetType ("ns3::ApWifiMac",
    81   mac.SetType ("ns3::ApWifiMac",
    82                "Ssid", SsidValue (ssid));
    82                "Ssid", SsidValue (ssid));
    83   mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
    83   mac.SetMsduAggregatorForAc (AC_BE, "ns3::MsduStandardAggregator", 
    84                                      "MaxAmsduSize", UintegerValue (7935));
    84                               "MaxAmsduSize", UintegerValue (7935));
    85 
    85 
    86   NetDeviceContainer apDevice;
    86   NetDeviceContainer apDevice;
    87   apDevice = wifi.Install (phy, mac, wifiApNode);
    87   apDevice = wifi.Install (phy, mac, wifiApNode);
    88  
    88  
    89   /* Setting mobility model */
    89   /* Setting mobility model */
    90   MobilityHelper mobility;
    90   MobilityHelper mobility;
    91 
    91 
    92   mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
    92   mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
    93     "MinX", DoubleValue (0.0),
    93                                  "MinX", DoubleValue (0.0),
    94     "MinY", DoubleValue (0.0),
    94                                  "MinY", DoubleValue (0.0),
    95     "DeltaX", DoubleValue (5.0),
    95                                  "DeltaX", DoubleValue (5.0),
    96     "DeltaY", DoubleValue (10.0),
    96                                  "DeltaY", DoubleValue (10.0),
    97     "GridWidth", UintegerValue (3),
    97                                  "GridWidth", UintegerValue (3),
    98     "LayoutType", StringValue ("RowFirst"));
    98                                  "LayoutType", StringValue ("RowFirst"));
    99 
    99 
   100   mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
   100   mobility.SetMobilityModel ("ns3::RandomWalk2dMobilityModel",
   101     "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
   101                              "Bounds", RectangleValue (Rectangle (-50, 50, -50, 50)));
   102   mobility.Install (wifiNodes);
   102   mobility.Install (wifiNodes);
   103 
   103 
   104   mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
   104   mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
   105   mobility.Install (wifiApNode);
   105   mobility.Install (wifiApNode);
   106   
   106 
   107   /* Internet stack*/
   107   /* Internet stack*/
   108   InternetStackHelper stack;
   108   InternetStackHelper stack;
   109   stack.Install (wifiApNode);
   109   stack.Install (wifiApNode);
   110   stack.Install (wifiNodes);
   110   stack.Install (wifiNodes);
   111 
   111 
   112   Ipv4AddressHelper address;
   112   Ipv4AddressHelper address;
   113 
   113 
   114   address.SetBase ("192.168.1.0", "255.255.255.0");
   114   address.SetBase ("192.168.1.0", "255.255.255.0");
   115   Ipv4InterfaceContainer wifiNodesInterfaces;
   115   Ipv4InterfaceContainer wifiNodesInterfaces;
   116   Ipv4InterfaceContainer apNodeInterface;
   116   Ipv4InterfaceContainer apNodeInterface;
   117   
   117 
   118   wifiNodesInterfaces = address.Assign (staDevices);
   118   wifiNodesInterfaces = address.Assign (staDevices);
   119   apNodeInterface = address.Assign (apDevice);
   119   apNodeInterface = address.Assign (apDevice);
   120   
   120 
   121   /* Setting applications */
   121   /* Setting applications */
   122   UdpEchoServerHelper echoServer (9);
   122   UdpEchoServerHelper echoServer (9);
   123 
   123 
   124   ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (1));
   124   ApplicationContainer serverApps = echoServer.Install (wifiNodes.Get (1));
   125   serverApps.Start (Seconds (1.0));
   125   serverApps.Start (Seconds (1.0));
   136   clientApps.Stop (Seconds (10.0));
   136   clientApps.Stop (Seconds (10.0));
   137 
   137 
   138   Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
   138   Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
   139 
   139 
   140   Simulator::Stop (Seconds (10.0));
   140   Simulator::Stop (Seconds (10.0));
   141   
   141 
   142   phy.EnablePcap ("test-802.11n", 
   142   phy.EnablePcap ("test-802.11n", 
   143     wifiNodes.Get (nWifi - 1)->GetId (), 0);
   143                   wifiNodes.Get (nWifi - 1)->GetId (), 0);
   144 
   144 
   145   Simulator::Run ();
   145   Simulator::Run ();
   146   Simulator::Destroy ();
   146   Simulator::Destroy ();
   147   
   147 
   148   return 0;
   148   return 0;
   149 }
   149 }