1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/scratch/be.cc Wed Aug 12 08:58:14 2009 -0300
1.3 @@ -0,0 +1,228 @@
1.4 +#include "ns3/core-module.h"
1.5 +#include "ns3/common-module.h"
1.6 +#include "ns3/node-module.h"
1.7 +#include "ns3/helper-module.h"
1.8 +#include "ns3/mobility-module.h"
1.9 +#include "ns3/contrib-module.h"
1.10 +#include "ns3/wimax-module.h"
1.11 +#include <iostream>
1.12 +#include "ns3/global-route-manager.h"
1.13 +
1.14 +NS_LOG_COMPONENT_DEFINE ("rtPSWimaxSimulation");
1.15 +
1.16 +
1.17 +using namespace ns3;
1.18 +
1.19 +#define MAX_NODES 50
1.20 +#define MAX_TIME 30
1.21 +
1.22 +int throughput[MAX_NODES][MAX_TIME];
1.23 +int total;
1.24 +
1.25 +void
1.26 +InitTrace ()
1.27 +{
1.28 + for (int i=0; i<MAX_NODES; i++)
1.29 + {
1.30 + for (int j=0; j<MAX_TIME; j++)
1.31 + {
1.32 + throughput[i][j] = 0;
1.33 + }
1.34 + }
1.35 + total = 0;
1.36 +}
1.37 +
1.38 +int address2int(Mac48Address address) {
1.39 + uint8_t addr[6];
1.40 + address.CopyTo(addr);
1.41 + return addr[5];
1.42 +}
1.43 +
1.44 +void
1.45 +BSRxTrace (std::string context, Ptr<const Packet> packet, Mac48Address address, Ptr<ConnectionIdentifier> cid)
1.46 +{
1.47 + std::cout << "RX (BS), from: " << address
1.48 + << ", CID: " << cid->GetIdentifier ()
1.49 + << ", time: " << Simulator::Now ().GetSeconds ()
1.50 + << ", packet size: " << packet->GetSize ()
1.51 + << std::endl;
1.52 + int node_id;
1.53 + int int_time;
1.54 + if ( cid->GetIdentifier () > 40000 ) {
1.55 + node_id = address2int ( address );
1.56 + int_time = int (Simulator::Now ().GetSeconds ());
1.57 + throughput [node_id][int_time] += packet->GetSize ();
1.58 + total += packet->GetSize ();
1.59 + // address2int(Mac48Address address)
1.60 + }
1.61 +}
1.62 +
1.63 +void
1.64 +PrintThroughput(int nodes, int time) {
1.65 + FILE * f = fopen("throughput.dat", "w");
1.66 + for ( int i=0; i<time; i++ )
1.67 + {
1.68 + for ( int j=0; j<nodes; j++ )
1.69 + {
1.70 + fprintf(f,"%d\t",throughput[j][i]);
1.71 + }
1.72 + fprintf(f,"\n");
1.73 + }
1.74 + return;
1.75 +}
1.76 +
1.77 +void
1.78 +PrintThroughputTotal(int nodes, int time, int nConnection) {
1.79 + char buf[100];
1.80 + sprintf(buf, "throughput-%02d.dat", nConnection);
1.81 + FILE * f = fopen( buf, "w");
1.82 +
1.83 + for ( int i=1; i<time; i++ )
1.84 + {
1.85 + int total = 0;
1.86 + for ( int j=1; j<=nodes; j++ )
1.87 + {
1.88 + //fprintf(f,"%d\t",throughput[j][i]);
1.89 + total += throughput[j][i];
1.90 + }
1.91 + fprintf(f,"%d\n", total);
1.92 + }
1.93 + fprintf(f,"\nTotal:%d",total);
1.94 + return;
1.95 +}
1.96 +
1.97 +
1.98 +
1.99 +int
1.100 +main(int argc, char *argv[])
1.101 +{
1.102 +
1.103 + int nbSS = 1*2, duration = 10, nbBS = 1; //default values
1.104 + int nCon = 20;
1.105 + CommandLine cmd;
1.106 + cmd.AddValue ("nConnection", "Number of connections", nCon);
1.107 + // cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
1.108 + cmd.Parse (argc, argv);
1.109 +
1.110 +
1.111 + nbSS = nCon * 2;
1.112 +
1.113 + LogComponentEnable("UdpClientApplication", LOG_LEVEL_INFO);
1.114 + LogComponentEnable("UdpServerApplication", LOG_LEVEL_INFO);
1.115 +
1.116 + TimeStepPrecision::Set(TimeStepPrecision::FS);
1.117 +
1.118 + WimaxHelper wimax;
1.119 + MobilityHelper mobility;
1.120 + NodeContainer ssNodes;
1.121 + NodeContainer bsNodes;
1.122 + NetDeviceContainer ssDevs, bsDevs;
1.123 +
1.124 +
1.125 + //**
1.126 +
1.127 + ssNodes.Create(nbSS);
1.128 + bsNodes.Create(nbBS);
1.129 +
1.130 + ssDevs = wimax.Install(ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
1.131 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_SIMPLE);
1.132 + bsDevs = wimax.Install(bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION,
1.133 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_SIMPLE);
1.134 +
1.135 + Ptr<WimaxSubscriberStationNetDevice> ss[nbSS];
1.136 +
1.137 + for (int i = 0; i < nbSS; i++)
1.138 + {
1.139 + ss[i] = ssDevs.Get(i)->GetObject<WimaxSubscriberStationNetDevice> ();
1.140 + ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM64_34);
1.141 +
1.142 + /* ss[i]->m_classifier->m_IPCS_Bind_parameter_manager->CreateIPCS_Classifier_Record ("10.1.1.2","10.1.1.1",0,100,17,102);
1.143 + Mac48Address MacAdress_ss = ss[i+1]->GetMacAddress ();
1.144 + SSRecord *ss1_Record = bsDevs.Get(0)->mbs_classifier->m_IPCS_BS_Bind_Parameter_Record->CreateIPCS_BS_Bind_Parameter_Record (MacAdress_ss);
1.145 +
1.146 + ss1_Record->m_liste_parameter_record->CreateIPCS_Classifier_Record ("10.1.1.2","10.1.1.1",0, 100,17,102);*/
1.147 + }
1.148 +
1.149 + Ptr<WimaxBaseStationNetDevice> bs[nbBS];
1.150 +
1.151 + for (int i = 0; i < nbBS; i++)
1.152 + {
1.153 + bs[i] = bsDevs.Get(i)->GetObject<WimaxBaseStationNetDevice> ();
1.154 + }
1.155 + mobility.Install(bsNodes);
1.156 + mobility.Install(ssNodes);
1.157 +
1.158 + InternetStackHelper stack;
1.159 + stack.Install(bsNodes);
1.160 + stack.Install(ssNodes);
1.161 +
1.162 + Ipv4AddressHelper address;
1.163 + address.SetBase("10.1.1.0", "255.255.255.0");
1.164 +
1.165 + Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
1.166 + Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
1.167 +
1.168 + /*------------------------------*/
1.169 +
1.170 + PacketSocketAddress socket;
1.171 + ApplicationContainer apps;
1.172 +
1.173 + for (int i = 0; i < nbSS / 2; i++)
1.174 + {
1.175 +
1.176 + socket.SetSingleDevice (ssDevs.Get (i)->GetIfIndex ());
1.177 + socket.SetPhysicalAddress (ssDevs.Get (i + (nbSS / 2))->GetAddress ());
1.178 + socket.SetProtocol (1);
1.179 +
1.180 + OnOffHelper onoff1 ("ns3::PacketSocketFactory", Address (socket));
1.181 + onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.0005)));
1.182 + onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
1.183 + onoff1.SetAttribute ("DataRate", DataRateValue (DataRate("600kbps")));
1.184 + onoff1.SetAttribute ("PacketSize", UintegerValue (100));
1.185 + apps = onoff1.Install (ssNodes.Get (i));
1.186 + apps.Start (Seconds (1.0+(i/100)));
1.187 + apps.Stop (Seconds (duration));
1.188 +
1.189 + }
1.190 +
1.191 +
1.192 + Simulator::Stop(Seconds(duration + 0.1));
1.193 +
1.194 +
1.195 + QoSParameterSet* BEparameterSet[nbSS];
1.196 +
1.197 + for (int i = 0; i < nbSS; i++)
1.198 + {
1.199 +
1.200 +
1.201 + BEparameterSet[i] = wimax.CreateBeParameterSet(0);
1.202 +
1.203 + wimax.SetupConnection(ss[i], bs[0], BEparameterSet[i], QoSParameterSet::SCHEDULING_TYPE_BE);
1.204 + }
1.205 + /*
1.206 + for (int i = 0; i < nbSS / 2; i++)
1.207 + {
1.208 + wimax.ClassifierConfig(ss[i + (nbSS / 2)], ss[i], bs[0],
1.209 + SSinterfaces.GetAddress(i + (nbSS / 2)), SSinterfaces.GetAddress(i),
1.210 + 0, 100 + (i * 10), 17, 101);
1.211 +
1.212 + }*/
1.213 +
1.214 +
1.215 + std::ofstream ascii;
1.216 + ascii.open ("simple-wimax.tr");
1.217 + WimaxHelper::EnableAscii (ascii);
1.218 +
1.219 + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxBaseStationNetDevice/BSRx", MakeCallback (&BSRxTrace));
1.220 +
1.221 + InitTrace();
1.222 +
1.223 + NS_LOG_INFO("Starting simulation.....");
1.224 + Simulator::Run();
1.225 + Simulator::Destroy();
1.226 + PrintThroughput(20,10);
1.227 + PrintThroughputTotal(nCon, duration, nCon);
1.228 + NS_LOG_INFO("Done.");
1.229 +
1.230 + return 0;
1.231 +}
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/scratch/nrtps_test.cc Wed Aug 12 08:58:14 2009 -0300
2.3 @@ -0,0 +1,271 @@
2.4 +#include "ns3/core-module.h"
2.5 +#include "ns3/common-module.h"
2.6 +#include "ns3/node-module.h"
2.7 +#include "ns3/helper-module.h"
2.8 +#include "ns3/mobility-module.h"
2.9 +#include "ns3/contrib-module.h"
2.10 +#include "ns3/wimax-module.h"
2.11 +#include <iostream>
2.12 +#include "ns3/global-route-manager.h"
2.13 +
2.14 +NS_LOG_COMPONENT_DEFINE ("rtPSWimaxSimulation");
2.15 +
2.16 +
2.17 +using namespace ns3;
2.18 +
2.19 +#define MAX_NODES 50
2.20 +#define MAX_TIME 30
2.21 +
2.22 +int throughput[MAX_NODES][MAX_TIME];
2.23 +int total;
2.24 +
2.25 +void
2.26 +InitTrace ()
2.27 +{
2.28 + for (int i=0; i<MAX_NODES; i++)
2.29 + {
2.30 + for (int j=0; j<MAX_TIME; j++)
2.31 + {
2.32 + throughput[i][j] = 0;
2.33 + }
2.34 + }
2.35 + total = 0;
2.36 +}
2.37 +
2.38 +int address2int(Mac48Address address) {
2.39 + uint8_t addr[6];
2.40 + address.CopyTo(addr);
2.41 + return addr[5];
2.42 +}
2.43 +
2.44 +void
2.45 +SSTxTrace (std::string context, Ptr<const PacketBurst> burst, Mac48Address address, Ptr<ConnectionIdentifier> cid, WimaxPhy::ModulationType modulationType)
2.46 +{
2.47 + std::cout << "TraceDelay: TX (SS) address: " << address
2.48 + << ", CID: " << cid->GetIdentifier ()
2.49 + << ", time: " << Simulator::Now ().GetSeconds ()
2.50 + << ", burst size: " << burst->GetSize ()
2.51 + << ", packets: " << burst->GetNPackets ()<< std::endl;
2.52 + // << ", modulation: " << ToString (modulationType) << std::endl;
2.53 +}
2.54 +
2.55 +void
2.56 +BSRxTrace (std::string context, Ptr<const Packet> packet, Mac48Address address, Ptr<ConnectionIdentifier> cid)
2.57 +{
2.58 + std::cout << "TraceDelay: RX (BS), from: " << address
2.59 + << ", CID: " << cid->GetIdentifier ()
2.60 + << ", time: " << Simulator::Now ().GetSeconds ()
2.61 + << ", packet size: " << packet->GetSize ()
2.62 + << ", packet uid: " << packet->GetUid ()
2.63 + << std::endl;
2.64 + int node_id;
2.65 + int int_time;
2.66 + if ( cid->GetIdentifier () > 40000 ) {
2.67 + node_id = address2int ( address );
2.68 + int_time = int (Simulator::Now ().GetSeconds ());
2.69 + throughput [node_id][int_time] += packet->GetSize ();
2.70 + total += packet->GetSize ();
2.71 + // address2int(Mac48Address address)
2.72 + }
2.73 +
2.74 +}
2.75 +
2.76 +void
2.77 +SSRxTrace (std::string context, Ptr<const Packet> packet, Mac48Address address, Ptr<ConnectionIdentifier> cid)
2.78 +{
2.79 + std::cout << "RX (SS) address: " << address
2.80 + << ", CID: " << cid->GetIdentifier ()
2.81 + << ", time: " << Simulator::Now ().GetSeconds ()
2.82 + << ", packet size: " << packet->GetSize ()
2.83 + << ", packet uid: " << packet->GetUid ()
2.84 + //<< ", packet: " << *packet
2.85 + << std::endl;
2.86 +}
2.87 +
2.88 +
2.89 +void
2.90 +PrintThroughput(int nodes, int time) {
2.91 + FILE * f = fopen("throughput.dat", "w");
2.92 + for ( int i=0; i<time; i++ )
2.93 + {
2.94 + for ( int j=0; j<nodes; j++ )
2.95 + {
2.96 + fprintf(f,"%d\t",throughput[j][i]);
2.97 + }
2.98 + fprintf(f,"\n");
2.99 + }
2.100 + return;
2.101 +}
2.102 +
2.103 +void
2.104 +PrintThroughputTotal(int nodes, int time, int nConnection) {
2.105 + char buf[100];
2.106 + sprintf(buf, "throughput-%02d.dat", nConnection);
2.107 + FILE * f = fopen( buf, "w");
2.108 +
2.109 + for ( int i=1; i<time; i++ )
2.110 + {
2.111 + int total = 0;
2.112 + for ( int j=1; j<=nodes; j++ )
2.113 + {
2.114 + //fprintf(f,"%d\t",throughput[j][i]);
2.115 + total += throughput[j][i];
2.116 + }
2.117 + fprintf(f,"%d\n", total);
2.118 + }
2.119 + fprintf(f,"\nTotal:%d",total);
2.120 + return;
2.121 +}
2.122 +
2.123 +
2.124 +
2.125 +int
2.126 +main(int argc, char *argv[])
2.127 +{
2.128 +
2.129 + int nbSS = 1*2, duration = 10, nbBS = 1; //default values
2.130 + int nCon = 2;
2.131 + CommandLine cmd;
2.132 + cmd.AddValue ("nConnection", "Number of connections", nCon);
2.133 + // cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
2.134 + cmd.Parse (argc, argv);
2.135 +
2.136 +
2.137 + nbSS = nCon * 2;
2.138 +
2.139 + LogComponentEnable("UdpClientApplication", LOG_LEVEL_INFO);
2.140 + LogComponentEnable("UdpServerApplication", LOG_LEVEL_INFO);
2.141 +
2.142 + TimeStepPrecision::Set(TimeStepPrecision::FS);
2.143 +
2.144 + WimaxHelper wimax;
2.145 + MobilityHelper mobility;
2.146 + NodeContainer ssNodes;
2.147 + NodeContainer bsNodes;
2.148 + NetDeviceContainer ssDevs, bsDevs;
2.149 +
2.150 +
2.151 + //**
2.152 +
2.153 + ssNodes.Create(nbSS);
2.154 + bsNodes.Create(nbBS);
2.155 +
2.156 + ssDevs = wimax.Install(ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
2.157 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_SIMPLE);
2.158 + bsDevs = wimax.Install(bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION,
2.159 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_SIMPLE);
2.160 +
2.161 + Ptr<WimaxSubscriberStationNetDevice> ss[nbSS];
2.162 +
2.163 + for (int i = 0; i < nbSS; i++)
2.164 + {
2.165 + ss[i] = ssDevs.Get(i)->GetObject<WimaxSubscriberStationNetDevice> ();
2.166 + ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_34);
2.167 + }
2.168 +
2.169 + Ptr<WimaxBaseStationNetDevice> bs[nbBS];
2.170 +
2.171 + for (int i = 0; i < nbBS; i++)
2.172 + {
2.173 + bs[i] = bsDevs.Get(i)->GetObject<WimaxBaseStationNetDevice> ();
2.174 + }
2.175 + mobility.Install(bsNodes);
2.176 + mobility.Install(ssNodes);
2.177 +
2.178 + InternetStackHelper stack;
2.179 + stack.Install(bsNodes);
2.180 + stack.Install(ssNodes);
2.181 +
2.182 + Ipv4AddressHelper address;
2.183 + address.SetBase("10.1.1.0", "255.255.255.0");
2.184 +
2.185 + Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
2.186 + Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
2.187 +
2.188 + /*------------------------------*/
2.189 + // wimax.SetupConnection (ss[0], ss[1], bs[0], parameterSet, QoSParameterSet::SCHEDULING_TYPE_UGS);
2.190 +
2.191 + /* wimax.ClassifierConfig(ss[0], ss[1], bs[0],
2.192 + SSinterfaces.GetAddress(0), SSinterfaces.GetAddress(1),
2.193 + 0, 101, 17, 100);*/
2.194 +
2.195 +
2.196 +
2.197 + PacketSocketAddress socket;
2.198 + ApplicationContainer apps;
2.199 +
2.200 + socket.SetSingleDevice (ssDevs.Get (0)->GetIfIndex ());
2.201 + socket.SetPhysicalAddress (ssDevs.Get (1)->GetAddress ());
2.202 + socket.SetProtocol (1);
2.203 +
2.204 + OnOffHelper onoff1 ("ns3::PacketSocketFactory", Address (socket));
2.205 + onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.0005)));
2.206 + onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
2.207 + onoff1.SetAttribute ("DataRate", DataRateValue (DataRate("600kbps")));
2.208 + onoff1.SetAttribute ("PacketSize", UintegerValue (100));
2.209 + apps = onoff1.Install (ssNodes.Get (0));
2.210 + apps.Start (Seconds (1.0));
2.211 + apps.Stop (Seconds (duration));
2.212 +
2.213 + QoSParameterSet *parameterSet = wimax.CreateNrtpsParameterSet (10000);
2.214 + wimax.SetupConnection (ss[0], bs[0],parameterSet, QoSParameterSet::SCHEDULING_TYPE_NRTPS);
2.215 + wimax.SetupConnection (ss[1], bs[0],parameterSet, QoSParameterSet::SCHEDULING_TYPE_NRTPS);
2.216 +
2.217 + /* wimax.ClassifierConfig(ss[0], ss[1], bs[0],
2.218 + SSinterfaces.GetAddress(0), SSinterfaces.GetAddress(1),
2.219 + 0, 101, 17, 101);*/
2.220 +
2.221 + /* BE connections */
2.222 +
2.223 +
2.224 + for (int i = 2; i < nbSS; i+=2)
2.225 + {
2.226 +
2.227 + socket.SetSingleDevice (ssDevs.Get (i)->GetIfIndex ());
2.228 + socket.SetPhysicalAddress (ssDevs.Get (i + 1)->GetAddress ());
2.229 + socket.SetProtocol (1);
2.230 +
2.231 + OnOffHelper onoff1 ("ns3::PacketSocketFactory", Address (socket));
2.232 + onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.0005)));
2.233 + onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
2.234 + onoff1.SetAttribute ("DataRate", DataRateValue (DataRate("600kbps")));
2.235 + onoff1.SetAttribute ("PacketSize", UintegerValue (100));
2.236 + apps = onoff1.Install (ssNodes.Get (i));
2.237 + apps.Start (Seconds (1.0+(i/100)));
2.238 + apps.Stop (Seconds (duration));
2.239 +
2.240 + }
2.241 +
2.242 +
2.243 + QoSParameterSet* NRTPSparameterSet[nbSS];
2.244 + // QoSParameterSet *parameterSet = wimax.CreateNrtpsParameterSet (10000);
2.245 + for (int i = 2; i < nbSS; i++)
2.246 + {
2.247 +
2.248 + NRTPSparameterSet[i] = wimax.CreateNrtpsParameterSet (1000);
2.249 +
2.250 + wimax.SetupConnection(ss[i], bs[0], NRTPSparameterSet[i], QoSParameterSet::SCHEDULING_TYPE_NRTPS);
2.251 + }
2.252 +
2.253 +
2.254 + Simulator::Stop(Seconds(duration + 1.0));
2.255 +
2.256 + std::ofstream ascii;
2.257 + ascii.open ("simple-wimax.tr");
2.258 + WimaxHelper::EnableAscii (ascii);
2.259 +
2.260 + // Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxSubscriberStationNetDevice/SSTx", MakeCallback (&SSTxTrace));
2.261 + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxBaseStationNetDevice/BSRx", MakeCallback (&BSRxTrace));
2.262 + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxSubscriberStationNetDevice/SSRx", MakeCallback (&SSRxTrace));
2.263 +
2.264 + InitTrace();
2.265 +
2.266 + NS_LOG_INFO("Starting simulation.....");
2.267 + Simulator::Run();
2.268 + Simulator::Destroy();
2.269 + PrintThroughput(20,10);
2.270 + PrintThroughputTotal(nCon, duration, nCon);
2.271 + NS_LOG_INFO("Done.");
2.272 +
2.273 + return 0;
2.274 +}
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/scratch/rtps_test.cc Wed Aug 12 08:58:14 2009 -0300
3.3 @@ -0,0 +1,272 @@
3.4 +#include "ns3/core-module.h"
3.5 +#include "ns3/common-module.h"
3.6 +#include "ns3/node-module.h"
3.7 +#include "ns3/helper-module.h"
3.8 +#include "ns3/mobility-module.h"
3.9 +#include "ns3/contrib-module.h"
3.10 +#include "ns3/wimax-module.h"
3.11 +#include <iostream>
3.12 +#include "ns3/global-route-manager.h"
3.13 +
3.14 +NS_LOG_COMPONENT_DEFINE ("rtPSWimaxSimulation");
3.15 +
3.16 +
3.17 +using namespace ns3;
3.18 +
3.19 +#define MAX_NODES 50
3.20 +#define MAX_TIME 30
3.21 +
3.22 +int throughput[MAX_NODES][MAX_TIME];
3.23 +int total;
3.24 +
3.25 +void
3.26 +InitTrace ()
3.27 +{
3.28 + for (int i=0; i<MAX_NODES; i++)
3.29 + {
3.30 + for (int j=0; j<MAX_TIME; j++)
3.31 + {
3.32 + throughput[i][j] = 0;
3.33 + }
3.34 + }
3.35 + total = 0;
3.36 +}
3.37 +
3.38 +int address2int(Mac48Address address) {
3.39 + uint8_t addr[6];
3.40 + address.CopyTo(addr);
3.41 + return addr[5];
3.42 +}
3.43 +
3.44 +void
3.45 +SSTxTrace (std::string context, Ptr<const PacketBurst> burst, Mac48Address address, Ptr<ConnectionIdentifier> cid, WimaxPhy::ModulationType modulationType)
3.46 +{
3.47 + std::cout << "TraceDelay: TX (SS) address: " << address
3.48 + << ", CID: " << cid->GetIdentifier ()
3.49 + << ", time: " << Simulator::Now ().GetSeconds ()
3.50 + << ", burst size: " << burst->GetSize ()
3.51 + << ", packets: " << burst->GetNPackets ()<< std::endl;
3.52 + // << ", modulation: " << ToString (modulationType) << std::endl;
3.53 +}
3.54 +
3.55 +void
3.56 +BSRxTrace (std::string context, Ptr<const Packet> packet, Mac48Address address, Ptr<ConnectionIdentifier> cid)
3.57 +{
3.58 + std::cout << "TraceDelay: RX (BS), from: " << address
3.59 + << ", CID: " << cid->GetIdentifier ()
3.60 + << ", time: " << Simulator::Now ().GetSeconds ()
3.61 + << ", packet size: " << packet->GetSize ()
3.62 + << ", packet uid: " << packet->GetUid ()
3.63 + << std::endl;
3.64 + int node_id;
3.65 + int int_time;
3.66 + if ( cid->GetIdentifier () > 40000 ) {
3.67 + node_id = address2int ( address );
3.68 + int_time = int (Simulator::Now ().GetSeconds ());
3.69 + throughput [node_id][int_time] += packet->GetSize ();
3.70 + total += packet->GetSize ();
3.71 + // address2int(Mac48Address address)
3.72 + }
3.73 +
3.74 +}
3.75 +
3.76 +void
3.77 +SSRxTrace (std::string context, Ptr<const Packet> packet, Mac48Address address, Ptr<ConnectionIdentifier> cid)
3.78 +{
3.79 + std::cout << "RX (SS) address: " << address
3.80 + << ", CID: " << cid->GetIdentifier ()
3.81 + << ", time: " << Simulator::Now ().GetSeconds ()
3.82 + << ", packet size: " << packet->GetSize ()
3.83 + << ", packet uid: " << packet->GetUid ()
3.84 + //<< ", packet: " << *packet
3.85 + << std::endl;
3.86 +}
3.87 +
3.88 +
3.89 +void
3.90 +PrintThroughput(int nodes, int time) {
3.91 + FILE * f = fopen("throughput.dat", "w");
3.92 + for ( int i=0; i<time; i++ )
3.93 + {
3.94 + for ( int j=0; j<nodes; j++ )
3.95 + {
3.96 + fprintf(f,"%d\t",throughput[j][i]);
3.97 + }
3.98 + fprintf(f,"\n");
3.99 + }
3.100 + return;
3.101 +}
3.102 +
3.103 +void
3.104 +PrintThroughputTotal(int nodes, int time, int nConnection) {
3.105 + char buf[100];
3.106 + sprintf(buf, "throughput-%02d.dat", nConnection);
3.107 + FILE * f = fopen( buf, "w");
3.108 +
3.109 + for ( int i=1; i<time; i++ )
3.110 + {
3.111 + int total = 0;
3.112 + for ( int j=1; j<=nodes; j++ )
3.113 + {
3.114 + //fprintf(f,"%d\t",throughput[j][i]);
3.115 + total += throughput[j][i];
3.116 + }
3.117 + fprintf(f,"%d\n", total);
3.118 + }
3.119 + fprintf(f,"\nTotal:%d",total);
3.120 + return;
3.121 +}
3.122 +
3.123 +
3.124 +
3.125 +int
3.126 +main(int argc, char *argv[])
3.127 +{
3.128 +
3.129 + int nbSS = 1*2, duration = 10, nbBS = 1; //default values
3.130 + int nCon = 2;
3.131 + CommandLine cmd;
3.132 + cmd.AddValue ("nConnection", "Number of connections", nCon);
3.133 + // cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
3.134 + cmd.Parse (argc, argv);
3.135 +
3.136 +
3.137 + nbSS = nCon * 2;
3.138 +
3.139 + LogComponentEnable("UdpClientApplication", LOG_LEVEL_INFO);
3.140 + LogComponentEnable("UdpServerApplication", LOG_LEVEL_INFO);
3.141 +
3.142 + TimeStepPrecision::Set(TimeStepPrecision::FS);
3.143 +
3.144 + WimaxHelper wimax;
3.145 + MobilityHelper mobility;
3.146 + NodeContainer ssNodes;
3.147 + NodeContainer bsNodes;
3.148 + NetDeviceContainer ssDevs, bsDevs;
3.149 +
3.150 +
3.151 + //**
3.152 +
3.153 + ssNodes.Create(nbSS);
3.154 + bsNodes.Create(nbBS);
3.155 +
3.156 + ssDevs = wimax.Install(ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
3.157 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_MBQOS);
3.158 + bsDevs = wimax.Install(bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION,
3.159 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_MBQOS);
3.160 +
3.161 + Ptr<WimaxSubscriberStationNetDevice> ss[nbSS];
3.162 +
3.163 + for (int i = 0; i < nbSS; i++)
3.164 + {
3.165 + ss[i] = ssDevs.Get(i)->GetObject<WimaxSubscriberStationNetDevice> ();
3.166 + ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_34);
3.167 + }
3.168 +
3.169 + Ptr<WimaxBaseStationNetDevice> bs[nbBS];
3.170 +
3.171 + for (int i = 0; i < nbBS; i++)
3.172 + {
3.173 + bs[i] = bsDevs.Get(i)->GetObject<WimaxBaseStationNetDevice> ();
3.174 + }
3.175 + mobility.Install(bsNodes);
3.176 + mobility.Install(ssNodes);
3.177 +
3.178 + InternetStackHelper stack;
3.179 + stack.Install(bsNodes);
3.180 + stack.Install(ssNodes);
3.181 +
3.182 + Ipv4AddressHelper address;
3.183 + address.SetBase("10.1.1.0", "255.255.255.0");
3.184 +
3.185 + Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
3.186 + Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
3.187 +
3.188 + /*------------------------------*/
3.189 + // wimax.SetupConnection (ss[0], ss[1], bs[0], parameterSet, QoSParameterSet::SCHEDULING_TYPE_UGS);
3.190 +
3.191 + /* wimax.ClassifierConfig(ss[0], ss[1], bs[0],
3.192 + SSinterfaces.GetAddress(0), SSinterfaces.GetAddress(1),
3.193 + 0, 101, 17, 100);*/
3.194 +
3.195 +
3.196 +
3.197 + PacketSocketAddress socket;
3.198 + ApplicationContainer apps;
3.199 +
3.200 + socket.SetSingleDevice (ssDevs.Get (0)->GetIfIndex ());
3.201 + socket.SetPhysicalAddress (ssDevs.Get (1)->GetAddress ());
3.202 + socket.SetProtocol (1);
3.203 +
3.204 + OnOffHelper onoff1 ("ns3::PacketSocketFactory", Address (socket));
3.205 + onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.0005)));
3.206 + onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
3.207 + onoff1.SetAttribute ("DataRate", DataRateValue (DataRate("600kbps")));
3.208 + onoff1.SetAttribute ("PacketSize", UintegerValue (100));
3.209 + apps = onoff1.Install (ssNodes.Get (0));
3.210 + apps.Start (Seconds (1.0));
3.211 + apps.Stop (Seconds (duration));
3.212 +
3.213 + QoSParameterSet *parameterSet = wimax.CreateRtpsParameterSet (100, 5000, 7000, 200);
3.214 + wimax.SetupConnection (ss[0], bs[0],parameterSet, QoSParameterSet::SCHEDULING_TYPE_RTPS);
3.215 + wimax.SetupConnection (ss[1], bs[0],parameterSet, QoSParameterSet::SCHEDULING_TYPE_RTPS);
3.216 +
3.217 + /* wimax.ClassifierConfig(ss[0], ss[1], bs[0],
3.218 + SSinterfaces.GetAddress(0), SSinterfaces.GetAddress(1),
3.219 + 0, 101, 17, 101);*/
3.220 +
3.221 + /* BE connections */
3.222 +
3.223 +
3.224 + for (int i = 2; i < nbSS; i+=2)
3.225 + {
3.226 +
3.227 + socket.SetSingleDevice (ssDevs.Get (i)->GetIfIndex ());
3.228 + socket.SetPhysicalAddress (ssDevs.Get (i + 1)->GetAddress ());
3.229 + socket.SetProtocol (1);
3.230 +
3.231 + OnOffHelper onoff1 ("ns3::PacketSocketFactory", Address (socket));
3.232 + onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.0005)));
3.233 + onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
3.234 + onoff1.SetAttribute ("DataRate", DataRateValue (DataRate("600kbps")));
3.235 + onoff1.SetAttribute ("PacketSize", UintegerValue (100));
3.236 + apps = onoff1.Install (ssNodes.Get (i));
3.237 + apps.Start (Seconds (1.0+(i/100)));
3.238 + apps.Stop (Seconds (duration));
3.239 +
3.240 + }
3.241 +
3.242 +
3.243 + QoSParameterSet* NRTPSparameterSet[nbSS];
3.244 +
3.245 + for (int i = 2; i < nbSS; i++)
3.246 + {
3.247 +
3.248 +
3.249 + NRTPSparameterSet[i] = wimax.CreateNrtpsParameterSet(400);
3.250 +
3.251 + wimax.SetupConnection(ss[i], bs[0], NRTPSparameterSet[i], QoSParameterSet::SCHEDULING_TYPE_NRTPS);
3.252 + }
3.253 +
3.254 +
3.255 + Simulator::Stop(Seconds(duration + 1.0));
3.256 +
3.257 + std::ofstream ascii;
3.258 + ascii.open ("simple-wimax.tr");
3.259 + WimaxHelper::EnableAscii (ascii);
3.260 +
3.261 + // Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxSubscriberStationNetDevice/SSTx", MakeCallback (&SSTxTrace));
3.262 + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxBaseStationNetDevice/BSRx", MakeCallback (&BSRxTrace));
3.263 + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxSubscriberStationNetDevice/SSRx", MakeCallback (&SSRxTrace));
3.264 +
3.265 + InitTrace();
3.266 +
3.267 + NS_LOG_INFO("Starting simulation.....");
3.268 + Simulator::Run();
3.269 + Simulator::Destroy();
3.270 + PrintThroughput(20,10);
3.271 + PrintThroughputTotal(nCon, duration, nCon);
3.272 + NS_LOG_INFO("Done.");
3.273 +
3.274 + return 0;
3.275 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/scratch/ugs_grant_test.cc Wed Aug 12 08:58:14 2009 -0300
4.3 @@ -0,0 +1,280 @@
4.4 +#include "ns3/core-module.h"
4.5 +#include "ns3/common-module.h"
4.6 +#include "ns3/node-module.h"
4.7 +#include "ns3/helper-module.h"
4.8 +#include "ns3/mobility-module.h"
4.9 +#include "ns3/contrib-module.h"
4.10 +#include "ns3/wimax-module.h"
4.11 +#include <iostream>
4.12 +#include "ns3/global-route-manager.h"
4.13 +
4.14 +NS_LOG_COMPONENT_DEFINE ("rtPSWimaxSimulation");
4.15 +
4.16 +
4.17 +using namespace ns3;
4.18 +
4.19 +#define MAX_NODES 50
4.20 +#define MAX_TIME 30
4.21 +
4.22 +int throughput[MAX_NODES][MAX_TIME];
4.23 +int total;
4.24 +
4.25 +void
4.26 +InitTrace ()
4.27 +{
4.28 + for (int i=0; i<MAX_NODES; i++)
4.29 + {
4.30 + for (int j=0; j<MAX_TIME; j++)
4.31 + {
4.32 + throughput[i][j] = 0;
4.33 + }
4.34 + }
4.35 + total = 0;
4.36 +}
4.37 +
4.38 +int address2int(Mac48Address address) {
4.39 + uint8_t addr[6];
4.40 + address.CopyTo(addr);
4.41 + return addr[5];
4.42 +}
4.43 +
4.44 +void
4.45 +SSTxTrace (std::string context, Ptr<const PacketBurst> burst, Mac48Address address, Ptr<ConnectionIdentifier> cid, WimaxPhy::ModulationType modulationType)
4.46 +{
4.47 + std::cout << "TraceDelay: TX (SS) address: " << address
4.48 + << ", CID: " << cid->GetIdentifier ()
4.49 + << ", time: " << Simulator::Now ().GetSeconds ()
4.50 + << ", burst size: " << burst->GetSize ()
4.51 + << ", packets: " << burst->GetNPackets ()<< std::endl;
4.52 + // << ", modulation: " << ToString (modulationType) << std::endl;
4.53 +}
4.54 +
4.55 +void
4.56 +BSRxTrace (std::string context, Ptr<const Packet> packet, Mac48Address address, Ptr<ConnectionIdentifier> cid)
4.57 +{
4.58 + std::cout << "TraceDelay: RX (BS), from: " << address
4.59 + << ", CID: " << cid->GetIdentifier ()
4.60 + << ", time: " << Simulator::Now ().GetSeconds ()
4.61 + << ", packet size: " << packet->GetSize ()
4.62 + << ", packet uid: " << packet->GetUid ()
4.63 + << std::endl;
4.64 + int node_id;
4.65 + int int_time;
4.66 + if ( cid->GetIdentifier () > 40000 ) {
4.67 + node_id = address2int ( address );
4.68 + int_time = int (Simulator::Now ().GetSeconds ());
4.69 + throughput [node_id][int_time] += packet->GetSize ();
4.70 + total += packet->GetSize ();
4.71 + // address2int(Mac48Address address)
4.72 + }
4.73 +
4.74 +}
4.75 +
4.76 +void
4.77 +SSRxTrace (std::string context, Ptr<const Packet> packet, Mac48Address address, Ptr<ConnectionIdentifier> cid)
4.78 +{
4.79 + std::cout << "RX (SS) address: " << address
4.80 + << ", CID: " << cid->GetIdentifier ()
4.81 + << ", time: " << Simulator::Now ().GetSeconds ()
4.82 + << ", packet size: " << packet->GetSize ()
4.83 + << ", packet uid: " << packet->GetUid ()
4.84 + //<< ", packet: " << *packet
4.85 + << std::endl;
4.86 +}
4.87 +
4.88 +
4.89 +void
4.90 +PrintThroughput(int nodes, int time) {
4.91 + FILE * f = fopen("throughput.dat", "w");
4.92 + for ( int i=0; i<time; i++ )
4.93 + {
4.94 + for ( int j=0; j<nodes; j++ )
4.95 + {
4.96 + fprintf(f,"%d\t",throughput[j][i]);
4.97 + }
4.98 + fprintf(f,"\n");
4.99 + }
4.100 + return;
4.101 +}
4.102 +
4.103 +void
4.104 +PrintThroughputTotal(int nodes, int time, int nConnection) {
4.105 + char buf[100];
4.106 + sprintf(buf, "throughput-%02d.dat", nConnection);
4.107 + FILE * f = fopen( buf, "w");
4.108 +
4.109 + for ( int i=1; i<time; i++ )
4.110 + {
4.111 + int total = 0;
4.112 + for ( int j=1; j<=nodes; j++ )
4.113 + {
4.114 + //fprintf(f,"%d\t",throughput[j][i]);
4.115 + total += throughput[j][i];
4.116 + }
4.117 + fprintf(f,"%d\n", total);
4.118 + }
4.119 + fprintf(f,"\nTotal:%d",total);
4.120 + return;
4.121 +}
4.122 +
4.123 +
4.124 +
4.125 +int
4.126 +main(int argc, char *argv[])
4.127 +{
4.128 +
4.129 + int nbSS = 1*2, duration = 10, nbBS = 1; //default values
4.130 + int nCon = 20;
4.131 + CommandLine cmd;
4.132 + cmd.AddValue ("nConnection", "Number of connections", nCon);
4.133 + // cmd.AddValue ("verbose", "Tell echo applications to log if true", verbose);
4.134 + cmd.Parse (argc, argv);
4.135 +
4.136 +
4.137 + nbSS = nCon * 2;
4.138 +
4.139 + LogComponentEnable("UdpClientApplication", LOG_LEVEL_INFO);
4.140 + LogComponentEnable("UdpServerApplication", LOG_LEVEL_INFO);
4.141 +
4.142 + TimeStepPrecision::Set(TimeStepPrecision::FS);
4.143 +
4.144 + WimaxHelper wimax;
4.145 + MobilityHelper mobility;
4.146 + NodeContainer ssNodes;
4.147 + NodeContainer bsNodes;
4.148 + NetDeviceContainer ssDevs, bsDevs;
4.149 +
4.150 +
4.151 + //**
4.152 +
4.153 + ssNodes.Create(nbSS);
4.154 + bsNodes.Create(nbBS);
4.155 +
4.156 + ssDevs = wimax.Install(ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION,
4.157 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_MBQOS);
4.158 + bsDevs = wimax.Install(bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION,
4.159 + WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_MBQOS);
4.160 +
4.161 + Ptr<WimaxSubscriberStationNetDevice> ss[nbSS];
4.162 +
4.163 + for (int i = 0; i < nbSS; i++)
4.164 + {
4.165 + ss[i] = ssDevs.Get(i)->GetObject<WimaxSubscriberStationNetDevice> ();
4.166 + ss[i]->SetModulationType(WimaxPhy::MODULATION_TYPE_QAM16_34);
4.167 + }
4.168 +
4.169 + Ptr<WimaxBaseStationNetDevice> bs[nbBS];
4.170 +
4.171 + for (int i = 0; i < nbBS; i++)
4.172 + {
4.173 + bs[i] = bsDevs.Get(i)->GetObject<WimaxBaseStationNetDevice> ();
4.174 + }
4.175 + mobility.Install(bsNodes);
4.176 + mobility.Install(ssNodes);
4.177 +
4.178 + InternetStackHelper stack;
4.179 + stack.Install(bsNodes);
4.180 + stack.Install(ssNodes);
4.181 +
4.182 + Ipv4AddressHelper address;
4.183 + address.SetBase("10.1.1.0", "255.255.255.0");
4.184 +
4.185 + Ipv4InterfaceContainer SSinterfaces = address.Assign(ssDevs);
4.186 + Ipv4InterfaceContainer BSinterface = address.Assign(bsDevs);
4.187 +
4.188 + /*------------------------------*/
4.189 + int port_number = 101; //initial port_number
4.190 +
4.191 + /* UGS connections */
4.192 +
4.193 + //starting_time=((rand()%1000)/1000)+2;
4.194 + // duration_time=(rand() %1000)/100;
4.195 +
4.196 + UdpServerHelper udpServer (port_number);
4.197 +
4.198 + ApplicationContainer serverApps = udpServer.Install (ssNodes.Get (1));
4.199 + serverApps.Start (Seconds (1.0));
4.200 + serverApps.Stop (Seconds (15));
4.201 +
4.202 + UdpClientHelper udpClient (SSinterfaces.GetAddress (1), port_number);
4.203 + udpClient.SetAttribute ("MaxPackets", UintegerValue (1200));
4.204 + udpClient.SetAttribute ("Interval", TimeValue (Seconds (0.1)));
4.205 + udpClient.SetAttribute ("PacketSize", UintegerValue (128));
4.206 +
4.207 + ApplicationContainer clientApps = udpClient.Install (ssNodes.Get (0));
4.208 + clientApps.Start (Seconds (1));
4.209 + clientApps.Stop (Seconds (duration));
4.210 +
4.211 + QoSParameterSet *parameterSet = wimax.CreateUgsParameterSet (100000, 100, 100);
4.212 + wimax.SetupConnection (ss[0], bs[0],parameterSet, QoSParameterSet::SCHEDULING_TYPE_UGS);
4.213 + wimax.SetupConnection (ss[1], bs[0],parameterSet, QoSParameterSet::SCHEDULING_TYPE_UGS);
4.214 + // wimax.SetupConnection (ss[0], ss[1], bs[0], parameterSet, QoSParameterSet::SCHEDULING_TYPE_UGS);
4.215 +
4.216 + wimax.ClassifierConfig(ss[0], ss[1], bs[0],
4.217 + SSinterfaces.GetAddress(0), SSinterfaces.GetAddress(1),
4.218 + 0, 101, 17, 100);
4.219 +
4.220 + std::cout << "\tSetup UGS connection between \n\tss[ "
4.221 + << SSinterfaces.GetAddress (0) << " ] and \n\tss["
4.222 + << SSinterfaces.GetAddress (1) << " ]"
4.223 + "\n\tport number: " << port_number
4.224 + << std::endl;
4.225 +
4.226 +
4.227 + /* BE connections */
4.228 +
4.229 + PacketSocketAddress socket;
4.230 + ApplicationContainer apps;
4.231 +
4.232 + for (int i = 2; i < nbSS; i+=2)
4.233 + {
4.234 +
4.235 + socket.SetSingleDevice (ssDevs.Get (i)->GetIfIndex ());
4.236 + socket.SetPhysicalAddress (ssDevs.Get (i + 1)->GetAddress ());
4.237 + socket.SetProtocol (1);
4.238 +
4.239 + OnOffHelper onoff1 ("ns3::PacketSocketFactory", Address (socket));
4.240 + onoff1.SetAttribute ("OnTime", RandomVariableValue (ConstantVariable (0.0005)));
4.241 + onoff1.SetAttribute ("OffTime", RandomVariableValue (ConstantVariable (0)));
4.242 + onoff1.SetAttribute ("DataRate", DataRateValue (DataRate("600kbps")));
4.243 + onoff1.SetAttribute ("PacketSize", UintegerValue (100));
4.244 + apps = onoff1.Install (ssNodes.Get (i));
4.245 + apps.Start (Seconds (1.0+(i/100)));
4.246 + apps.Stop (Seconds (duration));
4.247 +
4.248 + }
4.249 +
4.250 +
4.251 + QoSParameterSet* BEparameterSet[nbSS];
4.252 +
4.253 + for (int i = 2; i < nbSS; i++)
4.254 + {
4.255 +
4.256 +
4.257 + BEparameterSet[i] = wimax.CreateBeParameterSet(0);
4.258 +
4.259 + wimax.SetupConnection(ss[i], bs[0], BEparameterSet[i], QoSParameterSet::SCHEDULING_TYPE_BE);
4.260 + }
4.261 +
4.262 +
4.263 + Simulator::Stop(Seconds(duration + 1.0));
4.264 +
4.265 + std::ofstream ascii;
4.266 + ascii.open ("simple-wimax.tr");
4.267 + WimaxHelper::EnableAscii (ascii);
4.268 +
4.269 + // Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxSubscriberStationNetDevice/SSTx", MakeCallback (&SSTxTrace));
4.270 + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxBaseStationNetDevice/BSRx", MakeCallback (&BSRxTrace));
4.271 + Config::Connect ("/NodeList/*/DeviceList/*/$ns3::WimaxSubscriberStationNetDevice/SSRx", MakeCallback (&SSRxTrace));
4.272 +
4.273 + InitTrace();
4.274 +
4.275 + NS_LOG_INFO("Starting simulation.....");
4.276 + Simulator::Run();
4.277 + Simulator::Destroy();
4.278 + PrintThroughput(20,10);
4.279 + PrintThroughputTotal(nCon, duration, nCon);
4.280 + NS_LOG_INFO("Done.");
4.281 +
4.282 + return 0;
4.283 +}
5.1 --- a/scratch/wimax.cc Tue Aug 11 16:41:52 2009 -0300
5.2 +++ b/scratch/wimax.cc Wed Aug 12 08:58:14 2009 -0300
5.3 @@ -179,8 +179,8 @@
5.4 bsNodes.Create (number_bs);
5.5 ssNodes.Create (number_ss);
5.6
5.7 - bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_SIMPLE);
5.8 - ssDevs = wimax.Install (ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_SIMPLE);
5.9 + bsDevs = wimax.Install (bsNodes, WimaxHelper::DEVICE_TYPE_BASE_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_MBQOS);
5.10 + ssDevs = wimax.Install (ssNodes, WimaxHelper::DEVICE_TYPE_SUBSCRIBER_STATION, WimaxHelper::SIMPLE_PHY_TYPE_OFDM, WimaxHelper::SCHED_TYPE_MBQOS);
5.11
5.12
5.13 std::vector<Ptr<WimaxBaseStationNetDevice> > bs;
6.1 --- a/src/devices/wimax/ul-job.h Tue Aug 11 16:41:52 2009 -0300
6.2 +++ b/src/devices/wimax/ul-job.h Wed Aug 12 08:58:14 2009 -0300
6.3 @@ -1,4 +1,23 @@
6.4 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
6.5 +/*
6.6 + * Copyright (c)
6.7 + *
6.8 + * This program is free software; you can redistribute it and/or modify
6.9 + * it under the terms of the GNU General Public License version 2 as
6.10 + * published by the Free Software Foundation;
6.11 + *
6.12 + * This program is distributed in the hope that it will be useful,
6.13 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
6.14 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6.15 + * GNU General Public License for more details.
6.16 + *
6.17 + * You should have received a copy of the GNU General Public License
6.18 + * along with this program; if not, write to the Free Software
6.19 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
6.20 + *
6.21 + * Author: Juliana Freitag Borin, Flavio Kubota and Nelson L.
6.22 + * S. da Fonseca - wimaxgroup@lrc.ic.unicamp.br
6.23 + */
6.24
6.25 #ifndef UL_JOB_H
6.26 #define UL_JOB_H
6.27 @@ -6,7 +25,8 @@
6.28 #include <stdint.h>
6.29 #include "ns3/header.h"
6.30 #include "ss-record.h"
6.31 -
6.32 +#include "service-flow.h"
6.33 +#include "service-flow-record.h"
6.34
6.35 namespace ns3 {
6.36
6.37 @@ -106,9 +126,27 @@
6.38 bool operator()(PriorityUlJob& left, PriorityUlJob& right) const
6.39 { //return true if left is logically less then right for given comparison
6.40 if(left.GetPriority () < right.GetPriority ())
6.41 - return true;
6.42 - else
6.43 - return false;
6.44 + {
6.45 + return true;
6.46 + }
6.47 + else if (left.GetPriority () == right.GetPriority ())
6.48 + {
6.49 + //serviceFlow->GetRecord ()->GetBacklogged ()
6.50 + int32_t leftBacklogged = left.GetUlJob ()->GetServiceFlow ()->GetRecord ()->GetBacklogged ();
6.51 + int32_t rightBacklogged = left.GetUlJob ()->GetServiceFlow ()->GetRecord ()->GetBacklogged ();
6.52 + if (leftBacklogged <= rightBacklogged)
6.53 + {
6.54 + return true;
6.55 + }
6.56 + else
6.57 + {
6.58 + return false;
6.59 + }
6.60 + }
6.61 + else
6.62 + {
6.63 + return false;
6.64 + }
6.65 };
6.66 };
6.67
7.1 --- a/src/devices/wimax/uplink-scheduler-mbqos.cc Tue Aug 11 16:41:52 2009 -0300
7.2 +++ b/src/devices/wimax/uplink-scheduler-mbqos.cc Wed Aug 12 08:58:14 2009 -0300
7.3 @@ -41,16 +41,23 @@
7.4
7.5 NS_OBJECT_ENSURE_REGISTERED (UplinkSchedulerMBQoS);
7.6
7.7 - UplinkSchedulerMBQoS::UplinkSchedulerMBQoS()
7.8 + UplinkSchedulerMBQoS::UplinkSchedulerMBQoS ()
7.9 {
7.10 +
7.11 }
7.12
7.13 - UplinkSchedulerMBQoS::~UplinkSchedulerMBQoS(void)
7.14 + UplinkSchedulerMBQoS::~UplinkSchedulerMBQoS (void)
7.15 {
7.16 m_bs = 0;
7.17 m_uplinkAllocations.clear();
7.18 }
7.19
7.20 + void
7.21 + UplinkSchedulerMBQoS::InitOnce ()
7.22 + {
7.23 + UplinkSchedWindowTimer ();
7.24 + }
7.25 +
7.26 uint8_t
7.27 UplinkSchedulerMBQoS::GetNrIrOppsAllocated(void) const
7.28 {
7.29 @@ -147,9 +154,17 @@
7.30 void
7.31 UplinkSchedulerMBQoS::UplinkSchedWindowTimer (void)
7.32 {
7.33 + int windowSize = 1; // in seconds
7.34 int32_t min_bw = 0;
7.35 +
7.36 + if (!m_bs->GetSSManager ())
7.37 + {
7.38 + Simulator::Schedule (Seconds (windowSize), &UplinkSchedulerMBQoS::UplinkSchedWindowTimer, this);
7.39 + return ;
7.40 + }
7.41 +
7.42 std::vector<SSRecord*> *ssRecords = m_bs->GetSSManager ()->GetSSRecords ();
7.43 - int windowSize = 1; // in seconds
7.44 +
7.45
7.46 /* For each SS */
7.47 for (std::vector<SSRecord*>::iterator iter = ssRecords->begin ();
7.48 @@ -167,7 +182,7 @@
7.49 (serviceFlow->GetSchedulingType () == QoSParameterSet::SCHEDULING_TYPE_NRTPS ))
7.50 {
7.51 QoSParameterSet *qosParameterSet = serviceFlow-> GetParameterSet ();
7.52 - min_bw = (int) ceil(qosParameterSet->GetMinReservedTrafficRate () / windowSize );
7.53 + min_bw = (int) ceil(qosParameterSet->GetMinReservedTrafficRate ());
7.54
7.55 /* This way we can compensate flows which did not get min_bw in the previous window */
7.56 if ((serviceFlow->GetRecord ()->GetBacklogged () > 0) && (serviceFlow->GetRecord ()->GetBwSinceLastExpiry () < min_bw))
7.57 @@ -188,7 +203,7 @@
7.58 }
7.59 }
7.60
7.61 - Simulator::Schedule( Seconds(1), &UplinkSchedulerMBQoS::UplinkSchedWindowTimer, this);
7.62 + Simulator::Schedule (Seconds (windowSize), &UplinkSchedulerMBQoS::UplinkSchedWindowTimer, this);
7.63 }
7.64
7.65 void
7.66 @@ -230,15 +245,6 @@
7.67
7.68 if (availableSymbols >= allocationSize)
7.69 {
7.70 - /*
7.71 - #ifdef JDEBUG2
7.72 - std::cout
7.73 - << "BS uplink scheduler, invited ranging allocation, size: "
7.74 - << allocationSize << " symbols" << ", modulation: BPSK 1/2"
7.75 - << std::endl;
7.76 - #endif
7.77 - */
7.78 -
7.79 AddUplinkAllocation(ulMapIe, allocationSize,
7.80 symbolsToAllocation, availableSymbols);
7.81 }
7.82 @@ -258,15 +264,6 @@
7.83 ulMapIe.SetUiuc(m_bs->GetBurstProfileManager()->GetBurstProfile(
7.84 modulationType, WimaxNetDevice::DIRECTION_UPLINK));
7.85
7.86 - /*
7.87 - #ifdef JDEBUG2
7.88 - std::cout << "BS uplink scheduler, creating allocations for SS (Basic CID: " << (uint32_t) cid->GetIdentifier () << ")"
7.89 - << ", modulation: " << modulationType
7.90 - << ", UIUC: " << (uint32_t) ulMapIe.GetUiuc ()
7.91 - << std::endl;
7.92 - #endif
7.93 - */
7.94 -
7.95 //establish service flows for SS
7.96 if (ssRecord-> GetRangingStatus()
7.97 == WimaxNetDevice::RANGING_STATUS_SUCCESS
7.98 @@ -282,14 +279,6 @@
7.99
7.100 if (availableSymbols >= allocationSize)
7.101 {
7.102 - /*
7.103 - #ifdef JDEBUG2
7.104 - std::cout
7.105 - << "BS uplink scheduler, DSA allocation, size: "
7.106 - << allocationSize << std::endl;
7.107 - #endif
7.108 - */
7.109 -
7.110 AddUplinkAllocation(ulMapIe, allocationSize,
7.111 symbolsToAllocation, availableSymbols);
7.112 allocationForDsa = true;
7.113 @@ -314,7 +303,6 @@
7.114 {
7.115 /*allocating grants for data transmission for UGS flows (Data Grant Burst Type IEs, 6.3.7.4.3.3)
7.116 (grant has been referred by different names e.g. transmission opportunity, slot, uplink allocation, etc)*/
7.117 -
7.118 if (ssRecord->GetHasServiceFlowUgs())
7.119 {
7.120
7.121 @@ -324,18 +312,20 @@
7.122 Time uInterval = MilliSeconds (ssRecord->GetServiceFlow(QoSParameterSet::SCHEDULING_TYPE_UGS)->GetParameterSet()->GetUnsolicitedGrantInterval());
7.123
7.124 Scalar frame = ((timestamp - Simulator::Now ()) / frame_duration);
7.125 -/*
7.126 +
7.127 if (frame.GetDouble() <= 1)
7.128 - {
7.129 + {/*
7.130 UlJob *jobUGS = new UlJob ();
7.131 jobUGS->SetSsRecord (ssRecord);
7.132 jobUGS->SetSchedulingType (QoSParameterSet::SCHEDULING_TYPE_UGS);
7.133 jobUGS->SetType (UNICAST_POLLING);
7.134 - EnqueueJob (UlJob::HIGH, *jobUGS);
7.135 - }*/
7.136 + EnqueueJob (UlJob::HIGH, *jobUGS);*/
7.137
7.138 - ServiceUnsolicitedGrants (ssRecord, QoSParameterSet::SCHEDULING_TYPE_UGS, ulMapIe,
7.139 - modulationType, symbolsToAllocation, availableSymbols);
7.140 + ServiceUnsolicitedGrants (ssRecord, QoSParameterSet::SCHEDULING_TYPE_UGS, ulMapIe,
7.141 + modulationType, symbolsToAllocation, availableSymbols);
7.142 + }
7.143 +
7.144 +
7.145
7.146 }
7.147
7.148 @@ -385,7 +375,6 @@
7.149
7.150
7.151 if (!m_uplinkJobs_high.empty()) {
7.152 - int x = m_uplinkJobs_high.size();
7.153 fprintf(stdout,"DEBUG: Queue size before high: %d\n", m_uplinkJobs_high.size());
7.154 }
7.155 /* Scheduling high priority queue */
7.156 @@ -572,10 +561,6 @@
7.157
7.158 UlJob job = *iter;
7.159
7.160 - /*std::cout << "Job info: " << job.GetSsRecord()->GetBasicCid()
7.161 - << std::endl;*/
7.162 -
7.163 -
7.164 if (job.GetSchedulingType() == QoSParameterSet::SCHEDULING_TYPE_RTPS)
7.165 {
7.166 ServiceFlow *serviceFlow = job.GetServiceFlow ();
7.167 @@ -745,28 +730,6 @@
7.168 allocationSize = m_bs->GetBandwidthManager()->CalculateAllocationSize(
7.169 ssRecord, serviceFlow);
7.170
7.171 - // Flavio : it will checked in CheckMinimumBandwidth
7.172 - //verifying that minimum reserved traffic rate of nrtPS flow is maintained
7.173 - /* if (serviceFlow->GetSchedulingType()
7.174 - == QoSParameterSet::SCHEDULING_TYPE_NRTPS)
7.175 - {
7.176 - Time currentTime = Simulator::Now();
7.177 - ServiceFlowRecord *record = serviceFlow->GetRecord();
7.178 - if (currentTime - record->GetGrantTimeStamp() > Seconds(1))
7.179 - {
7.180 - uint32_t bps = (record->GetBwSinceLastExpiry() * 8);
7.181 - if (bps
7.182 - < serviceFlow->GetParameterSet()->GetMinReservedTrafficRate())
7.183 - {
7.184 - ServiceBandwidthRequests(serviceFlow, schedulingType,
7.185 - ulMapIe, modulationType, symbolsToAllocation,
7.186 - availableSymbols);
7.187 - record->SetBwSinceLastExpiry(0);
7.188 - record->SetGrantTimeStamp(currentTime);
7.189 - }
7.190 - }
7.191 - }*/
7.192 -
7.193 if (availableSymbols < allocationSize)
7.194 break;
7.195
8.1 --- a/src/devices/wimax/uplink-scheduler-mbqos.h Tue Aug 11 16:41:52 2009 -0300
8.2 +++ b/src/devices/wimax/uplink-scheduler-mbqos.h Wed Aug 12 08:58:14 2009 -0300
8.3 @@ -15,7 +15,9 @@
8.4 * along with this program; if not, write to the Free Software
8.5 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
8.6 *
8.7 - * Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
8.8 + * Original Author: Jahanzeb Farooq <jahanzeb.farooq@sophia.inria.fr>
8.9 + *
8.10 + *
8.11 */
8.12
8.13 #ifndef UPLINK_SCHEDULER_MBQOS_H
8.14 @@ -122,6 +124,9 @@
8.15 void
8.16 ConfigureBs (Ptr<WimaxBaseStationNetDevice> bs);
8.17
8.18 + void
8.19 + InitOnce (void);
8.20 +
8.21 private:
8.22 Ptr<WimaxBaseStationNetDevice> m_bs;
8.23 std::list<OfdmUlMapIe> m_uplinkAllocations;
9.1 --- a/src/devices/wimax/uplink-scheduler.cc Tue Aug 11 16:41:52 2009 -0300
9.2 +++ b/src/devices/wimax/uplink-scheduler.cc Wed Aug 12 08:58:14 2009 -0300
9.3 @@ -58,6 +58,12 @@
9.4 m_uplinkAllocations.clear();
9.5 }
9.6
9.7 + void
9.8 + UplinkScheduler::InitOnce ()
9.9 + {
9.10 +
9.11 + }
9.12 +
9.13 uint8_t
9.14 UplinkScheduler::GetNrIrOppsAllocated(void) const
9.15 {
10.1 --- a/src/devices/wimax/uplink-scheduler.h Tue Aug 11 16:41:52 2009 -0300
10.2 +++ b/src/devices/wimax/uplink-scheduler.h Wed Aug 12 08:58:14 2009 -0300
10.3 @@ -90,6 +90,9 @@
10.4 virtual void
10.5 ConfigureBs (Ptr<WimaxBaseStationNetDevice> bs);
10.6
10.7 + virtual void
10.8 + InitOnce (void);
10.9 +
10.10 private:
10.11 Ptr<WimaxBaseStationNetDevice> m_bs;
10.12 std::list<OfdmUlMapIe> m_uplinkAllocations;
11.1 --- a/src/devices/wimax/wimax-bs-net-device.cc Tue Aug 11 16:41:52 2009 -0300
11.2 +++ b/src/devices/wimax/wimax-bs-net-device.cc Wed Aug 12 08:58:14 2009 -0300
11.3 @@ -102,9 +102,6 @@
11.4 LogComponentEnable("WimaxBaseStationNetDevice", LOG_LEVEL_INFO);
11.5 mbs_classifier = new IPCS_BS_Packet_classifier(this);
11.6 m_symbolDuration = Seconds(0);
11.7 - //m_uplinkScheduler->UplinkSchedWindowTimer();
11.8 - //m_uplinkSchedulert->UplinkSchedWindowTimer();
11.9 -
11.10 }
11.11
11.12 WimaxBaseStationNetDevice::~WimaxBaseStationNetDevice(void)
11.13 @@ -349,6 +346,8 @@
11.14 /* shall actually be 2 symbols = 1 (preamble) + 1 (bandwidth request header)
11.15 if bandwidth request header is implemented exactly as in spec, see Question 66 */
11.16 m_bwReqOppSize = 6;
11.17 +
11.18 + m_uplinkScheduler->InitOnce ();
11.19 }
11.20
11.21 void
12.1 --- a/src/devices/wimax/wimax-net-device.h Tue Aug 11 16:41:52 2009 -0300
12.2 +++ b/src/devices/wimax/wimax-net-device.h Wed Aug 12 08:58:14 2009 -0300
12.3 @@ -224,11 +224,6 @@
12.4 GetMobility(void);
12.5 void
12.6 SetMobility(Ptr<Object> mobility);
12.7 -/*
12.8 - Ptr<UplinkScheduler>
12.9 - GetUplinkScheduler(void);
12.10 - void
12.11 - SetUplinkScheduler (Ptr<UplinkScheduler> uplinkScheduler);*/
12.12
12.13 private:
12.14 virtual bool
13.1 --- a/src/devices/wimax/wscript Tue Aug 11 16:41:52 2009 -0300
13.2 +++ b/src/devices/wimax/wscript Wed Aug 12 08:58:14 2009 -0300
13.3 @@ -45,7 +45,6 @@
13.4 'connection-manager.cc',
13.5 'uplink-scheduler.cc',
13.6 'uplink-scheduler-mbqos.cc',
13.7 - 'uplink-scheduler-qos.cc',
13.8 'bs-scheduler.cc',
13.9 'wimax-mac-queue.cc',
13.10 'burst-profile-manager.cc',
13.11 @@ -116,7 +115,6 @@
13.12 'propagation.h',
13.13 'uplink-scheduler.h',
13.14 'uplink-scheduler-mbqos.h',
13.15 - 'uplink-scheduler-qos.h',
13.16 'ul-job.h',
13.17 'service-flow-record.h'
13.18 ]