Re: [ns] Help: accessing contents of data payload in NS2

2010-04-08 Thread Sidney Doria

There are many options to circunvent this issue and use packet
payloads. Some more elegant, some less elegant.

A more elegant is to use a new class inherited from AppData, ready to
manipulate a real payload, and more, ready to manipulate real objects,
or everything you want. (you must implement a virtual copy() and a
virtual destructor of this class to use inheritance. So, the packet
may be copied and destructed).

A less elegant is use a pointer in the packet's header (a new packet
type for your app). This pointer will be your packet payload, so it
may carry what you want.

You may use a buffer of payloads as a onipresent entity (like in
BitTorrent.patch from Kolja Eger).

Many options, but you'll not carry a real packet payload (with
everything you want) in a standard NS-2.

Sidney Doria
UFCG / BRAZIL


2010/4/6 MiLo_TUD mike.lor...@mailbox.tu-dresden.de:


 Oh, sorry. You used PacketData.
 But how did you wrote your payload to your packet ?

 I see, there's a problem. setdata(..) want a pointer to the class AppData.
 And you don't have direct access to the unsigned char* data_ of PacketData.
 So you can't create a new object with data inside. It is only possible to
 create an empty packet or copy an existing packet of type PacketData.
 So you have to derive a class from class PacketData or change the the class
 PacketData.


 --
 View this message in context: 
 http://old.nabble.com/Help%3A-accessing-contents-of-data-payload-in-NS2-tp28115846p28153305.html
 Sent from the ns-users mailing list archive at Nabble.com.





-- 
Sidney Doria
Redes ad hoc móveis
Doutorado em Computação
UFCG
Brasil

Nessa jornada, o conhecimento será o seu escudo...
(Mestre dos Magos no episódio do grimoire de ouro)



Re: [ns] Help: accessing contents of data payload in NS2

2010-04-07 Thread MiLo_TUD


Oh, sorry. You used PacketData.
But how did you wrote your payload to your packet ?

I see, there's a problem. setdata(..) want a pointer to the class AppData.
And you don't have direct access to the unsigned char* data_ of PacketData.
So you can't create a new object with data inside. It is only possible to
create an empty packet or copy an existing packet of type PacketData.
So you have to derive a class from class PacketData or change the the class
PacketData.


-- 
View this message in context: 
http://old.nabble.com/Help%3A-accessing-contents-of-data-payload-in-NS2-tp28115846p28153305.html
Sent from the ns-users mailing list archive at Nabble.com.



Re: [ns] Help: accessing contents of data payload in NS2

2010-04-04 Thread MiLo_TUD




O S wrote:
 
 
 if((PacketData*)p-userdata()!=NULL) {
 PacketData* packdata = (PacketData*)p-userdata();
 char* pdata = (char*)packdata-data();
 printf(data = %c\n, pdata);
 }
 
 if (p-accessdata()!=NULL){
 data_char = p-accessdata();
 printf(data = %c and p-datalength = %d real length = %d \n,
 data_char, p-datalen(), ((PacketData*)(p-userdata()))-size() );
 }
 
 
 


data_ is a pointer to the class AppData .
1. so it is no good idea to cast to a pointer of char . try to avoid type
casting ! this is not a good programmer's style and resolves in faults.
2. the class AppData is only a interface for different types of payload. so
you have to specify the type of payload and the data. maybe you can use the
class PacketData for your purposes.

regards mike


-- 
View this message in context: 
http://old.nabble.com/Help%3A-accessing-contents-of-data-payload-in-NS2-tp28115846p28132310.html
Sent from the ns-users mailing list archive at Nabble.com.



Re: [ns] Help: accessing contents of data payload in NS2

2010-04-02 Thread yogalakshmi balasubramaniam

Hi,
I'm also want to know how to access the contents of the data
payload. Please help me too..

--
Regards,
yogalakshmi


[ns] Help: accessing contents of data payload in NS2

2010-04-01 Thread O S

Hi,

I am trying to access the contents of the data payload of a packet in NS2
i.e. the actual bits of data. I have something like this:

from packet.h, I can see that it has functions 'accessdata' and 'userdata'
both of which return the data payload one way or another. But when I do
this:


if((PacketData*)p-userdata()!=NULL) {
PacketData* packdata = (PacketData*)p-userdata();
char* pdata = (char*)packdata-data();
printf(data = %c\n, pdata);
}

if (p-accessdata()!=NULL){
data_char = p-accessdata();
printf(data = %c and p-datalength = %d real length = %d \n,
data_char, p-datalen(), ((PacketData*)(p-userdata()))-size() );
}

I get the correct lengths of the packet, but data is empty...prints just
empty space.

Can anyone help me access the contents of the data payload in NS2? I need to
compare the contents of two packets. Any other ideas.

Thanks

PS: in one documentation for NS2, I read something which seems to suggest
that the payload of packets in NS2 does not contain anything because its
only a simulated packet. Any ideas?