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>