Change data rate of wireless channel

1,732 views
Skip to first unread message

dm

unread,
Nov 12, 2008, 3:11:04 PM11/12/08
to ns-3-users
How can I change the data rate of the wifi channel to a lower value,
like 12Mbps. Also, 802.11b is not available, yeah? Is there some way
to do this?

Thanks in advance!

Mathieu Lacage

unread,
Nov 12, 2008, 3:19:11 PM11/12/08
to ns-3-...@googlegroups.com
On Wed, 2008-11-12 at 12:11 -0800, dm wrote:
> How can I change the data rate of the wifi channel to a lower value,

see examples/wifi-adhoc.cc:

WifiHelper wifi;
wifi.SetMac ("ns3::AdhocWifiMac");
wifi.SetPhy ("ns3::WifiPhy");

[...]

wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-9mbs"));
[...]

> like 12Mbps. Also, 802.11b is not available, yeah? Is there some way

802.11b rates are not available.

dm

unread,
Nov 13, 2008, 10:17:24 AM11/13/08
to ns-3-users
Hi Mathieu, and thanks a lot for the help.
I tried that out, but it doesn't seem to work for me. The thing is I
have AP and several clients, and I want to limit the transmission rate
towards each client. I tried limiting the rate as you suggested, but
even if it is set to 6Mbps, if I send 10Mbps it receives 10Mbps.


On Nov 12, 9:19 pm, Mathieu Lacage <mathieu.lac...@sophia.inria.fr>
wrote:

Mathieu Lacage

unread,
Nov 13, 2008, 11:19:44 AM11/13/08
to ns-3-...@googlegroups.com
On Thu, 2008-11-13 at 07:17 -0800, dm wrote:
> Hi Mathieu, and thanks a lot for the help.
> I tried that out, but it doesn't seem to work for me. The thing is I
> have AP and several clients, and I want to limit the transmission rate
> towards each client. I tried limiting the rate as you suggested, but
> even if it is set to 6Mbps, if I send 10Mbps it receives 10Mbps.

You should post your simulation script if you want more help.

regards,
Mathieu

dm

unread,
Nov 13, 2008, 1:04:31 PM11/13/08
to ns-3-users
Thanks, again!
This is the part where I configure the wireless clients (wifiStaNodes
has two nodes, and wifiApNodes has one):

Ptr<WifiChannel> channel = CreateObject<WifiChannel> ();

channel->SetPropagationDelayModel (
CreateObject<ConstantSpeedPropagationDelayModel> ());

Ptr<LogDistancePropagationLossModel> log =
CreateObject<LogDistancePropagationLossModel> ();

log->SetReferenceModel (CreateObject<FriisPropagationLossModel> ());

channel->SetPropagationLossModel (log);

WifiHelper wifi;
wifi.SetPhy ("ns3::WifiPhy");

Ssid ssid = Ssid ("ns-3-ssid");

wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-6mbs"));
wifi.SetMac ("ns3::NqstaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));

staDevices[i] = wifi.Install (wifiStaNodes, channel);

wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-54mbs"));
wifi.SetMac ("ns3::NqapWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));

apDevices[i] = wifi.Install (wifiApNodes, channel);


MobilityHelper mobility;

mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (10.0),
"GridWidth", UintegerValue (3),
"LayoutType", StringValue ("RowFirst"));

mobility.SetMobilityModel ("ns3::StaticMobilityModel");
mobility.Install (wifiStaNodes);

mobility.SetMobilityModel ("ns3::StaticMobilityModel");
mobility.Install (wifiApNodes);

Then I try to send 10Mbps tcp traffic to the wifi stations, and they
receive just as much. If I try to send 20Mbps the simulation exits
with code -11. The same thing happens when I have for example 7
clients.


On Nov 13, 5:19 pm, Mathieu Lacage <mathieu.lac...@sophia.inria.fr>
wrote:

Mathieu Lacage

unread,
Nov 13, 2008, 2:36:11 PM11/13/08
to ns-3-...@googlegroups.com
On Thu, 2008-11-13 at 10:04 -0800, dm wrote:
> Thanks, again!
> This is the part where I configure the wireless clients (wifiStaNodes
> has two nodes, and wifiApNodes has one):

A complete simulation script would be much more useful.

dm

unread,
Nov 13, 2008, 3:44:43 PM11/13/08
to ns-3-users
Here it is. Also changing the number of clients or making the data
rate higher makes the simulation exit with the infamous code -11.


#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include "ns3/core-module.h"
#include "ns3/common-module.h"
#include "ns3/node-module.h"
#include "ns3/helper-module.h"
#include "ns3/mobility-module.h"
#include "ns3/contrib-module.h"
#include "ns3/wifi-module.h"
#include "ns3/global-route-manager.h"

using namespace std;
using namespace ns3;

//
// Define logging keyword for this file
//

NS_LOG_COMPONENT_DEFINE ("Test Network");

uint32_t nWifi = 1;
int
main (int argc, char *argv[])
{
LogComponentEnable("Tcp test_network_server", LOG_LEVEL_INFO);

NodeContainer p2pNodes;
NodeContainer wifiStaNodes;
NodeContainer wifiApNodes;

p2pNodes.Create (2);
wifiApNodes.Add (p2pNodes.Get (1));
wifiStaNodes.Create (nWifi);

// PointToPoint

PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute ("DataRate", StringValue
("50Mbps"));
pointToPoint.SetChannelAttribute ("Delay", StringValue ("2ms"));

NetDeviceContainer p2pDevices;
p2pDevices = pointToPoint.Install (p2pNodes);

// WIFI

NetDeviceContainer apDevices;
NetDeviceContainer staDevices;

Ptr<WifiChannel> channel = CreateObject<WifiChannel> ();

channel->SetPropagationDelayModel (
CreateObject<ConstantSpeedPropagationDelayModel> ());

Ptr<LogDistancePropagationLossModel> log =
CreateObject<LogDistancePropagationLossModel> ();

log->SetReferenceModel (CreateObject<FriisPropagationLossModel> ());

channel->SetPropagationLossModel (log);

WifiHelper wifi;
wifi.SetPhy ("ns3::WifiPhy");

Ssid ssid = Ssid ("ns-3-ssid");

wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-6mbs"));
wifi.SetMac ("ns3::NqstaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));

staDevices = wifi.Install (wifiStaNodes, channel);

wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("wifia-54mbs"));
wifi.SetMac ("ns3::NqapWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (2.5)));

apDevices = wifi.Install (wifiApNodes, channel);



//MOBILITY SPECIFICATION. ALL ARE STATIONARY FOR NOW

MobilityHelper mobility;

mobility.SetPositionAllocator ("ns3::GridPositionAllocator",
"MinX", DoubleValue (0.0),
"MinY", DoubleValue (0.0),
"DeltaX", DoubleValue (5.0),
"DeltaY", DoubleValue (10.0),
"GridWidth", UintegerValue (3),
"LayoutType", StringValue ("RowFirst"));

mobility.SetMobilityModel ("ns3::StaticMobilityModel");
mobility.Install (wifiStaNodes);

mobility.SetMobilityModel ("ns3::StaticMobilityModel");
mobility.Install (wifiApNodes);


InternetStackHelper stack;

stack.Install (wifiStaNodes);
stack.Install (p2pNodes);

// ASSIGNING IP ADDRESSES

Ipv4AddressHelper address;
Ipv4InterfaceContainer p2pInterfaces;
Ipv4InterfaceContainer wifiStaInterfaces;
Ipv4InterfaceContainer wifiAPInterfaces;

address.SetBase ("192.168.1.0", "255.255.255.0");
p2pInterfaces = address.Assign (p2pDevices);

address.SetBase ("192.166.1.0", "255.255.255.0");
wifiStaInterfaces=address.Assign (staDevices);
wifiAPInterfaces=address.Assign (apDevices);

//TCP

NS_LOG_INFO ("Create Applications.");

// Create the application. The server is sending the same stream to
all clients.
uint16_t port = 8000; // Send to port

OnOffHelper onoff ("ns3::TcpSocketFactory", Address ());
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable
(10)));
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable
(0)));
onoff.SetAttribute ("DataRate", DataRateValue (DataRate
(10000000)));
onoff.SetAttribute ("PacketSize", UintegerValue (1024));

ApplicationContainer apps;
for(uint32_t j=0; j<nWifi; ++j)
{
AddressValue remoteAddress (InetSocketAddress
(wifiStaInterfaces.GetAddress (j), port));
onoff.SetAttribute ("Remote", remoteAddress);
apps.Add(onoff.Install (p2pNodes.Get (0)));
}

apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));

// Create a packet sinks to receive these packets
PacketSinkHelper sink ("ns3::TcpSocketFactory",
Address (InetSocketAddress (Ipv4Address::GetAny (), port)));
apps.Add( sink.Install (wifiStaNodes));

apps.Start (Seconds (1.0));
apps.Stop (Seconds (10.0));


GlobalRouteManager::PopulateRoutingTables ();

// Enable dumping at the server and at the clients
PointToPointHelper::EnablePcap ("test_network_server",p2pNodes.Get
(0));

Simulator::Stop (Seconds (10.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}



On Nov 13, 8:36 pm, Mathieu Lacage <mathieu.lac...@sophia.inria.fr>

shivanshu shekhar

unread,
Dec 15, 2022, 1:59:02 PM12/15/22
to ns-3-users
Did this get solved?
Reply all
Reply to author
Forward
0 new messages