Ndrs
unread,Mar 2, 2012, 6:28:20 AM3/2/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ns-3-users
Hi all,
I'm trying to set a very simple scenario, based on lena-simple-
epc.cc.
I want the remote host to send packets to a multicast address that all
ues attached to the enb will receive.
The problem is that no ue is able to receive the multicast packets.
I set a destination "multicastGroup" address to send the packets
(225.1.2.4) and set the following static routes:
from the remoteHost to the pgw (over the point to point interface)
from the pgw to the enb (over the S1 interface)
from the enb to the LTE interface (which I think is not necessary,
because the pgw is already in the same IP network than the ues, but
I'm running out of ideas).
I'm not an LTE expert, maybe I'm having conceptual mistakes here so
any help will be appreciated.
----------------------------------------
#include "ns3/lte-helper.h"
#include "ns3/epc-helper.h"
#include "ns3/core-module.h"
#include "ns3/network-module.h"
#include "ns3/mobility-module.h"
#include "ns3/config-store.h"
#include "ns3/internet-module.h"
#include "ns3/applications-module.h"
#include "ns3/lte-module.h"
#include "ns3/point-to-point-helper.h"
#include "ns3/ipv4-static-routing-helper.h"
using namespace ns3;
NS_LOG_COMPONENT_DEFINE ("LteMulticast");
int
main (int argc, char *argv[])
{
uint16_t numDevs = 4;
double duration = 5.5;
LogComponentEnable("PacketSink",
(LogLevel) (LOG_LEVEL_INFO|LOG_PREFIX_FUNC|LOG_PREFIX_TIME|
LOG_PREFIX_NODE));
LogComponentEnable("PacketSink",
(LogLevel) (LOG_LEVEL_DEBUG|LOG_PREFIX_FUNC|LOG_PREFIX_TIME|
LOG_PREFIX_NODE));
LogComponentEnable("UdpTraceClient",
(LogLevel) (LOG_LEVEL_INFO|LOG_PREFIX_FUNC|LOG_PREFIX_TIME|
LOG_PREFIX_NODE));
LogComponentEnable("UdpTraceClient",
(LogLevel) (LOG_LEVEL_DEBUG|LOG_PREFIX_FUNC|LOG_PREFIX_TIME|
LOG_PREFIX_NODE));
// *** ECP *** //
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<EpcHelper> epcHelper = CreateObject<EpcHelper> ();
lteHelper->SetEpcHelper (epcHelper);
lteHelper->SetSchedulerType("ns3::RrFfMacScheduler");
Ptr<Node> pgw = epcHelper->GetPgwNode (); //Packet Data Network
Gateway
// Create a RemoteHost
NodeContainer remoteHostContainer;
remoteHostContainer.Create (1);
Ptr<Node> 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);
Ipv4StaticRoutingHelper ipv4RoutingHelper;
Ptr<Ipv4StaticRouting> remoteHostStaticRouting =
ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"),
Ipv4Mask ("255.0.0.0"), 1);
NodeContainer ueNodes;
NodeContainer enbNodes;
enbNodes.Create(1);
ueNodes.Create(numDevs);
// ******* Mobility ****** //
MobilityHelper mobility;
// For the UEs
double width;
width = sqrt (numDevs);
modf (width , &width);
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX",
DoubleValue (0.0), "MinY", DoubleValue (0.0), "DeltaX", DoubleValue
(50),
"DeltaY", DoubleValue (50), "GridWidth", UintegerValue
(width), "LayoutType", StringValue ("RowFirst"));
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (ueNodes);
mobility.SetPositionAllocator ("ns3::GridPositionAllocator", "MinX",
DoubleValue (width*50));
mobility.Install (enbNodes);
// Install LTE Devices to the nodes
NetDeviceContainer enbLteDevs = lteHelper->InstallEnbDevice
(enbNodes);
NetDeviceContainer ueLteDevs = lteHelper->InstallUeDevice (ueNodes);
// Attach UEs to the eNodeB
for (uint16_t i = 0; i < numDevs; i++)
{
NS_LOG_DEBUG ("Attaching UE " << i << " to eNB");
lteHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(0));
}
// Install the IP stack on the UEs
internet.Install (ueNodes);
Ipv4InterfaceContainer ueIp;
ueIp = epcHelper->AssignUeIpv4Address (NetDeviceContainer
(ueLteDevs));
Ptr<Node> enb = enbNodes.Get (0);
// Assign IP address to UEs, and install applications
for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
{
Ptr<Node> ueNode = ueNodes.Get (u);
// Set the default gateway for the UE
Ptr<Ipv4StaticRouting> ueStaticRouting =
ipv4RoutingHelper.GetStaticRouting (ueNode->GetObject<Ipv4> ());
ueStaticRouting->SetDefaultRoute (epcHelper-
>GetUeDefaultGatewayAddress (), 1);
}
lteHelper->ActivateEpsBearer (ueLteDevs, EpsBearer
(EpsBearer::NGBR_IMS), EpcTft::Default ());
// ******** Multicast route ****** //
Ipv4Address multicastSource (remoteHost->GetObject<Ipv4> ()-
>GetAddress (1, 0).GetLocal ());
Ipv4Address multicastGroup ("225.1.2.4");
//Ipv4Address multicastGroup ("7.0.0.3");
uint16_t multicastPort = 1236;
Ipv4StaticRoutingHelper multicast;
// Configure a multicast route on PGW
Ptr<Node> multicastRouter = pgw;
Ptr<NetDevice> inputIf = pgw->GetDevice(2);
multicast.AddMulticastRoute (multicastRouter, multicastSource,
multicastGroup, inputIf, pgw->GetDevice(1));
// Set up a default multicast route on the sender
Ptr<Node> sender = remoteHost;
Ptr<NetDevice> senderIf = internetDevices.Get (1);
remoteHostStaticRouting->SetDefaultMulticastRoute (1);
// Configure a multicast route on eNodeB
multicastRouter = enb;
inputIf = enb->GetDevice(2);
multicast.AddMulticastRoute (multicastRouter, multicastSource,
multicastGroup, inputIf, enb->GetDevice(2));
// ********** APPLICATIONS ****** //
PacketSinkHelper packetSinkHelper ("ns3::UdpSocketFactory",
InetSocketAddress (Ipv4Address::GetAny (), multicastPort));
ApplicationContainer sinkApp;
sinkApp = packetSinkHelper.Install (ueNodes);
sinkApp.Start (Seconds (0.01));
sinkApp.Stop (Seconds (duration));
UdpTraceClientHelper udpClient (multicastGroup, multicastPort, "");
ApplicationContainer clientApp;
clientApp = udpClient.Install (remoteHost);
clientApp.Start (Seconds (3));
clientApp.Stop (Seconds (4));
Simulator::Stop(Seconds(duration));
Simulator::Run();
Simulator::Destroy();
return 0;
}