Anuradha wrote:
> First of all thanks to Mr. Timo, for his help regarding sendmsg().

It's either Timo or Mr. Reimann. I prefer the former. :)

> As I wanted to see the data that i set in the tcl file, I edited the
> ../tcl/ex/udpdata.tcl like
> $ns at 0.1 "$udp0 send 724 Hello1"
> $ns at 0.2 "$udp1 send 100 Hello2"
> $ns at 0.3 "$udp0 send 500 Hello3"
> $ns at 0.4 "$udp1 send 828 Hello4"
> It calls the following function in, where i added the printf
> statement
> int UdpAgent::command(int argc, const char*const* argv)
> {
>       if (argc == 4) {
>               if (strcmp(argv[1], "send") == 0) {
>                       printf("\n \n%d==>%s",atoi(argv[2]),argv[3]);
>                       PacketData* data = new PacketData(1 + strlen(argv[3]));
>                       strcpy((char*)data->data(), argv[3]);
>                       sendmsg(atoi(argv[2]), data);
>                       return (TCL_OK);
>               }

Please notice that data is a pointer to PacketData and see below.

> Its displaying the contents of data, as expected. But after this, when i
> add
> printf statement in "void UdpAgent::sendmsg(int nbytes, AppData* data,
> const
> char* flags)" ,like given below
> if (flags && (0 ==strcmp(flags, "NEW_BURST")))
>                       rh->flags() |= RTP_M;
>               p->setdata(data);
>               printf("after setdata(): %s :",p->userdata());

You're missing one type cast and another function call here. Keep in mind
that p is of type Packet, that is, it includes a bunch of information used
to manage packages in general. One of its member functions is userdata()
which returns an AppData pointer. AppData is PacketData's base class which
was used in UdpAgent's sendmsg() function above. (check

This means that p->userdata() just yields an AppData object, not the
C-string data you're hoping for. For that, use


instead. data() is one of PacketData's member functions, of course, and
finally returns the actual data.

> and at receiver end, i did the same, like

[similar case]


--Timo a.k.a. Mr. Reimann

Reply via email to