Trying to allocate twice the same uid ns3::timeTag error

322 views
Skip to first unread message

tomh...@mac.com

unread,
May 14, 2009, 3:46:15 AM5/14/09
to ns-3-users
Hi All,

I have added the following code to add a tag to the packet on
creation, that is a timestamp of the current time. It is then read on
reception to calculate the throughput time of the packet:

void SendingFunction (Ptr<Socket> m_socket, uint32_t m_pktSize) {
Ptr<Packet> p = Create<Packet> (m_pktSize);
timeTag stamp;
double sendTime = Simulator::Now().GetSeconds();
stamp.SetSimpleValue (sendTime);
p->AddTag(stamp);
m_socket->Send (p);
totalSent++;
}


When I run highly dense or high utilisation simulations (all wifi), I
get the following error:

Trying to allocate twice the same uid: ns3::timeTag
[node-e28:22972] *** Process received signal ***
[node-e28:22972] Signal: Segmentation fault (11)
[node-e28:22972] Signal code: Address not mapped (1)
[node-e28:22972] Failing at address: (nil)
[node-e28:22972] [ 0] /lib64/tls/libpthread.so.0 [0x357f20c430]
[node-e28:22972] [ 1] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZN51_GLOBAL__N_.._src_core_type_id.cc_AAEE1AA9_4230396110IidManager11AllocateUidESs
+0xb2) [0x2a958dd17e]
[node-e28:22972] [ 2] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZN3ns36TypeIdC1EPKc+0x44) [0x2a958de494]
[node-e28:22972] [ 3] /shared/home/ucabtdh/data/ns-3.4/build/debug/
scratch/wifi_para(_ZN7timeTag9GetTypeIdEv+0x107) [0x41557f]
[node-e28:22972] [ 4] /shared/home/ucabtdh/data/ns-3.4/build/debug/
scratch/wifi_para(_ZNK7timeTag17GetInstanceTypeIdEv+0x18) [0x41584e]
[node-e28:22972] [ 5] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZNK3ns36Packet20FindFirstMatchingTagERNS_3TagE+0x2c)
[0x2a959e9c74]
[node-e28:22972] [ 6] /shared/home/ucabtdh/data/ns-3.4/build/debug/
scratch/wifi_para [0x41597f]
[node-e28:22972] [ 7] /shared/home/ucabtdh/data/ns-3.4/build/debug/
scratch/wifi_para
(_ZN3ns319FunctorCallbackImplIPFvSsNS_3PtrIKNS_6PacketEEERKNS_7AddressEEvSsS4_S7_NS_5emptyESA_SA_SA_SA_SA_EclESsS4_S7_
+0x
4a) [0x42a456]
[node-e28:22972] [ 8] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZNK3ns38CallbackIvSsNS_3PtrIKNS_6PacketEEERKNS_7AddressENS_5emptyES8_S8_S8_S8_S8_EclESsS4_S7_
+0x60) [0x2a95b4f0d2]
[node-e28:22972] [ 9] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZN3ns324BoundFunctorCallbackImplINS_8CallbackIvSsNS_3PtrIKNS_6PacketEEERKNS_7AddressENS_5emptyES9_S9_S9_S9_S9_EEvSsS5_S8_S9_S9_
S9_S9_S9_S9_EclES5_S8_+0x4c) [0x2a95b4f00e]
[node-e28:22972] [10] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZNK3ns38CallbackIvNS_3PtrIKNS_6PacketEEERKNS_7AddressENS_5emptyES8_S8_S8_S8_S8_S8_EclES4_S7_
+0x42) [0x2a95b4c874]
[node-e28:22972] [11] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZNK3ns314TracedCallbackINS_3PtrIKNS_6PacketEEERKNS_7AddressENS_5emptyES8_S8_S8_S8_S8_EclES4_S7_
+0x6e) [0x2a95b4c2ca]
[node-e28:22972] [12] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZN3ns310PacketSink10HandleReadENS_3PtrINS_6SocketEEE+0x47d)
[0x2a95b4b431]
[node-e28:22972] [13] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZN3ns318MemPtrCallbackImplIPNS_10PacketSinkEMS1_FvNS_3PtrINS_6SocketEEEEvS5_NS_5emptyES8_S8_S8_S8_S8_S8_S8_EclES5_
+0x89) [0x2a9
5b4d6f9]
[node-e28:22972] [14] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZNK3ns38CallbackIvNS_3PtrINS_6SocketEEENS_5emptyES4_S4_S4_S4_S4_S4_S4_EclES3_
+0x3a) [0x2a95a42aea]
[node-e28:22972] [15] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZN3ns36Socket14NotifyDataRecvEv+0xf1) [0x2a95a41c4d]
[node-e28:22972] [16] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZN3ns313UdpSocketImpl9ForwardUpENS_3PtrINS_6PacketEEENS_11Ipv4AddressEt
+0x2cc) [0x2a95ab5082]
[node-e28:22972] [17] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZN3ns318MemPtrCallbackImplINS_3PtrINS_13UdpSocketImplEEEMS2_FvNS1_INS_6PacketEEENS_11Ipv4AddressEtEvS5_S6_tNS_5emptyES9_S9_S9_S
9_S9_EclES5_S6_t+0xa4) [0x2a95abfe70]
[node-e28:22972] [18] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZNK3ns38CallbackIvNS_3PtrINS_6PacketEEENS_11Ipv4AddressEtNS_5emptyES5_S5_S5_S5_S5_EclES3_S4_t
+0x48) [0x2a95a87fa4]
[node-e28:22972] [19] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so
(_ZN3ns312Ipv4EndPoint11DoForwardUpENS_3PtrINS_6PacketEEENS_11Ipv4AddressEt
+0x35) [0x2a95a8766b]
[node-e28:22972] [20] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so [0x2a95a87d5b]
[node-e28:22972] [21] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZN3ns39EventImpl6InvokeEv+0x2a) [0x2a9598e0e0]
[node-e28:22972] [22] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZN3ns320DefaultSimulatorImpl15ProcessOneEventEv+0x1ca)
[0x2a959a7188]
[node-e28:22972] [23] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZN3ns320DefaultSimulatorImpl3RunEv+0x47) [0x2a959a7331]
[node-e28:22972] [24] /shared/home/ucabtdh/data/ns-3.4/build/debug/
libns3.so(_ZN3ns39Simulator3RunEv+0xd1) [0x2a9598eb11]
[node-e28:22972] [25] /shared/home/ucabtdh/data/ns-3.4/build/debug/
scratch/wifi_para
(_Z10ExperimentSsjjjjdjSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsSsd+0x90d4)
[0x41ec7c]
[node-e28:22972] [26] /shared/home/ucabtdh/data/ns-3.4/build/debug/
scratch/wifi_para(main+0x2317) [0x421879]
[node-e28:22972] [27] /lib64/tls/libc.so.6(__libc_start_main+0xdb)
[0x357db1c3fb]
[node-e28:22972] [28] /shared/home/ucabtdh/data/ns-3.4/build/debug/
scratch/wifi_para(__gxx_personality_v0+0xd2) [0x4152da]
[node-e28:22972] *** End of error message ***


I understand the the timeStamp will not be unique, but assumed that
the packet object I was applying it to was, so should not get this
error.

Any assistance on how to get around this would be great. The packet
creation/sending is called via a calculation for a Poisson
distribution with 5 packets per second expected.

I can send the full code through, but would rather not post to the
forum.

Many thanks,

Tom.

Mathieu Lacage

unread,
May 14, 2009, 4:12:25 AM5/14/09
to ns-3-...@googlegroups.com
On Thu, 2009-05-14 at 00:46 -0700, TomH...@mac.com wrote:
> Hi All,
>
> I have added the following code to add a tag to the packet on
> creation, that is a timestamp of the current time. It is then read on
> reception to calculate the throughput time of the packet:
>
> void SendingFunction (Ptr<Socket> m_socket, uint32_t m_pktSize) {
> Ptr<Packet> p = Create<Packet> (m_pktSize);
> timeTag stamp;
> double sendTime = Simulator::Now().GetSeconds();
> stamp.SetSimpleValue (sendTime);
> p->AddTag(stamp);
> m_socket->Send (p);
> totalSent++;
> }

[snip]

> I understand the the timeStamp will not be unique, but assumed that
> the packet object I was applying it to was, so should not get this
> error.

Can you show the source code for timeTag::GetTypeId and
timeTag::GetInstanceTypeId ?

Mathieu

tomh...@mac.com

unread,
May 14, 2009, 4:56:35 AM5/14/09
to ns-3-users
Thanks Mathieu,

TypeId
timeTag::GetTypeId (void)
{
static TypeId tid = TypeId ("ns3::timeTag")
.SetParent<Tag> ()
.AddConstructor<timeTag> ()
.AddAttribute ("SimpleValue",
"A simple value",
EmptyAttributeValue (),
MakeDoubleAccessor (&timeTag::GetSimpleValue),
MakeDoubleChecker<double> ())
;
return tid;
}
TypeId
timeTag::GetInstanceTypeId (void) const
{
return GetTypeId ();
}

T.

On May 14, 9:12 am, Mathieu Lacage <mathieu.lac...@sophia.inria.fr>
wrote:

Mathieu Lacage

unread,
May 14, 2009, 5:00:45 AM5/14/09
to ns-3-...@googlegroups.com
Could it be that you created two _separate_ classes which register a
typeid named "ns3::timeTag" ? If so, you need to give them different
typeid names.

Mathieu

tomh...@mac.com

unread,
May 14, 2009, 5:04:10 AM5/14/09
to ns-3-users
Would this be the problem, I thought that when removing the tag it has
to have the same typeID? The tag is removed upon reception as follows:

static void SinkRx (std::string path, Ptr<const Packet> p, const
Address &address) {
// Getting the Size of the Packet
uint32_t singleBytes = p->GetSize ();
totalBytes = singleBytes + totalBytes;

// Delay Calculation
timeTag stampRx;
p->FindFirstMatchingTag (stampRx);
double stampRxClock = stampRx.GetSimpleValue();
double delayStamp = (Simulator::Now().GetSeconds() - stampRxClock);
// This part adds the packet delay to the delayArray array if the
value != 0
if (delayStamp > 0.0){
delays << delayStamp << std::endl;
delayArray[totalReceived] = delayStamp;
}
totalReceived++;
}

Thanks, Tom.

On May 14, 10:00 am, Mathieu Lacage <mathieu.lac...@sophia.inria.fr>
wrote:
> Could it be that you created two _separate_ classes which register a
> typeid named "ns3::timeTag" ? If so, you need to give them different
> typeid names.
>
> Mathieu
>

tomh...@mac.com

unread,
May 14, 2009, 5:05:09 AM5/14/09
to ns-3-users
It's worth noting that this normally works, it only fails when it
appears to try to create two tags the same in a single packet, or so I
thought?

I can send you the full code if you require.

Thanks,

Tom.

Mathieu Lacage

unread,
May 14, 2009, 7:22:39 AM5/14/09
to ns-3-...@googlegroups.com
On Thu, 2009-05-14 at 02:05 -0700, TomH...@mac.com wrote:
> It's worth noting that this normally works, it only fails when it
> appears to try to create two tags the same in a single packet, or so I
> thought?

I don't know which version of ns-3 you are using but theoretically,
using ns-3-dev, you should be able to store the same tag twice in the
same packet so, no, I don't really know what is going on. If you have a
simple testcase, I could look at it.

Mathieu

tomh...@mac.com

unread,
May 14, 2009, 12:28:42 PM5/14/09
to ns-3-users
Thanks for your help Mathieu, I'm just testing on the dev branch, but
have to update some code first. Will update shortly.

T.

On May 14, 12:22 pm, Mathieu Lacage <mathieu.lac...@sophia.inria.fr>
wrote:
Reply all
Reply to author
Forward
0 new messages