and here is my code:
/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */
/*
* Copyright (c) 2005,2006,2007 INRIA
* This program is free software; you can redistribute it and/or
modify
*
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation;
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA
*
* Author: Mathieu Lacage <
mathieu...@sophia.inria.fr>
*/
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/applications-module.h"
#include "ns3/mobility-module.h"
#include "ns3/tools-module.h"
#include "ns3/wifi-module.h"
#include <iostream>
NS_LOG_COMPONENT_DEFINE ("Main");
using namespace ns3;
int main (int argc, char *argv[])
{
WifiHelper wifi = WifiHelper::Default ();
wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
wifi.SetStandard (WIFI_PHY_STANDARD_80211b);
NqosWifiMacHelper mac = NqosWifiMacHelper::Default ();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default
();
NodeContainer c;
c.Create (4);
PacketSocketHelper packetSocket;
packetSocket.Install (c);
phy.SetChannel (wifiChannel.Create ());
Ssid ssid ("Raad-network");
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevices = wifi.Install (phy, mac, c.Get(0));
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid));
NetDeviceContainer apDevices = wifi.Install (phy, mac, c.Get(1));
Ssid ssid2 ("Raad-network2");
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid2),
"ActiveProbing", BooleanValue (false));
NetDeviceContainer staDevices2 = wifi.Install (phy, mac, c.Get(2));
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid2));
NetDeviceContainer apDevices2 = wifi.Install (phy, mac, c.Get(3));
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.Install (c);
PacketSocketAddress socket;
socket.SetSingleDevice (staDevices.Get (0)->GetIfIndex ());
socket.SetPhysicalAddress (apDevices.Get (0)->GetAddress ());
socket.SetProtocol (1);
OnOffHelper onoff ("ns3::PacketSocketFactory", Address (socket));
onoff.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable
(250)));
onoff.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable
(0)));
onoff.SetAttribute ("DataRate", DataRateValue (DataRate
(600000000)));
onoff.SetAttribute ("PacketSize", UintegerValue (2000));
ApplicationContainer apps = onoff.Install (c.Get (0));
apps.Start (Seconds (0.5));
apps.Stop (Seconds (30));
PacketSocketAddress socket2;
socket2.SetSingleDevice (staDevices2.Get (0)->GetIfIndex ());
socket2.SetPhysicalAddress (apDevices2.Get (0)->GetAddress ());
socket2.SetProtocol (1);
OnOffHelper onoff2 ("ns3::PacketSocketFactory", Address (socket2));
onoff2.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable
(250)));
onoff2.SetAttribute ("OffTime", RandomVariableValue
(ConstantVariable (0)));
onoff2.SetAttribute ("DataRate", DataRateValue (DataRate
(600000000)));
onoff2.SetAttribute ("PacketSize", UintegerValue (2000));
ApplicationContainer apps2 = onoff2.Install (c.Get (2));
apps2.Start (Seconds (0.5));
apps2.Stop (Seconds (30));
phy.SetPcapDataLinkType(YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
phy.EnablePcap ("new", apDevices.Get(0));
phy.EnablePcap ("new", staDevices.Get(0));
phy.EnablePcap ("new", apDevices2.Get(0));
phy.EnablePcap ("new", staDevices2.Get(0));
Simulator::Stop(Seconds(30));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}