Professional Documents
Culture Documents
Cenario Lte
Cenario Lte
#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"
#include "ns3/csma-module.h"
#include "ns3/ns2-mobility-helper.h"
#include "ns3/wifi-module.h"
#include "ns3/bridge-helper.h"
#include "ns3/olsr-helper.h"
#include "ns3/mih-module.h"
#include "ns3/projeto-module.h"
NS_LOG_COMPONENT_DEFINE ("CenarioGenerico");
int
main (int argc, char *argv[])
{
#if 1
// LogComponentEnable ("Ipv6L3Protocol", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6Interface", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6StaticRouting", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6ListRouting", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6MobilityL4Protocol", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6Mobility", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6MobilityDemux", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6MobilityHeader", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6MobilityOption", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6MobilityOptionDemux", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6MobilityOptionHeader", LOG_LEVEL_ALL);
// LogComponentEnable ("Pmipv6Agent", LOG_LEVEL_LOGIC);
// LogComponentEnable ("Pmipv6MagNotifier", LOG_LEVEL_ALL);
// LogComponentEnable ("Pmipv6Profile", LOG_LEVEL_ALL);
// LogComponentEnable ("BindingCache", LOG_LEVEL_ALL);
// LogComponentEnable ("BindingUpdateList", LOG_LEVEL_ALL);
// LogComponentEnable ("UnicastRadvdApplication", LOG_LEVEL_ALL);
// LogComponentEnable ("Ping6Application", LOG_LEVEL_ALL);
// LogComponentEnable ("Ipv6TunnelL4Protocol", LOG_LEVEL_ALL);
// LogComponentEnable ("TunnelNetDevice", LOG_LEVEL_ALL);
// LogComponentEnable ("CsmaNetDevice", LOG_LEVEL_ALL);
// LogComponentEnable ("CsmaChannel", LOG_LEVEL_ALL);
// LogComponentEnable ("Node", LOG_LEVEL_ALL);
// LogComponentEnable ("Simulator", LOG_LEVEL_ALL);
// LogComponentEnable ("Icmpv6L4Protocol", LOG_LEVEL_ALL);
// LogComponentEnable ("NdiscCache", LOG_LEVEL_ALL);
// LogComponentEnable ("BridgeNetDevice", LOG_LEVEL_ALL);
// LogComponentEnable ("LteSpectrumPhy", LOG_LEVEL_ALL);
// LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
// LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
// LogComponentEnable ("Ipv6RawSocketImpl", LOG_LEVEL_ALL);
// LogComponentEnable ("Ns2MobilityHelper",LOG_LEVEL_DEBUG);
// LogComponentEnable ("ComfortApp", LOG_LEVEL_INFO);
// LogComponentEnable ("ComfortAppServer", LOG_LEVEL_INFO);
// LogComponentEnable ("SafetyApp", LOG_LEVEL_INFO);
// LogComponentEnable ("SafetyAppServer", LOG_LEVEL_INFO);
// LogComponentEnable ("UserApp", LOG_LEVEL_INFO);
// LogComponentEnable ("UserAppServer", LOG_LEVEL_INFO);
// LogComponentEnable ("UdpServer", LOG_LEVEL_INFO);
// LogComponentEnable ("UdpClient", LOG_LEVEL_INFO);
#endif
//variaveis
int nodeNum=50;
int nodeNaplicaton=5;
double duration=400;
//int cenario=0;
//Valores "globais"
InternetStackHelper internet;
Ipv4AddressHelper ipv4;
CsmaHelper csma, csma1;
BridgeHelper bridge;
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
lteHelper->SetEpcHelper (epcHelper);
lteHelper->SetSchedulerType("ns3::RrFfMacScheduler");
Ipv4StaticRoutingHelper ipv4RoutingHelper;
internet.Install (stas);
//Declaração dos aps
NodeContainer aps;
aps.Create(2);
internet.Install (aps.Get(0));
NodeContainer cn;
NodeContainer backbone;
NetDeviceContainer outerDevs;
NetDeviceContainer backboneDevs;
Ipv4InterfaceContainer backboneIfs;
Ipv4InterfaceContainer outerIfs;
cn.Create(1);
internet.Install (cn);
internet.Install (backbone);
backbone.Add(pgw);
NetDeviceContainer mag1Devs;
NetDeviceContainer mag2Devs;
NetDeviceContainer mag1ApDev;
NetDeviceContainer mag2ApDev;
NetDeviceContainer mag1BrDev;
NetDeviceContainer mag2BrDev;
Ipv4InterfaceContainer mag1Ifs;
Ipv4InterfaceContainer mag2Ifs;
//home agent do nó
lma.Add(backbone.Get(0));
//gatewares da redes
mags.Add(backbone.Get(1));
mags.Add(backbone.Get(2));
//rede 1 - wifi
mag1Net.Add(mags.Get(0));
mag1Net.Add(aps.Get(0));
//rede 2 - lte
mag2Net.Add(mags.Get(1));
mag2Net.Add(aps.Get(1));
Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
ipv4RoutingHelper.GetStaticRouting (outerNet.Get(1)->GetObject<Ipv4> ());
remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"),
Ipv4Mask ("255.0.0.0"), 1);
// CONFIGURE MOBILITY
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc =
CreateObject<ListPositionAllocator> ();
Ptr<ConstantPositionMobilityModel> enbMobility =
CreateObject<ConstantPositionMobilityModel> ();
enbMobility->SetPosition (Vector (407.5, 254.5, 0.0)); //camada física
positionAlloc->Add (Vector (407.5, 245.5, 0.0)); //MAG1AP
positionAlloc->Add (enbMobility->GetPosition()); //MAG2AP
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.SetPositionAllocator(positionAlloc);
mobility.Install(aps);
//Setting MAG2
NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice (aps.Get(1));
NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (stas);
Ipv4InterfaceContainer ueIpIface;
ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer
(ueLteDevs));
// Assign IP address to UEs, and install applications
//Setting MAG1
mag1Devs = csma.Install(mag1Net);
wifiMac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (MilliSeconds(100)));
wifiMac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid),
"ActiveProbing", BooleanValue (false));
Ipv4GlobalRoutingHelper::PopulateRoutingTables ();
ApplicationContainer confortserverApp[nodeNaplicaton];
ApplicationContainer confortclienApp[nodeNaplicaton];
ComfortAppServerHelper comfortServer[nodeNaplicaton];
ComfortAppHelper comfortapp[nodeNaplicaton];
ApplicationContainer safetyserverApp[nodeNaplicaton];
ApplicationContainer safetyclienApp[nodeNaplicaton];
SafetyAppServerHelper safetServer[nodeNaplicaton];
SafetyAppHelper safetapp[nodeNaplicaton];
ApplicationContainer userserverApp[nodeNaplicaton];
ApplicationContainer userclienApp[nodeNaplicaton];
UserAppServerHelper UserServer[nodeNaplicaton];
UserAppHelper userapp[nodeNaplicaton];
Ptr<mih::MihVeicular> mihUserwifi[nodeNaplicaton];
Simulator::Destroy ();
return 0;