PROBLEMBY ADDING Ptr <Packet> packet=Create<Packet> ("hello",5);

199 views
Skip to first unread message

PRADEEP SINGH

unread,
Nov 29, 2011, 7:43:02 AM11/29/11
to ns-3-users
IF I ADD Ptr <Packet> packet=Create<Packet> ();
THERE IS NO ERROR BUT WHEN I ADD
Ptr <Packet> packet=Create<Packet> ("hello",5);
FOLLOWING ERROR OCCURS
PLEASE SUGGEST ME
Waf: Entering directory `/home/pradeep/Desktop/ns-allinone-3.12.1/
ns-3.12.1/build'
[1136/1211] cxx: aodv_p_more_sender.cc -> ../build/optimized/scratch/
aodv_p_more_sender_15.o
In file included from optimized/ns3/attribute.h:25:0,
from optimized/ns3/address.h:26,
from optimized/ns3/ipv4-address.h:26,
from optimized/ns3/aodv-id-cache.h:32,
from optimized/ns3/aodv-dpd.h:26,
from optimized/ns3/aodv-module.h:10,
from ../scratch/aodv_p_more_sender.cc:1:
optimized/ns3/ptr.h: In function ‘ns3::Ptr<T> ns3::Create(T1, T2)
[with T = ns3::Packet, T1 = const char*, T2 = int]’:
../scratch/aodv_p_more_sender.cc:201:47: instantiated from here
optimized/ns3/ptr.h:245:39: error: invalid conversion from ‘const
char*’ to ‘const uint8_t*’
optimized/ns3/ptr.h:245:39: error: initializing argument 1 of
‘ns3::Packet::Packet(const uint8_t*, uint32_t)’
Waf: Leaving directory `/home/pradeep/Desktop/ns-allinone-3.12.1/
ns-3.12.1/build'
Build failed: -> task failed (err #1):
{task: cxx aodv_p_more_sender.cc -> aodv_p_more_sender_15.o}


THANK U

Eric Gamess

unread,
Nov 29, 2011, 9:18:12 AM11/29/11
to ns-3-users
Hi Pradeep,

Do not forget to have a look at the API:
http://www.nsnam.org/docs/release/3.12/doxygen/classns3_1_1_packet.html

Try:
Ptr <Packet> packet=Create<Packet> (reinterpret_cast<uint8_t const
*>("hello"),5);

Eric.

Reply all
Reply to author
Forward
0 new messages