Multiple RemoteHost

249 views
Skip to first unread message

Vaison

unread,
Jan 18, 2015, 2:32:30 PM1/18/15
to ns-3-...@googlegroups.com
I'm trying to create a multiple Remote but something goes wrong.... that's my code
#include "iostream"
#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"

using namespace ns3;

NS_LOG_COMPONENT_DEFINE
("Different RemoteHost");

int main (int argc, char *argv[])
{

    uint32_t numberOfNodes
= 5;
 
 
Ptr<LteHelper> lteHelper = CreateObject<LteHelper> ();
 
Ptr<PointToPointEpcHelper>  epcHelper = CreateObject<PointToPointEpcHelper> ();
  lteHelper
->SetEpcHelper (epcHelper);

 
Ptr<Node> pgw = epcHelper->GetPgwNode ();

   
// Create multiple RemoteHost
 
NodeContainer remoteHostContainer;
  remoteHostContainer
.Create (numberOfNodes);
  Ptr<Node> remoteHost = remoteHostContainer.GetN ();
 
 
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 (2);

 
Ipv4StaticRoutingHelper ipv4RoutingHelper;
 
Ptr<Ipv4StaticRouting> remoteHostStaticRouting = ipv4RoutingHelper.GetStaticRouting (remoteHost->GetObject<Ipv4> ());
  remoteHostStaticRouting
->AddNetworkRouteTo (Ipv4Address ("7.0.0.0"), Ipv4Mask ("255.0.0.0"), 1);

}

The highlighting line is failing, I've checked in documentation and this method exist... the error is

no known conversion for argument 1 from ‘uint32_t {aka unsigned int}’ to ‘ns3::Node*’
../scratch/multiplermthst.cc:38:42: error: invalid conversion from ‘uint32_t {aka unsigned int}’ to ‘ns3::Node*’ [-fpermissive]
   remoteHost = remoteHostContainer.GetN ();


Could someone let me know why I'm getting these error?

Regards,

~V
multiplermthst.cc

Tommaso Pecorella

unread,
Jan 18, 2015, 3:42:40 PM1/18/15
to ns-3-...@googlegroups.com
On Sunday, January 18, 2015 at 8:32:30 PM UTC+1, Vaison wrote:
Could someone let me know why I'm getting these error?

Because you didn't read the Doxygen documentation ?

"Get the number of Ptr<Node> stored in this container."
and if this may seems confusing (I don't know how it could be), a few lines after...

"Returns
the number of Ptr<Node> stored in this container."

I guess that trying to assign a number to a Ptr is not a good idea. Apparently your C++ compiler agrees with me.


T. 

Vaison

unread,
Jan 18, 2015, 5:42:40 PM1/18/15
to ns-3-...@googlegroups.com
Oh shi*! What an idiot I am.... I read documentation almost three times.. Sorry for the stupid question! But Im still asking me how I could get all the nodes and put just in one variable, I mean, if I have 2 nodes in the container (remote host), can I store in one Ptr<Node>??
I don't know if Im explained well...

Regards,

~V

Konstantinos

unread,
Jan 18, 2015, 6:02:44 PM1/18/15
to ns-3-...@googlegroups.com
No you can not.
Each Ptr<Node> is a "smart pointer" to one instance of the class Node and you simply can not refer to two objects with one name.
If you want to reference a group of nodes with one variable, you use the NodeContainer.

Then, to use it in your scenario, you need to build individual P2P links between the PGW with each RH node, create subnets for each P2P link and construct individual Routing Rules for each RH. 
Reply all
Reply to author
Forward
0 new messages