Cant get position of UEs

71 views
Skip to first unread message

KonstantinosDim

unread,
May 17, 2019, 8:31:36 AM5/17/19
to ns-3-users
Hello everyone, i am new to ns3 and i have a question regarding the lena-x2-handover-measures.cc example.
I implemented it using 10 UEs and 8 eNBs and used custom positions and speed for the UEs.
I want to get the position of UEs frequently, for example before and after a handover.
This is the code i added to get positions, but it doesnt show any output. Any ideas what i am doing wrong?

Code for function :(above main)

Εισαγωγή κώδικα εδώ...void
CourseChange (std::string context, Ptr<const MobilityModel> model)
{
 
Vector position = model->GetPosition ();
  NS_LOG_UNCOND
(context <<
   
" x = " << position.x << ", y = " << position.y);
}
Code for trace :(before Simulation ::Stop)

  std::ostringstream oss;
  oss
<<"/NodeList/" << ueNodes.Get (numberOfUes-1)->GetId () <<"/$ns3::MobilityModel/CourseChange";
 
Config::Connect (oss.str (), MakeCallback (&CourseChange)); Εισαγωγή κώδικα εδώ...

I suppose i have to add it and somewhere else but since i am new with this i would appreciate any kind of help :)

Tom Henderson

unread,
May 17, 2019, 9:28:14 AM5/17/19
to ns-3-...@googlegroups.com
On 5/17/19 5:31 AM, KonstantinosDim wrote:
> Hello everyone, i am new to ns3 and i have a question regarding the
> lena-x2-handover-measures.cc example.
> I implemented it using 10 UEs and 8 eNBs and used custom positions and
> speed for the UEs.
> I want to get the position of UEs frequently, for example before and
> after a handover.
> This is the code i added to get positions, but it doesnt show any
> output. Any ideas what i am doing wrong?

Make sure that you are working with a debug build; otherwise, the
NS_LOG_UNCOND () statement will not happen. Or else change
NS_LOG_UNCOND() to std::cout ...

>
> Code for function :(above main)
>
> |
> Εισαγωγήκώδικαεδώ...void
> CourseChange(std::stringcontext,Ptr<constMobilityModel>model)
> {
> Vectorposition =model->GetPosition();
>   NS_LOG_UNCOND (context <<
> " x = "<<position.x <<", y = "<<position.y);
> }
> |
> Code for trace :(before Simulation ::Stop)
>
> |
>   std::ostringstream oss;
>   oss
> <<"/NodeList/"<<ueNodes.Get(numberOfUes-1)->GetId()<<"/$ns3::MobilityModel/CourseChange";
> Config::Connect(oss.str (),MakeCallback(&CourseChange));Εισαγωγήκώδικαεδώ...
> |
>

The above will trace the course of the last UE in the ueNodes container,
not all UEs (your message above suggested that you would like all UEs).

This string can be used to get course change of all nodes:

"/NodeList/*/$ns3::MobilityModel/CourseChange"

> I suppose i have to add it and somewhere else but since i am new with
> this i would appreciate any kind of help :)
>
> --
> Posting to this group should follow these guidelines
> https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
> ---
> You received this message because you are subscribed to the Google
> Groups "ns-3-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to ns-3-users+...@googlegroups.com
> <mailto:ns-3-users+...@googlegroups.com>.
> To post to this group, send email to ns-3-...@googlegroups.com
> <mailto:ns-3-...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/ns-3-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ns-3-users/5d3ecd09-f831-4cb6-9928-d778a198190b%40googlegroups.com
> <https://groups.google.com/d/msgid/ns-3-users/5d3ecd09-f831-4cb6-9928-d778a198190b%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

KonstantinosDim

unread,
May 17, 2019, 9:47:58 AM5/17/19
to ns-3-users
Hello,
I have also tried what you suggested, but again i got nothing on terminal.
Perhaps i am missing some small detail?

Tom Henderson

unread,
May 17, 2019, 12:19:47 PM5/17/19
to ns-3-...@googlegroups.com
I tested this for you and found that the code is correct but you are not
getting any output because there are no course changes in that scenario.

To be precise, the simulation will call this method during the initial
setup:

void
ConstantVelocityMobilityModel::DoSetPosition (const Vector &position)
{
  m_helper.SetPosition (position);
  NotifyCourseChange ();
}

However, this method executes before simulation time zero, and before
the Config::Connect statements are handled.  So DoSetPosition() executes
before Config::Connect(), and after the simulation starts, there are no
further course changes.

- Tom


fatima zahra rabahi

unread,
May 18, 2019, 9:54:50 PM5/18/19
to ns-3-users

Dear Tom Henderson
please, I have a text file that contains the position of each node at every moment and I want to implement it like a mobility at my nodes
how do i do that with ns3 please
my best regards
Reply all
Reply to author
Forward
0 new messages