Skip to first unread message

John Scott

unread,
Apr 8, 2017, 10:53:12 AM4/8/17
to ns-3-users
Hi,

I am writing a packet tag class to get nodes mobility information. The position works well, but speed does not. Here's a snapshot of my code

TypeId
LocationTag::GetTypeId ()
{
 
static TypeId tid = TypeId ("ns3::LocationTag")
   
.SetParent<Tag> ()
 
;
 
return tid;
}

TypeId
PositionTag::GetTypeId ()
{
 
static TypeId tid = TypeId ("ns3::PositionTag")
   
.SetParent<LocationTag> ()
 
;
 
return tid;
}

const Vector &
PositionTag::GetPosition () const
{
 
return m_position; // from MobilityHelper
}

const Vector &
PositionTag::GetSpeed () const
{
 
return m_velocity; // from ConstantVelovityHelper
}

And I have the following libraries declared on my header file:
#include "ns3/tag.h"
#include "ns3/vector.h"

However, I am getting the error:
error: m_velocity was not declared in this scope

Can you help please?
In the future I would like to add timestamp and direction of movement too.

Thank you!

John Scott

unread,
Apr 9, 2017, 3:50:24 PM4/9/17
to ns-3-users
I updated my tag class to implement velocity and timestamp. The code compiles, but when I try to run the application it crashes with the following message. This is the GDB output, which didn't help me.

assert failed. cond="m_current + 1 <= m_end", file=./ns3/tag-buffer.h, line=174
terminate called without an active exception


Program received signal SIGABRT, Aborted.
0x00007fffed3f8428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory

The complete tag files are attached.
My application calls


/*
   * Location Tag
   */

 
Ptr<MobilityModel> model = GetNode ()->GetObject<MobilityModel> ();
 
Vector position;
  position
= model->GetPosition ();
  NS_LOG_INFO
("Sender position is: " << position);
 
 
Vector velocity;
  velocity
= model->GetVelocity();
  NS_LOG_INFO
("Snder velocity is: " << velocity);
 
 
Time timeNow;
  timeNow
= Simulator::Now();
  NS_LOG_INFO
("Current time is: " << timeNow);
 
 
if (model)
 
{
  position
= model->GetPosition ();
  velocity
= model->GetVelocity ();
 
GeoTag tag;
  tag
.SetPosition (position);
  tag
.SetSpeed (velocity);
  tag
.SetTimestamp(timeNow);
  interest
->GetPayload()->AddPacketTag (tag);
  NS_LOG_INFO
("Consumer adding tag!");
 
}

Could you assist please?

Thank you
location-tag.cc
location-tag.h

Konstantinos

unread,
Apr 10, 2017, 5:06:13 AM4/10/17
to ns-3-users
Hi John

Your GetSerializedSize() method is inconsistent with how much you write. 

uint32_t
LocationTag::GetSerializedSize() const
{
  return 2 * sizeof (double);
}


This should return the amount of bytes that are to be written/read from the buffer.
You say 2-doubles, but you actually you write 4 doubles and an uint-64!

Regards,
K

John Scott

unread,
Apr 10, 2017, 12:20:06 PM4/10/17
to ns-3-...@googlegroups.com
Hi Konstantinos,
Thank you for your reply.
I changed the buffer size to 4, but got an error.

assert failed. cond="tag.GetSerializedSize () <= TagData::MAX_SIZE", file=../src/network/model/packet-tag-list.cc, line=257

terminate called without an active exception

How do I go about solving this issue?

Thank you



On Monday, April 10, 2017 5:14 AM, Konstantinos <dinos.k...@gmail.com> wrote:


Hi John

Your GetSerializedSize() method is inconsistent with how much you write. 

uint32_t
LocationTag::GetSerializedSize() const
{
  return 2 * sizeof (double);
}


This should return the amount of bytes that are to be written/read from the buffer.
You say 2-doubles, but you actually you write 4 doubles and an uint-64!

Regards,
K

On Sunday, April 9, 2017 at 8:50:24 PM UTC+1, John Scott wrote:
I updated my tag class to implement velocity and timestamp. The code compiles, but when I try to run the application it crashes with the following message. This is the GDB output, which didn't help me.

assert failed. cond="m_current + 1 <= m_end", file=./ns3/tag-buffer.h, line=174
terminate called without an active exception


Program received signal SIGABRT, Aborted.
0x00007fffed3f8428 in __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/rai se.c:54
54 ../sysdeps/unix/sysv/linux/rai se.c: No such file or directory

The complete tag files are attached.
My application calls


/*
   * Location Tag
   */

 
Ptr<MobilityModel> model = GetNode ()->GetObject<MobilityModel> ();
 
Vector position;
  position
= model->GetPosition ();
  NS_LOG_INFO
("Sender position is: " << position);
 
 
Vector velocity;
  velocity
= model->GetVelocity();
  NS_LOG_INFO
("Snder velocity is: " << velocity);
 
 
Time timeNow;
  timeNow
= Simulator::Now();
  NS_LOG_INFO
("Current time is: " << timeNow);
 
 
if (model)
 
{
  position
= model->GetPosition ();
  velocity
= model->GetVelocity ();
 
GeoTag tag;
  tag
.SetPosition (position);
  tag
.SetSpeed (velocity);
  tag
.SetTimestamp(timeNow);

  interest
->GetPayload()->AddPac ketTag (tag);
--
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 a topic in the Google Groups "ns-3-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ns-3-users/4Zd0CZT2npc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at https://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/d/optout.


Konstantinos

unread,
Apr 11, 2017, 1:11:32 PM4/11/17
to ns-3-users, scot...@yahoo.com
Hi,

Please upgrade your ns-3 release (to ns-3-dev)
Up to ns-3.26 there is a limit on the packet data you can add.

However, even if you change the buffer size to 4 as you mention, that is still wrong. 
You have 4-doubles plus 4bytes (the 64-bit timestamp).

Further, if you want to share that information with other nodes, the proper/realistic method would be to add it to the packet as payload, not tag. 
Tags are only simulated meta-data, not real data that go over the wire.

Regards,
K
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.

John Scott

unread,
Apr 18, 2017, 2:51:41 PM4/18/17
to ns-3-...@googlegroups.com
Hi Konstantinos,

Thank you. I ended up creating multiple tags, which is working fine.
I'm having trouble to get the information from a tag that comes from the sink node and add to a packet at the source node.

At sink node:
    data->GetPayload ()->AddPacketTag (sinkTag);

At source node: (don't know how to do this)
    m_sourceTag.SetPosition(data->GetPayload()->PeekPacketTag (sinkTag.GetPosition ()));

How can I read the information from one tag and write on the other tag?

Thank you



On Tuesday, April 11, 2017 1:11 PM, Konstantinos <dinos.k...@gmail.com> wrote:


Hi,

Please upgrade your ns-3 release (to ns-3-dev)
Up to ns-3.26 there is a limit on the packet data you can add.

However, even if you change the buffer size to 4 as you mention, that is still wrong. 
You have 4-doubles plus 4bytes (the 64-bit timestamp).

Further, if you want to share that information with other nodes, the proper/realistic method would be to add it to the packet as payload, not tag. 
Tags are only simulated meta-data, not real data that go over the wire.

Regards,
K

On Monday, April 10, 2017 at 5:20:06 PM UTC+1, John Scott wrote:
Hi Konstantinos,
Thank you for your reply.
I changed the buffer size to 4, but got an error.

assert failed. cond="tag.GetSerializedSize () <= TagData::MAX_SIZE", file=../src/network/model/ packet-tag-list.cc, line=257
To unsubscribe from this group and all its topics, send an email to ns-3-users+...@googlegroups.com.

John Scott

unread,
Apr 18, 2017, 2:55:48 PM4/18/17
to ns-3-...@googlegroups.com
just solved the issue!

Konstantinos

unread,
Apr 18, 2017, 2:59:52 PM4/18/17
to ns-3-users, scot...@yahoo.com
Hi John,

The documentation explains how to Add/Remove PacketTags 

I would recommend not to do the 'peek' within the set method.
Do all the initialisations, get the values you want and then set it.

Regards
K
To unsubscribe from this group and all its topics, send an email to ns-3-users+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages