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)); |