I got this message.
Gateway( defined as nodes(1) ) -- Mesh Network (defined as nodes(2....24) ) Assume that we have 25 nodes. First node is my gateway, and others are smart meters. I successfully made connection between gateway and mesh network.
After time between gateway and mesh network finish, I want to make a connection between gateway(defined as remoteHost) and UserEquipment(UE) in LTE NETWORK. Gateway successfully received packets from UE, but UE didn't receive packets from Gateway. Both of them sent packets each other.
I am sending my codes very shortly so that you can understand. This code that I tried to tell my scenario in my previous email. I am not sure but I think InternetStacker makes a problem because Nodes(Global variable) are installed by internet before. when I want to use nodes(1)[that was installed by internetStacker] for connection between this and UE. You can see this inside Run() function. I wrote this capital letters.
NS_LOG_INFO("LTE APP START");
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
Ptr<PointToPointEpcHelper> epcHelper = CreateObject<PointToPointEpcHelper> ();
lteHelper->SetEpcHelper (epcHelper);
Ptr<Node> pgw = epcHelper->GetPgwNode ();
NS_LOG_INFO("SECOND STEP- GATEWAP SETUP");
Ptr<Node> remoteHost = nodes.Get(0);
NS_LOG_INFO("NODE 0 IP ADDRESS " << interfaces.GetAddress(0));
internetStacker.Install (remoteHost); -------> THIS STATEMENT GENERATES AN ERROR!
NS_LOG_INFO("THIRD STEP- CREATE INTERNET");
// 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);
NS_LOG_INFO("FOURTH STEP- CONFIGURE REMOTEHOST IPv4 ADDRESS");
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);
NS_LOG_INFO("remoteHostAddr--> " << remoteHostAddr);
NS_LOG_INFO("FIFTH STEP- SET UP IPv4 ADDRESS for UE");
Ipv4StaticRoutingHelper ipv4RoutingHelper;
Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
remoteHostStaticRouting->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);
NS_LOG_INFO("SIXTH STEP- CREATE UE_NODES and ENB_NODES");
uint16_t numberOfNodes = 1;
double distance = 60.0;
NodeContainer ueNodes;
NodeContainer enbNodes;
enbNodes.Create(numberOfNodes);
ueNodes.Create(numberOfNodes);
// Install Mobility Model
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
for (uint16_t i = 0; i < numberOfNodes; i++)
{
positionAlloc->Add (Vector(distance * i, 0, 0));
}
NS_LOG_INFO("SEVENTH STEP- CREATE MOBILITY");
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
internetStack.Install (ueNodes);
Ipv4InterfaceContainer ueIpIface;
ueIpIface = epcHelper->AssignUeIpv4Address (NetDeviceContainer (ueLteDevs));
NS_LOG_INFO("EIGHTH STEP- ASSIGN IP ADDRESS to UES");
// 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);
}
NS_LOG_INFO("NINTH STEP- ATTACH one UE per eNodeB");
// Attach one UE per eNodeB
for (uint16_t i = 0; i < numberOfNodes; i++)
{
lteHelper->Attach (ueLteDevs.Get(i), enbLteDevs.Get(i));
// side effect: the default EPS bearer will be activated
}
double interPacketInterval = 100;
// Install and start applications on UEs and remote host
uint16_t dlPort = 1234;
uint16_t ulPort = 2000;
ApplicationContainer clientApps;
ApplicationContainer serverApps;
for (uint32_t u = 0; u < ueNodes.GetN (); ++u)
{
++ulPort;
PacketSinkHelper dlPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (ueIpIface.GetAddress (u), dlPort));
NS_LOG_INFO("UE--> "<< ueIpIface.GetAddress (u) << " and port: "<< dlPort<<" and mask: "<< ueIpIface.GetAddress (u).GetBroadcast());
dlPacketSinkHelper.SetAttribute("TransMode", UintegerValue(1)); //UE
PacketSinkHelper ulPacketSinkHelper ("ns3::UdpSocketFactory", InetSocketAddress (remoteHostAddr, ulPort));
NS_LOG_INFO("REMOTEHOST--> "<< remoteHostAddr<< " and port: "<< ulPort<<" and mask: "<<remoteHostAddr.GetBroadcast());
ulPacketSinkHelper.SetAttribute("TransMode", UintegerValue(0)); //RemoteHost
serverApps.Add (dlPacketSinkHelper.Install (ueNodes.Get(u)));
serverApps.Add (ulPacketSinkHelper.Install (remoteHost));
UdpClientHelper dlClient (ueIpIface.GetAddress (u), dlPort); //UE
NS_LOG_INFO("U Number : " << u);
dlClient.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
dlClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
dlClient.SetAttribute("TransMode", UintegerValue(1)); //UE
UdpClientHelper ulClient (remoteHostAddr, ulPort);//RemoteHost
ulClient.SetAttribute ("Interval", TimeValue (MilliSeconds(interPacketInterval)));
ulClient.SetAttribute ("MaxPackets", UintegerValue(1000000));
ulClient.SetAttribute("TransMode", UintegerValue(0)); //RemoteHost
clientApps.Add (dlClient.Install (remoteHost));
clientApps.Add (ulClient.Install (ueNodes.Get(u)));
}
serverApps.Start (Seconds (250));
clientApps.Start (Seconds (260));
lteHelper->EnableTraces ();
serverApps.Stop(Seconds(300));
clientApps.Stop(Seconds(285));
NS_LOG_INFO("THE END LTE");