diff --git a/src/lte/examples/lena-deactivate-bearer.cc b/src/lte/examples/lena-deactivate-bearer.cc index 03256ea4d..702e588be 100644 --- a/src/lte/examples/lena-deactivate-bearer.cc +++ b/src/lte/examples/lena-deactivate-bearer.cc @@ -1,238 +1,238 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) - * - * 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: Gaurav Sathe - */ - -#include "ns3/lte-helper.h" -#include "ns3/epc-helper.h" -#include "ns3/core-module.h" -#include "ns3/network-module.h" -#include "ns3/ipv4-global-routing-helper.h" -#include "ns3/internet-module.h" -#include "ns3/mobility-module.h" -#include "ns3/lte-module.h" -#include "ns3/applications-module.h" -#include "ns3/point-to-point-helper.h" -#include "ns3/config-store.h" -//#include "ns3/gtk-config-store.h" - -using namespace ns3; - -/** - * Sample simulation script for LTE+EPC. It instantiates one eNodeB, - * attaches three UE to eNodeB starts a flow for each UE to and from a remote host. - * It also instantiates one dedicated bearer per UE - */ -NS_LOG_COMPONENT_DEFINE ("BearerDeactivateExample"); -int -main (int argc, char *argv[]) -{ - - uint16_t numberOfNodes = 1; - uint16_t numberOfUeNodes = 3; - double simTime = 1.1; - double distance = 60.0; - double interPacketInterval = 100; - - // Command line arguments - CommandLine cmd; - cmd.AddValue ("numberOfNodes", "Number of eNodeBs + UE pairs", numberOfNodes); - cmd.AddValue ("simTime", "Total duration of the simulation [s])", simTime); - cmd.AddValue ("distance", "Distance between eNBs [m]", distance); - cmd.AddValue ("interPacketInterval", "Inter packet interval [ms])", interPacketInterval); - cmd.Parse (argc, argv); - - Ptr lteHelper = CreateObject (); - Ptr epcHelper = CreateObject (); - lteHelper->SetEpcHelper (epcHelper); - - ConfigStore inputConfig; - inputConfig.ConfigureDefaults (); - - // parse again so you can override default values from the command line - cmd.Parse (argc, argv); - - Ptr pgw = epcHelper->GetPgwNode (); - - // Enable Logging - LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); - - LogComponentEnable ("BearerDeactivateExample", LOG_LEVEL_ALL); - LogComponentEnable ("LteHelper", logLevel); - LogComponentEnable ("EpcHelper", logLevel); - LogComponentEnable ("EpcEnbApplication", logLevel); - LogComponentEnable ("EpcSgwPgwApplication", logLevel); - LogComponentEnable ("EpcMme", logLevel); - LogComponentEnable ("LteEnbRrc", logLevel); - - - // Create a single RemoteHost - NodeContainer remoteHostContainer; - remoteHostContainer.Create (1); - Ptr remoteHost = remoteHostContainer.Get (0); - InternetStackHelper internet; - internet.Install (remoteHostContainer); - - // Create the Internet - PointToPointHelper p2ph; - p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s"))); - p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500)); - p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010))); - NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost); - Ipv4AddressHelper ipv4h; - ipv4h.SetBase ("1.0.0.0", "255.0.0.0"); - Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices); - // interface 0 is localhost, 1 is the p2p device - Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1); - - Ipv4StaticRoutingHelper ipv4RoutingHelper; - Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); - - NodeContainer ueNodes; - NodeContainer enbNodes; - enbNodes.Create (numberOfNodes); - ueNodes.Create (numberOfUeNodes); - - // Install Mobility Model - Ptr positionAlloc = CreateObject (); - for (uint16_t i = 0; i < numberOfNodes; i++) - { - positionAlloc->Add (Vector (distance * i, 0, 0)); - } - MobilityHelper mobility; - mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); - mobility.SetPositionAllocator (positionAlloc); - mobility.Install (enbNodes); - mobility.Install (ueNodes); - - // Install LTE Devices to the nodes - NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes); - NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes); - - // Install the IP stack on the UEs - internet.Install (ueNodes); - Ipv4InterfaceContainer ueIpIface; - ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs)); - // Assign IP address to UEs, and install applications - for (uint32_t u = 0; u < ueNodes.GetN (); ++u) - { - Ptr ueNode = ueNodes.Get (u); - // Set the default gateway for the UE - Ptr ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject ()); - ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1); - } - - // Attach a UE to a eNB - lteHelper->Attach (ueLteDevs, enbLteDevs.Get (0)); - - // Activate an EPS bearer on all UEs - - for (uint32_t u = 0; u < ueNodes.GetN (); ++u) - { - Ptr ueDevice = ueLteDevs.Get (u); - GbrQosInformation qos; - qos.gbrDl = 132; // bit/s, considering IP, UDP, RLC, PDCP header size - qos.gbrUl = 132; - qos.mbrDl = qos.gbrDl; - qos.mbrUl = qos.gbrUl; - - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; - EpsBearer bearer (q, qos); - bearer.arp.priorityLevel = 15 - (u + 1); - bearer.arp.preemptionCapability = true; - bearer.arp.preemptionVulnerability = true; - lteHelper->ActivateDedicatedEpsBearer (ueDevice, bearer, EpcTft::Default ()); - } - - - // Install and start applications on UEs and remote host - uint16_t dlPort = 1234; - uint16_t ulPort = 2000; - uint16_t otherPort = 3000; - ApplicationContainer clientApps; - ApplicationContainer serverApps; - for (uint32_t u = 0; u < ueNodes.GetN (); ++u) - { - ++ulPort; - ++otherPort; - PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort)); - PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort)); - PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), otherPort)); - serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); - serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); - serverApps.Add (packetSinkHelper.Install (ueNodes.Get (u))); - - UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); - dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (interPacketInterval))); - dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); - - UdpClientHelper ulClient (remoteHostAddr, ulPort); - ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (interPacketInterval))); - ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); - - UdpClientHelper client (ueIpIface.GetAddress (u), otherPort); - client.SetAttribute ("Interval", TimeValue (MilliSeconds (interPacketInterval))); - client.SetAttribute ("MaxPackets", UintegerValue (1000000)); - - clientApps.Add (dlClient.Install (remoteHost)); - clientApps.Add (ulClient.Install (ueNodes.Get (u))); - if (u + 1 < ueNodes.GetN ()) - { - clientApps.Add (client.Install (ueNodes.Get (u + 1))); - } - else - { - clientApps.Add (client.Install (ueNodes.Get (0))); - } - } - - serverApps.Start (Seconds (0.030)); - clientApps.Start (Seconds (0.030)); - - double statsStartTime = 0.04; // need to allow for RRC connection establishment + SRS - double statsDuration = 1.0; - - lteHelper->EnableRlcTraces (); - Ptr rlcStats = lteHelper->GetRlcStats (); - rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime))); - rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration))); - - //get ue device pointer for UE-ID 0 IMSI 1 and enb device pointer - Ptr ueDevice = ueLteDevs.Get (0); - Ptr enbDevice = enbLteDevs.Get (0); - - /* - * Instantiate De-activation using Simulator::Schedule() method which will initiate bearer de-activation after deActivateTime - * Instantiate De-activation in sequence (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) - */ - Time deActivateTime (Seconds (1.5)); - Simulator::Schedule (deActivateTime, &LteHelper::DeActivateDedicatedEpsBearer, lteHelper, ueDevice, enbDevice, 2); - - //stop simulation after 3 seconds - Simulator::Stop (Seconds (3.0)); - - Simulator::Run (); - /*GtkConfigStore config; - config.ConfigureAttributes();*/ - - Simulator::Destroy (); - return 0; - -} - +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * 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: Gaurav Sathe + */ + +#include "ns3/lte-helper.h" +#include "ns3/epc-helper.h" +#include "ns3/core-module.h" +#include "ns3/network-module.h" +#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" +#include "ns3/mobility-module.h" +#include "ns3/lte-module.h" +#include "ns3/applications-module.h" +#include "ns3/point-to-point-helper.h" +#include "ns3/config-store.h" +//#include "ns3/gtk-config-store.h" + +using namespace ns3; + +/** + * Sample simulation script for LTE+EPC. It instantiates one eNodeB, + * attaches three UE to eNodeB starts a flow for each UE to and from a remote host. + * It also instantiates one dedicated bearer per UE + */ +NS_LOG_COMPONENT_DEFINE ("BearerDeactivateExample"); +int +main (int argc, char *argv[]) +{ + + uint16_t numberOfNodes = 1; + uint16_t numberOfUeNodes = 3; + double simTime = 1.1; + double distance = 60.0; + double interPacketInterval = 100; + + // Command line arguments + CommandLine cmd; + cmd.AddValue ("numberOfNodes", "Number of eNodeBs + UE pairs", numberOfNodes); + cmd.AddValue ("simTime", "Total duration of the simulation [s])", simTime); + cmd.AddValue ("distance", "Distance between eNBs [m]", distance); + cmd.AddValue ("interPacketInterval", "Inter packet interval [ms])", interPacketInterval); + cmd.Parse (argc, argv); + + Ptr lteHelper = CreateObject (); + Ptr epcHelper = CreateObject (); + lteHelper->SetEpcHelper (epcHelper); + + ConfigStore inputConfig; + inputConfig.ConfigureDefaults (); + + // parse again so you can override default values from the command line + cmd.Parse (argc, argv); + + Ptr pgw = epcHelper->GetPgwNode (); + + // Enable Logging + LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); + + LogComponentEnable ("BearerDeactivateExample", LOG_LEVEL_ALL); + LogComponentEnable ("LteHelper", logLevel); + LogComponentEnable ("EpcHelper", logLevel); + LogComponentEnable ("EpcEnbApplication", logLevel); + LogComponentEnable ("EpcSgwPgwApplication", logLevel); + LogComponentEnable ("EpcMme", logLevel); + LogComponentEnable ("LteEnbRrc", logLevel); + + + // Create a single RemoteHost + NodeContainer remoteHostContainer; + remoteHostContainer.Create (1); + Ptr remoteHost = remoteHostContainer.Get (0); + InternetStackHelper internet; + internet.Install (remoteHostContainer); + + // Create the Internet + PointToPointHelper p2ph; + p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s"))); + p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500)); + p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.010))); + NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost); + Ipv4AddressHelper ipv4h; + ipv4h.SetBase ("1.0.0.0", "255.0.0.0"); + Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices); + // interface 0 is localhost, 1 is the p2p device + Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1); + + Ipv4StaticRoutingHelper ipv4RoutingHelper; + Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + + NodeContainer ueNodes; + NodeContainer enbNodes; + enbNodes.Create (numberOfNodes); + ueNodes.Create (numberOfUeNodes); + + // Install Mobility Model + Ptr positionAlloc = CreateObject (); + for (uint16_t i = 0; i < numberOfNodes; i++) + { + positionAlloc->Add (Vector (distance * i, 0, 0)); + } + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.SetPositionAllocator (positionAlloc); + mobility.Install (enbNodes); + mobility.Install (ueNodes); + + // Install LTE Devices to the nodes + NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (enbNodes); + NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes); + + // Install the IP stack on the UEs + internet.Install (ueNodes); + Ipv4InterfaceContainer ueIpIface; + ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs)); + // Assign IP address to UEs, and install applications + for (uint32_t u = 0; u < ueNodes.GetN (); ++u) + { + Ptr ueNode = ueNodes.Get (u); + // Set the default gateway for the UE + Ptr ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject ()); + ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1); + } + + // Attach a UE to a eNB + lteHelper->Attach (ueLteDevs, enbLteDevs.Get (0)); + + // Activate an EPS bearer on all UEs + + for (uint32_t u = 0; u < ueNodes.GetN (); ++u) + { + Ptr ueDevice = ueLteDevs.Get (u); + GbrQosInformation qos; + qos.gbrDl = 132; // bit/s, considering IP, UDP, RLC, PDCP header size + qos.gbrUl = 132; + qos.mbrDl = qos.gbrDl; + qos.mbrUl = qos.gbrUl; + + enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer bearer (q, qos); + bearer.arp.priorityLevel = 15 - (u + 1); + bearer.arp.preemptionCapability = true; + bearer.arp.preemptionVulnerability = true; + lteHelper->ActivateDedicatedEpsBearer (ueDevice, bearer, EpcTft::Default ()); + } + + + // Install and start applications on UEs and remote host + uint16_t dlPort = 1234; + uint16_t ulPort = 2000; + uint16_t otherPort = 3000; + ApplicationContainer clientApps; + ApplicationContainer serverApps; + for (uint32_t u = 0; u < ueNodes.GetN (); ++u) + { + ++ulPort; + ++otherPort; + PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort)); + PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort)); + PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), otherPort)); + serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); + serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); + serverApps.Add (packetSinkHelper.Install (ueNodes.Get (u))); + + UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); + dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (interPacketInterval))); + dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); + + UdpClientHelper ulClient (remoteHostAddr, ulPort); + ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (interPacketInterval))); + ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); + + UdpClientHelper client (ueIpIface.GetAddress (u), otherPort); + client.SetAttribute ("Interval", TimeValue (MilliSeconds (interPacketInterval))); + client.SetAttribute ("MaxPackets", UintegerValue (1000000)); + + clientApps.Add (dlClient.Install (remoteHost)); + clientApps.Add (ulClient.Install (ueNodes.Get (u))); + if (u + 1 < ueNodes.GetN ()) + { + clientApps.Add (client.Install (ueNodes.Get (u + 1))); + } + else + { + clientApps.Add (client.Install (ueNodes.Get (0))); + } + } + + serverApps.Start (Seconds (0.030)); + clientApps.Start (Seconds (0.030)); + + double statsStartTime = 0.04; // need to allow for RRC connection establishment + SRS + double statsDuration = 1.0; + + lteHelper->EnableRlcTraces (); + Ptr rlcStats = lteHelper->GetRlcStats (); + rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime))); + rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration))); + + //get ue device pointer for UE-ID 0 IMSI 1 and enb device pointer + Ptr ueDevice = ueLteDevs.Get (0); + Ptr enbDevice = enbLteDevs.Get (0); + + /* + * Instantiate De-activation using Simulator::Schedule() method which will initiate bearer de-activation after deActivateTime + * Instantiate De-activation in sequence (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) + */ + Time deActivateTime (Seconds (1.5)); + Simulator::Schedule (deActivateTime, &LteHelper::DeActivateDedicatedEpsBearer, lteHelper, ueDevice, enbDevice, 2); + + //stop simulation after 3 seconds + Simulator::Stop (Seconds (3.0)); + + Simulator::Run (); + /*GtkConfigStore config; + config.ConfigureAttributes();*/ + + Simulator::Destroy (); + return 0; + +} + diff --git a/src/lte/test/lte-test-deactivate-bearer.cc b/src/lte/test/lte-test-deactivate-bearer.cc index f19065f9b..c6b42e713 100644 --- a/src/lte/test/lte-test-deactivate-bearer.cc +++ b/src/lte/test/lte-test-deactivate-bearer.cc @@ -1,347 +1,347 @@ -/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) - * - * 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:Gaurav Sathe - */ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include "ns3/radio-bearer-stats-calculator.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "ns3/string.h" -#include "ns3/double.h" -#include -#include -#include -#include - -#include "ns3/point-to-point-epc-helper.h" -#include "ns3/network-module.h" -#include "ns3/ipv4-global-routing-helper.h" -#include "ns3/internet-module.h" -#include "ns3/applications-module.h" -#include "ns3/point-to-point-helper.h" - -#include "lte-test-deactivate-bearer.h" - -NS_LOG_COMPONENT_DEFINE ("LenaTestDeactivateBearer"); - -namespace ns3 { - -LenaTestBearerDeactivateSuite::LenaTestBearerDeactivateSuite () - : TestSuite ("lte-test-deactivate-bearer", SYSTEM) -{ - NS_LOG_INFO ("creating LenaTestPssFfMacSchedulerSuite"); - - bool errorModel = false; - - // Test Case: homogeneous flow test in PSS (different distance) - // Traffic1 info - // UDP traffic: payload size = 100 bytes, interval = 1 ms - // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 132000 byte/rate - // Maximum throughput = 3 / ( 1/2196000 + 1/1191000 + 1/1383000) = 1486569 byte/s - // 132000 * 3 = 396000 < 1209046 -> estimated throughput in downlink = 132000 byte/sec - std::vector dist_1; - - dist_1.push_back (0); // User 0 distance --> MCS 28 - dist_1.push_back (0); // User 1 distance --> MCS 22 - dist_1.push_back (0); // User 2 distance --> MCS 20 - - std::vector packetSize_1; - - packetSize_1.push_back (100); //1 - packetSize_1.push_back (100); //2 - packetSize_1.push_back (100); //3 - - std::vector estThrPssDl_1; - - estThrPssDl_1.push_back (132000); // User 0 estimated TTI throughput from PSS - estThrPssDl_1.push_back (132000); // User 1 estimated TTI throughput from PSS - estThrPssDl_1.push_back (132000); // User 2 estimated TTI throughput from PSS - - AddTestCase (new LenaDeactivateBearerTestCase (dist_1,estThrPssDl_1,packetSize_1,1,errorModel,true), TestCase::QUICK); -} - -static LenaTestBearerDeactivateSuite lenaTestBearerDeactivateSuite; - - -std::string -LenaDeactivateBearerTestCase::BuildNameString (uint16_t nUser, std::vector dist) -{ - std::ostringstream oss; - oss << "distances (m) = [ "; - for (std::vector::iterator it = dist.begin (); it != dist.end (); ++it) - { - oss << *it << " "; - } - oss << "]"; - return oss.str (); -} - -LenaDeactivateBearerTestCase::LenaDeactivateBearerTestCase (std::vector dist, std::vector estThrPssDl, std::vector packetSize, uint16_t interval,bool errorModelEnabled, bool useIdealRrc) - : TestCase (BuildNameString (dist.size (), dist)), - m_nUser (dist.size ()), - m_dist (dist), - m_packetSize (packetSize), - m_interval (interval), - m_estThrPssDl (estThrPssDl), - m_errorModelEnabled (errorModelEnabled) -{ -} - -LenaDeactivateBearerTestCase::~LenaDeactivateBearerTestCase () -{ -} - -void -LenaDeactivateBearerTestCase::DoRun (void) -{ - if (!m_errorModelEnabled) - { - Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false)); - Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false)); - } - - Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true)); - - - Ptr lteHelper = CreateObject (); - Ptr epcHelper = CreateObject (); - lteHelper->SetEpcHelper (epcHelper); - - Ptr pgw = epcHelper->GetPgwNode (); - - // Create a single RemoteHost - NodeContainer remoteHostContainer; - remoteHostContainer.Create (1); - Ptr remoteHost = remoteHostContainer.Get (0); - InternetStackHelper internet; - internet.Install (remoteHostContainer); - - // Create the Internet - PointToPointHelper p2ph; - p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s"))); - p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500)); - p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001))); - NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost); - Ipv4AddressHelper ipv4h; - ipv4h.SetBase ("1.0.0.0", "255.0.0.0"); - Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices); - // interface 0 is localhost, 1 is the p2p device - Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1); - - Ipv4StaticRoutingHelper ipv4RoutingHelper; - Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); - remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); - - // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); - - // LogComponentEnable ("LenaTestDeactivateBearer", LOG_LEVEL_ALL); - // LogComponentEnable ("LteHelper", logLevel); - // LogComponentEnable ("EpcHelper", logLevel); - // LogComponentEnable ("EpcEnbApplication", logLevel); - // LogComponentEnable ("EpcSgwPgwApplication", logLevel); - // LogComponentEnable ("EpcMme", logLevel); - // LogComponentEnable ("LteEnbRrc", logLevel); - - lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel")); - - // Create Nodes: eNodeB and UE - NodeContainer enbNodes; - NodeContainer ueNodes; - enbNodes.Create (1); - ueNodes.Create (m_nUser); - - // Install Mobility Model - MobilityHelper mobility; - mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); - mobility.Install (enbNodes); - mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); - mobility.Install (ueNodes); - - // Create Devices and install them in the Nodes (eNB and UE) - NetDeviceContainer enbDevs; - NetDeviceContainer ueDevs; - lteHelper->SetSchedulerType ("ns3::PssFfMacScheduler"); - enbDevs = lteHelper->InstallEnbDevice (enbNodes); - ueDevs = lteHelper->InstallUeDevice (ueNodes); - - Ptr lteEnbDev = enbDevs.Get (0)->GetObject (); - Ptr enbPhy = lteEnbDev->GetPhy (); - enbPhy->SetAttribute ("TxPower", DoubleValue (30.0)); - enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0)); - - // Set UEs' position and power - for (int i = 0; i < m_nUser; i++) - { - Ptr mm = ueNodes.Get (i)->GetObject (); - mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0)); - Ptr lteUeDev = ueDevs.Get (i)->GetObject (); - Ptr uePhy = lteUeDev->GetPhy (); - uePhy->SetAttribute ("TxPower", DoubleValue (23.0)); - uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0)); - } - - // Install the IP stack on the UEs - internet.Install (ueNodes); - Ipv4InterfaceContainer ueIpIface; - ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs)); - - // Assign IP address to UEs - for (uint32_t u = 0; u < ueNodes.GetN (); ++u) - { - Ptr ueNode = ueNodes.Get (u); - // Set the default gateway for the UE - Ptr ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject ()); - ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1); - } - - // Attach a UE to a eNB - lteHelper->Attach (ueDevs, enbDevs.Get (0)); - - // Activate an EPS bearer on all UEs - - for (uint32_t u = 0; u < ueNodes.GetN (); ++u) - { - Ptr ueDevice = ueDevs.Get (u); - GbrQosInformation qos; - qos.gbrDl = (m_packetSize.at (u) + 32) * (1000 / m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size - qos.gbrUl = (m_packetSize.at (u) + 32) * (1000 / m_interval) * 8; - qos.mbrDl = qos.gbrDl; - qos.mbrUl = qos.gbrUl; - - enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; - EpsBearer bearer (q, qos); - bearer.arp.priorityLevel = 15 - (u + 1); - bearer.arp.preemptionCapability = true; - bearer.arp.preemptionVulnerability = true; - lteHelper->ActivateDedicatedEpsBearer (ueDevice, bearer, EpcTft::Default ()); - } - - - // Install downlink and uplink applications - uint16_t dlPort = 1234; - uint16_t ulPort = 2000; - PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort)); - PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort)); - ApplicationContainer clientApps; - ApplicationContainer serverApps; - for (uint32_t u = 0; u < ueNodes.GetN (); ++u) - { - ++ulPort; - serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); // receive packets from remotehost - serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs - - UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator - dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval))); - dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); - dlClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u))); - - UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator - ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval))); - ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); - ulClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u))); - - clientApps.Add (dlClient.Install (remoteHost)); - clientApps.Add (ulClient.Install (ueNodes.Get (u))); - } - - - serverApps.Start (Seconds (0.030)); - clientApps.Start (Seconds (0.030)); - - double statsStartTime = 0.04; // need to allow for RRC connection establishment + SRS - double statsDuration = 1.0; - double tolerance = 0.1; - - lteHelper->EnableRlcTraces (); - Ptr rlcStats = lteHelper->GetRlcStats (); - rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime))); - rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration))); - - - //get ue device pointer for UE-ID 0 IMSI 1 and enb device pointer - Ptr ueDevice = ueDevs.Get (0); - Ptr enbDevice = enbDevs.Get (0); - - /* - * Instantiate De-activation using Simulator::Schedule() method which will initiate bearer de-activation after deActivateTime - * Instantiate De-activation in sequence (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) - */ - Time deActivateTime (Seconds (1.5)); - Simulator::Schedule (deActivateTime, &LteHelper::DeActivateDedicatedEpsBearer, lteHelper, ueDevice, enbDevice, 2); - - //stop simulation after 3 seconds - Simulator::Stop (Seconds (3.0)); - - Simulator::Run (); - - NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)"); - std::vector dlDataRxed; - std::vector dlDataTxed; - for (int i = 0; i < m_nUser; i++) - { - // get the imsi - uint64_t imsi = ueDevs.Get (i)->GetObject ()->GetImsi (); - // get the lcId - // lcId is hard-coded, since only one dedicated bearer is added - uint8_t lcId = 4; - dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId)); - dlDataTxed.push_back (rlcStats->GetDlTxData (imsi, lcId)); - NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_estThrPssDl.at (i)); - NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes txed " << (double)dlDataTxed.at (i) << " thr " << (double)dlDataTxed.at (i) / statsDuration); - } - - for (int i = 0; i < m_nUser; i++) - { - uint64_t imsi = ueDevs.Get (i)->GetObject ()->GetImsi (); - - /* - * For UE ID-0 IMSI 1, LCID=4 is deactivated hence If traffic seen on it, test case should fail - * Else For other UE's, test case should validate throughput - */ - if (imsi == 1) - { - NS_TEST_ASSERT_MSG_EQ ((double)dlDataTxed.at (i), 0, "Invalid LCID in Statistics "); - } - else - { - NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataTxed.at (i) / statsDuration, m_estThrPssDl.at (i), m_estThrPssDl.at (i) * tolerance, " Unfair Throughput!"); - } - } - - Simulator::Destroy (); -} -} +/* -*- Mode: C++; c-file-style: "gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2011, 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) + * + * 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:Gaurav Sathe + */ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include "ns3/radio-bearer-stats-calculator.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "ns3/string.h" +#include "ns3/double.h" +#include +#include +#include +#include + +#include "ns3/point-to-point-epc-helper.h" +#include "ns3/network-module.h" +#include "ns3/ipv4-global-routing-helper.h" +#include "ns3/internet-module.h" +#include "ns3/applications-module.h" +#include "ns3/point-to-point-helper.h" + +#include "lte-test-deactivate-bearer.h" + +NS_LOG_COMPONENT_DEFINE ("LenaTestDeactivateBearer"); + +namespace ns3 { + +LenaTestBearerDeactivateSuite::LenaTestBearerDeactivateSuite () + : TestSuite ("lte-test-deactivate-bearer", SYSTEM) +{ + NS_LOG_INFO ("creating LenaTestPssFfMacSchedulerSuite"); + + bool errorModel = false; + + // Test Case: homogeneous flow test in PSS (different distance) + // Traffic1 info + // UDP traffic: payload size = 100 bytes, interval = 1 ms + // UDP rate in scheduler: (payload + RLC header + PDCP header + IP header + UDP header) * 1000 byte/sec -> 132000 byte/rate + // Maximum throughput = 3 / ( 1/2196000 + 1/1191000 + 1/1383000) = 1486569 byte/s + // 132000 * 3 = 396000 < 1209046 -> estimated throughput in downlink = 132000 byte/sec + std::vector dist_1; + + dist_1.push_back (0); // User 0 distance --> MCS 28 + dist_1.push_back (0); // User 1 distance --> MCS 22 + dist_1.push_back (0); // User 2 distance --> MCS 20 + + std::vector packetSize_1; + + packetSize_1.push_back (100); //1 + packetSize_1.push_back (100); //2 + packetSize_1.push_back (100); //3 + + std::vector estThrPssDl_1; + + estThrPssDl_1.push_back (132000); // User 0 estimated TTI throughput from PSS + estThrPssDl_1.push_back (132000); // User 1 estimated TTI throughput from PSS + estThrPssDl_1.push_back (132000); // User 2 estimated TTI throughput from PSS + + AddTestCase (new LenaDeactivateBearerTestCase (dist_1,estThrPssDl_1,packetSize_1,1,errorModel,true), TestCase::QUICK); +} + +static LenaTestBearerDeactivateSuite lenaTestBearerDeactivateSuite; + + +std::string +LenaDeactivateBearerTestCase::BuildNameString (uint16_t nUser, std::vector dist) +{ + std::ostringstream oss; + oss << "distances (m) = [ "; + for (std::vector::iterator it = dist.begin (); it != dist.end (); ++it) + { + oss << *it << " "; + } + oss << "]"; + return oss.str (); +} + +LenaDeactivateBearerTestCase::LenaDeactivateBearerTestCase (std::vector dist, std::vector estThrPssDl, std::vector packetSize, uint16_t interval,bool errorModelEnabled, bool useIdealRrc) + : TestCase (BuildNameString (dist.size (), dist)), + m_nUser (dist.size ()), + m_dist (dist), + m_packetSize (packetSize), + m_interval (interval), + m_estThrPssDl (estThrPssDl), + m_errorModelEnabled (errorModelEnabled) +{ +} + +LenaDeactivateBearerTestCase::~LenaDeactivateBearerTestCase () +{ +} + +void +LenaDeactivateBearerTestCase::DoRun (void) +{ + if (!m_errorModelEnabled) + { + Config::SetDefault ("ns3::LteSpectrumPhy::CtrlErrorModelEnabled", BooleanValue (false)); + Config::SetDefault ("ns3::LteSpectrumPhy::DataErrorModelEnabled", BooleanValue (false)); + } + + Config::SetDefault ("ns3::LteHelper::UseIdealRrc", BooleanValue (true)); + + + Ptr lteHelper = CreateObject (); + Ptr epcHelper = CreateObject (); + lteHelper->SetEpcHelper (epcHelper); + + Ptr pgw = epcHelper->GetPgwNode (); + + // Create a single RemoteHost + NodeContainer remoteHostContainer; + remoteHostContainer.Create (1); + Ptr remoteHost = remoteHostContainer.Get (0); + InternetStackHelper internet; + internet.Install (remoteHostContainer); + + // Create the Internet + PointToPointHelper p2ph; + p2ph.SetDeviceAttribute ("DataRate", DataRateValue (DataRate ("100Gb/s"))); + p2ph.SetDeviceAttribute ("Mtu", UintegerValue (1500)); + p2ph.SetChannelAttribute ("Delay", TimeValue (Seconds (0.001))); + NetDeviceContainer internetDevices = p2ph.Install (pgw, remoteHost); + Ipv4AddressHelper ipv4h; + ipv4h.SetBase ("1.0.0.0", "255.0.0.0"); + Ipv4InterfaceContainer internetIpIfaces = ipv4h.Assign (internetDevices); + // interface 0 is localhost, 1 is the p2p device + Ipv4Address remoteHostAddr = internetIpIfaces.GetAddress (1); + + Ipv4StaticRoutingHelper ipv4RoutingHelper; + Ptr remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject ()); + remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1); + + // LogLevel logLevel = (LogLevel)(LOG_PREFIX_FUNC | LOG_PREFIX_TIME | LOG_LEVEL_ALL); + + // LogComponentEnable ("LenaTestDeactivateBearer", LOG_LEVEL_ALL); + // LogComponentEnable ("LteHelper", logLevel); + // LogComponentEnable ("EpcHelper", logLevel); + // LogComponentEnable ("EpcEnbApplication", logLevel); + // LogComponentEnable ("EpcSgwPgwApplication", logLevel); + // LogComponentEnable ("EpcMme", logLevel); + // LogComponentEnable ("LteEnbRrc", logLevel); + + lteHelper->SetAttribute ("PathlossModel", StringValue ("ns3::FriisSpectrumPropagationLossModel")); + + // Create Nodes: eNodeB and UE + NodeContainer enbNodes; + NodeContainer ueNodes; + enbNodes.Create (1); + ueNodes.Create (m_nUser); + + // Install Mobility Model + MobilityHelper mobility; + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (enbNodes); + mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel"); + mobility.Install (ueNodes); + + // Create Devices and install them in the Nodes (eNB and UE) + NetDeviceContainer enbDevs; + NetDeviceContainer ueDevs; + lteHelper->SetSchedulerType ("ns3::PssFfMacScheduler"); + enbDevs = lteHelper->InstallEnbDevice (enbNodes); + ueDevs = lteHelper->InstallUeDevice (ueNodes); + + Ptr lteEnbDev = enbDevs.Get (0)->GetObject (); + Ptr enbPhy = lteEnbDev->GetPhy (); + enbPhy->SetAttribute ("TxPower", DoubleValue (30.0)); + enbPhy->SetAttribute ("NoiseFigure", DoubleValue (5.0)); + + // Set UEs' position and power + for (int i = 0; i < m_nUser; i++) + { + Ptr mm = ueNodes.Get (i)->GetObject (); + mm->SetPosition (Vector (m_dist.at (i), 0.0, 0.0)); + Ptr lteUeDev = ueDevs.Get (i)->GetObject (); + Ptr uePhy = lteUeDev->GetPhy (); + uePhy->SetAttribute ("TxPower", DoubleValue (23.0)); + uePhy->SetAttribute ("NoiseFigure", DoubleValue (9.0)); + } + + // Install the IP stack on the UEs + internet.Install (ueNodes); + Ipv4InterfaceContainer ueIpIface; + ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueDevs)); + + // Assign IP address to UEs + for (uint32_t u = 0; u < ueNodes.GetN (); ++u) + { + Ptr ueNode = ueNodes.Get (u); + // Set the default gateway for the UE + Ptr ueStaticRouting = ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject ()); + ueStaticRouting->SetDefaultRoute (epcHelper->GetUeDefaultGatewayAddress (), 1); + } + + // Attach a UE to a eNB + lteHelper->Attach (ueDevs, enbDevs.Get (0)); + + // Activate an EPS bearer on all UEs + + for (uint32_t u = 0; u < ueNodes.GetN (); ++u) + { + Ptr ueDevice = ueDevs.Get (u); + GbrQosInformation qos; + qos.gbrDl = (m_packetSize.at (u) + 32) * (1000 / m_interval) * 8; // bit/s, considering IP, UDP, RLC, PDCP header size + qos.gbrUl = (m_packetSize.at (u) + 32) * (1000 / m_interval) * 8; + qos.mbrDl = qos.gbrDl; + qos.mbrUl = qos.gbrUl; + + enum EpsBearer::Qci q = EpsBearer::GBR_CONV_VOICE; + EpsBearer bearer (q, qos); + bearer.arp.priorityLevel = 15 - (u + 1); + bearer.arp.preemptionCapability = true; + bearer.arp.preemptionVulnerability = true; + lteHelper->ActivateDedicatedEpsBearer (ueDevice, bearer, EpcTft::Default ()); + } + + + // Install downlink and uplink applications + uint16_t dlPort = 1234; + uint16_t ulPort = 2000; + PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), dlPort)); + PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (Ipv4Address::GetAny (), ulPort)); + ApplicationContainer clientApps; + ApplicationContainer serverApps; + for (uint32_t u = 0; u < ueNodes.GetN (); ++u) + { + ++ulPort; + serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get (u))); // receive packets from remotehost + serverApps.Add (ulPacketSinkHelper.Install (remoteHost)); // receive packets from UEs + + UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); // uplink packets generator + dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval))); + dlClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); + dlClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u))); + + UdpClientHelper ulClient (remoteHostAddr, ulPort); // downlink packets generator + ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds (m_interval))); + ulClient.SetAttribute ("MaxPackets", UintegerValue (1000000)); + ulClient.SetAttribute ("PacketSize", UintegerValue (m_packetSize.at (u))); + + clientApps.Add (dlClient.Install (remoteHost)); + clientApps.Add (ulClient.Install (ueNodes.Get (u))); + } + + + serverApps.Start (Seconds (0.030)); + clientApps.Start (Seconds (0.030)); + + double statsStartTime = 0.04; // need to allow for RRC connection establishment + SRS + double statsDuration = 1.0; + double tolerance = 0.1; + + lteHelper->EnableRlcTraces (); + Ptr rlcStats = lteHelper->GetRlcStats (); + rlcStats->SetAttribute ("StartTime", TimeValue (Seconds (statsStartTime))); + rlcStats->SetAttribute ("EpochDuration", TimeValue (Seconds (statsDuration))); + + + //get ue device pointer for UE-ID 0 IMSI 1 and enb device pointer + Ptr ueDevice = ueDevs.Get (0); + Ptr enbDevice = enbDevs.Get (0); + + /* + * Instantiate De-activation using Simulator::Schedule() method which will initiate bearer de-activation after deActivateTime + * Instantiate De-activation in sequence (Time const &time, MEM mem_ptr, OBJ obj, T1 a1, T2 a2, T3 a3) + */ + Time deActivateTime (Seconds (1.5)); + Simulator::Schedule (deActivateTime, &LteHelper::DeActivateDedicatedEpsBearer, lteHelper, ueDevice, enbDevice, 2); + + //stop simulation after 3 seconds + Simulator::Stop (Seconds (3.0)); + + Simulator::Run (); + + NS_LOG_INFO ("DL - Test with " << m_nUser << " user(s)"); + std::vector dlDataRxed; + std::vector dlDataTxed; + for (int i = 0; i < m_nUser; i++) + { + // get the imsi + uint64_t imsi = ueDevs.Get (i)->GetObject ()->GetImsi (); + // get the lcId + // lcId is hard-coded, since only one dedicated bearer is added + uint8_t lcId = 4; + dlDataRxed.push_back (rlcStats->GetDlRxData (imsi, lcId)); + dlDataTxed.push_back (rlcStats->GetDlTxData (imsi, lcId)); + NS_LOG_INFO ("\tUser " << i << " dist " << m_dist.at (i) << " imsi " << imsi << " bytes rxed " << (double)dlDataRxed.at (i) << " thr " << (double)dlDataRxed.at (i) / statsDuration << " ref " << m_estThrPssDl.at (i)); + NS_LOG_INFO ("\tUser " << i << " imsi " << imsi << " bytes txed " << (double)dlDataTxed.at (i) << " thr " << (double)dlDataTxed.at (i) / statsDuration); + } + + for (int i = 0; i < m_nUser; i++) + { + uint64_t imsi = ueDevs.Get (i)->GetObject ()->GetImsi (); + + /* + * For UE ID-0 IMSI 1, LCID=4 is deactivated hence If traffic seen on it, test case should fail + * Else For other UE's, test case should validate throughput + */ + if (imsi == 1) + { + NS_TEST_ASSERT_MSG_EQ ((double)dlDataTxed.at (i), 0, "Invalid LCID in Statistics "); + } + else + { + NS_TEST_ASSERT_MSG_EQ_TOL ((double)dlDataTxed.at (i) / statsDuration, m_estThrPssDl.at (i), m_estThrPssDl.at (i) * tolerance, " Unfair Throughput!"); + } + } + + Simulator::Destroy (); +} +} diff --git a/src/lte/test/lte-test-deactivate-bearer.h b/src/lte/test/lte-test-deactivate-bearer.h index d74d05a69..a62775299 100644 --- a/src/lte/test/lte-test-deactivate-bearer.h +++ b/src/lte/test/lte-test-deactivate-bearer.h @@ -1,39 +1,39 @@ /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -#ifndef LENA_TEST_DEACTIVATE_BEARER_H -#define LENA_TEST_DEACTIVATE_BEARER_H - -#include "ns3/simulator.h" -#include "ns3/test.h" - - -namespace ns3 { - -class LenaDeactivateBearerTestCase : public TestCase -{ -public: - LenaDeactivateBearerTestCase (std::vector dist, std::vector estThrPssDl, std::vector packetSize, uint16_t interval, bool errorModelEnabled, bool useIdealRrc); - virtual ~LenaDeactivateBearerTestCase (); - -private: - static std::string BuildNameString (uint16_t nUser, std::vector dist); - virtual void DoRun (void); - uint16_t m_nUser; - std::vector m_dist; - std::vector m_packetSize; // byte - uint16_t m_interval; // ms - std::vector m_estThrPssDl; - bool m_errorModelEnabled; -}; - - - -class LenaTestBearerDeactivateSuite : public TestSuite -{ -public: - LenaTestBearerDeactivateSuite (); -}; - -} // namespace ns3 - -#endif +#ifndef LENA_TEST_DEACTIVATE_BEARER_H +#define LENA_TEST_DEACTIVATE_BEARER_H + +#include "ns3/simulator.h" +#include "ns3/test.h" + + +namespace ns3 { + +class LenaDeactivateBearerTestCase : public TestCase +{ +public: + LenaDeactivateBearerTestCase (std::vector dist, std::vector estThrPssDl, std::vector packetSize, uint16_t interval, bool errorModelEnabled, bool useIdealRrc); + virtual ~LenaDeactivateBearerTestCase (); + +private: + static std::string BuildNameString (uint16_t nUser, std::vector dist); + virtual void DoRun (void); + uint16_t m_nUser; + std::vector m_dist; + std::vector m_packetSize; // byte + uint16_t m_interval; // ms + std::vector m_estThrPssDl; + bool m_errorModelEnabled; +}; + + + +class LenaTestBearerDeactivateSuite : public TestSuite +{ +public: + LenaTestBearerDeactivateSuite (); +}; + +} // namespace ns3 + +#endif diff --git a/src/wifi/model/ampdu-subframe-header.h b/src/wifi/model/ampdu-subframe-header.h index f22ddc1ce..f83d34a93 100644 --- a/src/wifi/model/ampdu-subframe-header.h +++ b/src/wifi/model/ampdu-subframe-header.h @@ -1,91 +1,91 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2013 - * - * 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: Ghada Badawy - */ -#ifndef AMPDU_SUBFRAME_HEADER_H -#define AMPDU_SUBFRAME_HEADER_H - -#include "ns3/header.h" -#include "ns3/mac48-address.h" - -namespace ns3 { - -/** - * \ingroup wifi - * - * - */ -class AmpduSubframeHeader : public Header -{ -public: - AmpduSubframeHeader (); - virtual ~AmpduSubframeHeader (); - - static TypeId GetTypeId (void); - virtual TypeId GetInstanceTypeId (void) const; - virtual void Print (std::ostream &os) const; - virtual uint32_t GetSerializedSize (void) const; - virtual void Serialize (Buffer::Iterator start) const; - virtual uint32_t Deserialize (Buffer::Iterator start); - - /** - * Set the CRC field. - * - * \param crc - */ - void SetCrc (uint8_t crc); - /** - * Set the SIG field. - * - * \param crc - */ - void SetSig (); - /** - * Set the length field. - * - * \param length - */ - void SetLength (uint16_t length); - /** - * Return the CRC field. - * - * \return the CRC field - */ - uint8_t GetCrc (void) const; - /** - * Return the SIG field. - * - * \return the SIG field - */ - uint8_t GetSig (void) const; - /** - * Return the length field. - * - * \return the length field - */ - uint16_t GetLength (void) const; - -private: - uint8_t m_crc; //!< CRC field - uint8_t m_sig; //!< SIG field - uint16_t m_length; //!< length field -}; - -} // namespace ns3 - -#endif /* AMPDU_SUBFRAME_HEADER_H */ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2013 + * + * 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: Ghada Badawy + */ +#ifndef AMPDU_SUBFRAME_HEADER_H +#define AMPDU_SUBFRAME_HEADER_H + +#include "ns3/header.h" +#include "ns3/mac48-address.h" + +namespace ns3 { + +/** + * \ingroup wifi + * + * + */ +class AmpduSubframeHeader : public Header +{ +public: + AmpduSubframeHeader (); + virtual ~AmpduSubframeHeader (); + + static TypeId GetTypeId (void); + virtual TypeId GetInstanceTypeId (void) const; + virtual void Print (std::ostream &os) const; + virtual uint32_t GetSerializedSize (void) const; + virtual void Serialize (Buffer::Iterator start) const; + virtual uint32_t Deserialize (Buffer::Iterator start); + + /** + * Set the CRC field. + * + * \param crc + */ + void SetCrc (uint8_t crc); + /** + * Set the SIG field. + * + * \param crc + */ + void SetSig (); + /** + * Set the length field. + * + * \param length + */ + void SetLength (uint16_t length); + /** + * Return the CRC field. + * + * \return the CRC field + */ + uint8_t GetCrc (void) const; + /** + * Return the SIG field. + * + * \return the SIG field + */ + uint8_t GetSig (void) const; + /** + * Return the length field. + * + * \return the length field + */ + uint16_t GetLength (void) const; + +private: + uint8_t m_crc; //!< CRC field + uint8_t m_sig; //!< SIG field + uint16_t m_length; //!< length field +}; + +} // namespace ns3 + +#endif /* AMPDU_SUBFRAME_HEADER_H */ diff --git a/src/wifi/model/ampdu-tag.h b/src/wifi/model/ampdu-tag.h index 3869f535f..0a7bac5c2 100644 --- a/src/wifi/model/ampdu-tag.h +++ b/src/wifi/model/ampdu-tag.h @@ -1,82 +1,82 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2013 - * - * 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: Ghada Badawy - */ -#ifndef AMPDU_TAG_H -#define AMPDU_TAG_H - -#include "ns3/packet.h" - -namespace ns3 { - -class Tag; - -/** - * \ingroup wifi - * - * The aim of the AmpduTag is to provide means for a MAC to specify that a packet includes A-MPDU - * since this is done in HT-SIG and there is no HT-SIG representation in ns-3 - */ -class AmpduTag : public Tag -{ -public: - static TypeId GetTypeId (void); - virtual TypeId GetInstanceTypeId (void) const; - - /** - * Create a AmpduTag with the default =0 no Ampdu - */ - AmpduTag (); - /** - * Set m_ampdu to 1. - */ - void SetAmpdu (bool supported); - /** - * \param noofmpdus the number of MPDUs - * - * Set the number of MPDUs in the A-MPDU. - */ - void SetNoOfMpdus (uint8_t noofmpdus); - - virtual void Serialize (TagBuffer i) const; - virtual void Deserialize (TagBuffer i); - virtual uint32_t GetSerializedSize () const; - virtual void Print (std::ostream &os) const; - - /** - * \return true if it is an A-MPDU, - * false otherwise. - * - * Returns m_ampdu - */ - bool GetAmpdu (void) const; - /** - * \return the number of MPDUs in an A-MPDU - * - * Returns the number of MPDUs in an A-MPDU - */ - uint8_t GetNoOfMpdus (void) const; - -private: - uint8_t m_ampdu; //!< Flag whether it is an A-MPDU - uint8_t m_noOfMpdus; //!< number of MPDUs in the A-MPDU -}; - -} // namespace ns3 - -#endif /* AMPDU_TAG_H */ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2013 + * + * 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: Ghada Badawy + */ +#ifndef AMPDU_TAG_H +#define AMPDU_TAG_H + +#include "ns3/packet.h" + +namespace ns3 { + +class Tag; + +/** + * \ingroup wifi + * + * The aim of the AmpduTag is to provide means for a MAC to specify that a packet includes A-MPDU + * since this is done in HT-SIG and there is no HT-SIG representation in ns-3 + */ +class AmpduTag : public Tag +{ +public: + static TypeId GetTypeId (void); + virtual TypeId GetInstanceTypeId (void) const; + + /** + * Create a AmpduTag with the default =0 no Ampdu + */ + AmpduTag (); + /** + * Set m_ampdu to 1. + */ + void SetAmpdu (bool supported); + /** + * \param noofmpdus the number of MPDUs + * + * Set the number of MPDUs in the A-MPDU. + */ + void SetNoOfMpdus (uint8_t noofmpdus); + + virtual void Serialize (TagBuffer i) const; + virtual void Deserialize (TagBuffer i); + virtual uint32_t GetSerializedSize () const; + virtual void Print (std::ostream &os) const; + + /** + * \return true if it is an A-MPDU, + * false otherwise. + * + * Returns m_ampdu + */ + bool GetAmpdu (void) const; + /** + * \return the number of MPDUs in an A-MPDU + * + * Returns the number of MPDUs in an A-MPDU + */ + uint8_t GetNoOfMpdus (void) const; + +private: + uint8_t m_ampdu; //!< Flag whether it is an A-MPDU + uint8_t m_noOfMpdus; //!< number of MPDUs in the A-MPDU +}; + +} // namespace ns3 + +#endif /* AMPDU_TAG_H */ diff --git a/src/wifi/model/mpdu-aggregator.h b/src/wifi/model/mpdu-aggregator.h index 8dc6cb37a..d8b6b206d 100644 --- a/src/wifi/model/mpdu-aggregator.h +++ b/src/wifi/model/mpdu-aggregator.h @@ -1,91 +1,91 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2013 - * - * 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: Ghada Badawy - */ -#ifndef MPDU_AGGREGATOR_H -#define MPDU_AGGREGATOR_H - -#include "ns3/ptr.h" -#include "ns3/packet.h" -#include "ns3/object.h" - -#include "ampdu-subframe-header.h" - -#include - -namespace ns3 { - -class WifiMacHeader; - -/** - * \brief Abstract class that concrete mpdu aggregators have to implement - * \ingroup wifi - */ -class MpduAggregator : public Object -{ -public: - /** - * A list of deaggregated packets and their A-MPDU subframe headers. - */ - typedef std::list, AmpduSubframeHeader> > DeaggregatedMpdus; - /** - * A constant iterator for a list of deaggregated packets and their A-MPDU subframe headers. - */ - typedef std::list, AmpduSubframeHeader> >::const_iterator DeaggregatedMpdusCI; - - static TypeId GetTypeId (void); - /** - * \param packet Packet we have to insert into aggregatedPacket. - * \param aggregatedPacket Packet that will contain packet, if aggregation is possible. - * \return true if packet can be aggregated to aggregatedPacket, false otherwise. - * - * Adds packet to aggregatedPacket. In concrete aggregator's implementation is - * specified how and if packet can be added to aggregatedPacket. - */ - virtual bool Aggregate (Ptr packet, Ptr aggregatedPacket) = 0; - /** - * Adds A-MPDU subframe header and padding to each MPDU that is part of an A-MPDU before it is sent. - */ - virtual void AddHeaderAndPad (Ptr packet,bool last) = 0; - /** - * \param packetSize size of the packet we want to insert into aggregatedPacket. - * \param aggregatedPacket packet that will contain the packet of size packetSize, if aggregation is possible. - * \param blockAckSize size of the piggybacked block ack request - * \return true if the packet of size packetSize can be aggregated to aggregatedPacket, false otherwise. - * - * This method is used to determine if a packet could be aggregated to an A-MPDU without exceeding the maximum packet size. - */ - virtual bool CanBeAggregated (uint32_t packetSize, Ptr aggregatedPacket, uint8_t blockAckSize) = 0; - /** - * \return padding that must be added to the end of an aggregated packet - * - * Calculates how much padding must be added to the end of an aggregated packet, after that a new packet is added. - * Each A-MPDU subframe is padded so that its length is multiple of 4 octets. - */ - virtual uint32_t CalculatePadding (Ptr packet) = 0; - /** - * Deaggregates an A-MPDU by removing the A-MPDU subframe header and padding. - * - * \return list of deaggragted packets and their A-MPDU subframe headers - */ - static DeaggregatedMpdus Deaggregate (Ptr aggregatedPacket); -}; - -} // namespace ns3 - -#endif /* MPDU_AGGREGATOR_H */ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2013 + * + * 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: Ghada Badawy + */ +#ifndef MPDU_AGGREGATOR_H +#define MPDU_AGGREGATOR_H + +#include "ns3/ptr.h" +#include "ns3/packet.h" +#include "ns3/object.h" + +#include "ampdu-subframe-header.h" + +#include + +namespace ns3 { + +class WifiMacHeader; + +/** + * \brief Abstract class that concrete mpdu aggregators have to implement + * \ingroup wifi + */ +class MpduAggregator : public Object +{ +public: + /** + * A list of deaggregated packets and their A-MPDU subframe headers. + */ + typedef std::list, AmpduSubframeHeader> > DeaggregatedMpdus; + /** + * A constant iterator for a list of deaggregated packets and their A-MPDU subframe headers. + */ + typedef std::list, AmpduSubframeHeader> >::const_iterator DeaggregatedMpdusCI; + + static TypeId GetTypeId (void); + /** + * \param packet Packet we have to insert into aggregatedPacket. + * \param aggregatedPacket Packet that will contain packet, if aggregation is possible. + * \return true if packet can be aggregated to aggregatedPacket, false otherwise. + * + * Adds packet to aggregatedPacket. In concrete aggregator's implementation is + * specified how and if packet can be added to aggregatedPacket. + */ + virtual bool Aggregate (Ptr packet, Ptr aggregatedPacket) = 0; + /** + * Adds A-MPDU subframe header and padding to each MPDU that is part of an A-MPDU before it is sent. + */ + virtual void AddHeaderAndPad (Ptr packet,bool last) = 0; + /** + * \param packetSize size of the packet we want to insert into aggregatedPacket. + * \param aggregatedPacket packet that will contain the packet of size packetSize, if aggregation is possible. + * \param blockAckSize size of the piggybacked block ack request + * \return true if the packet of size packetSize can be aggregated to aggregatedPacket, false otherwise. + * + * This method is used to determine if a packet could be aggregated to an A-MPDU without exceeding the maximum packet size. + */ + virtual bool CanBeAggregated (uint32_t packetSize, Ptr aggregatedPacket, uint8_t blockAckSize) = 0; + /** + * \return padding that must be added to the end of an aggregated packet + * + * Calculates how much padding must be added to the end of an aggregated packet, after that a new packet is added. + * Each A-MPDU subframe is padded so that its length is multiple of 4 octets. + */ + virtual uint32_t CalculatePadding (Ptr packet) = 0; + /** + * Deaggregates an A-MPDU by removing the A-MPDU subframe header and padding. + * + * \return list of deaggragted packets and their A-MPDU subframe headers + */ + static DeaggregatedMpdus Deaggregate (Ptr aggregatedPacket); +}; + +} // namespace ns3 + +#endif /* MPDU_AGGREGATOR_H */ diff --git a/src/wifi/model/mpdu-standard-aggregator.h b/src/wifi/model/mpdu-standard-aggregator.h index f7c8b4c7d..11efdc7fa 100644 --- a/src/wifi/model/mpdu-standard-aggregator.h +++ b/src/wifi/model/mpdu-standard-aggregator.h @@ -1,74 +1,74 @@ -/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ -/* - * Copyright (c) 2013 - * - * 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: Ghada Badawy - */ -#ifndef MPDU_STANDARD_AGGREGATOR_H -#define MPDU_STANDARD_AGGREGATOR_H - -#include "mpdu-aggregator.h" - -namespace ns3 { - -/** - * \ingroup wifi - * Standard MPDU aggregator - * - */ -class MpduStandardAggregator : public MpduAggregator -{ -public: - static TypeId GetTypeId (void); - MpduStandardAggregator (); - ~MpduStandardAggregator (); - /** - * \param packet packet we have to insert into aggregatedPacket. - * \param aggregatedPacket packet that will contain packet, if aggregation is possible. - * \return true if packet can be aggregated to aggregatedPacket, false otherwise. - * - * This method performs an MPDU aggregation. - * Returns true if packet can be aggregated to aggregatedPacket, false otherwise. - */ - virtual bool Aggregate (Ptr packet, Ptr aggregatedPacket); - /** - * Adds A-MPDU subframe header and padding to each MPDU that is part of an A-MPDU before it is sent. - */ - virtual void AddHeaderAndPad (Ptr packet, bool last); - /** - * \param packetSize size of the packet we want to insert into aggregatedPacket. - * \param aggregatedPacket packet that will contain the packet of size packetSize, if aggregation is possible. - * \param blockAckSize size of the piggybacked block ack request - * \return true if the packet of size packetSize can be aggregated to aggregatedPacket, false otherwise. - * - * This method is used to determine if a packet could be aggregated to an A-MPDU without exceeding the maximum packet size. - */ - virtual bool CanBeAggregated (uint32_t packetSize, Ptr aggregatedPacket, uint8_t blockAckSize); - /** - * \return padding that must be added to the end of an aggregated packet - * - * Calculates how much padding must be added to the end of an aggregated packet, after that a new packet is added. - * Each A-MPDU subframe is padded so that its length is multiple of 4 octets. - */ - virtual uint32_t CalculatePadding (Ptr packet); - -private: - uint32_t m_maxAmpduLength; //!< Maximum length in bytes of A-MPDUs -}; - -} // namespace ns3 - -#endif /* MPDU_STANDARD_AGGREGATOR_H */ +/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ +/* + * Copyright (c) 2013 + * + * 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: Ghada Badawy + */ +#ifndef MPDU_STANDARD_AGGREGATOR_H +#define MPDU_STANDARD_AGGREGATOR_H + +#include "mpdu-aggregator.h" + +namespace ns3 { + +/** + * \ingroup wifi + * Standard MPDU aggregator + * + */ +class MpduStandardAggregator : public MpduAggregator +{ +public: + static TypeId GetTypeId (void); + MpduStandardAggregator (); + ~MpduStandardAggregator (); + /** + * \param packet packet we have to insert into aggregatedPacket. + * \param aggregatedPacket packet that will contain packet, if aggregation is possible. + * \return true if packet can be aggregated to aggregatedPacket, false otherwise. + * + * This method performs an MPDU aggregation. + * Returns true if packet can be aggregated to aggregatedPacket, false otherwise. + */ + virtual bool Aggregate (Ptr packet, Ptr aggregatedPacket); + /** + * Adds A-MPDU subframe header and padding to each MPDU that is part of an A-MPDU before it is sent. + */ + virtual void AddHeaderAndPad (Ptr packet, bool last); + /** + * \param packetSize size of the packet we want to insert into aggregatedPacket. + * \param aggregatedPacket packet that will contain the packet of size packetSize, if aggregation is possible. + * \param blockAckSize size of the piggybacked block ack request + * \return true if the packet of size packetSize can be aggregated to aggregatedPacket, false otherwise. + * + * This method is used to determine if a packet could be aggregated to an A-MPDU without exceeding the maximum packet size. + */ + virtual bool CanBeAggregated (uint32_t packetSize, Ptr aggregatedPacket, uint8_t blockAckSize); + /** + * \return padding that must be added to the end of an aggregated packet + * + * Calculates how much padding must be added to the end of an aggregated packet, after that a new packet is added. + * Each A-MPDU subframe is padded so that its length is multiple of 4 octets. + */ + virtual uint32_t CalculatePadding (Ptr packet); + +private: + uint32_t m_maxAmpduLength; //!< Maximum length in bytes of A-MPDUs +}; + +} // namespace ns3 + +#endif /* MPDU_STANDARD_AGGREGATOR_H */