Thanks for the response Christos!!

I tried the while solution with no success. Is there any way to wait, for
instance, 100ms, before the command send(pktret,0) is executed ? I guess
it's a simple issue, but until now I was not able to solve.

Does anyone can suggest something to do ?

Thanks all!!


2012/10/3 Christos Spatiotis <spati...@ceid.upatras.gr>

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello , Rafael
>
> If you try to put send(pktret,0) in a "while" which run for a random
> time. I guess i do not know.
> Please let me know if you make it.
>
> On 10/03/2012 05:37 PM, Rafael P B Mota wrote:
> >
> > Hello,
> >
> > I am trying to use a random delay (in receiver) before the packet
> > is sent back to the sender agent. For example:
> >
> > 1) the receiver agent receive the sender packet 2) the receiver
> > sets up a response packet 3) Wait for a random time (in ms) 4)
> > sends the packet.
> >
> > I don't know how to do the step 3.
> >
> > I am pasting the code bellow: Somebody can help me ?
> >
> > void MyAgent::recv(Packet* pkt, Handler*) { hdr_ip* hdrip =
> > hdr_ip::access(pkt); hdr_rfidPacket* hdr =
> > hdr_rfidPacket::access(pkt); if (hdr->tipo_==1) { Packet* pktret =
> > allocpkt(); hdr_rfidPacket* hdrTag =
> > hdr_rfidPacket::access(pktret); hdr_ip* hdrIp =
> > hdr_ip::access(pktret); hdrTag->tagEPC_ = tagEPC_; hdrTag->id_ =
> > hdr->id_; hdrTag->tipo_ = 0; hdrIp->daddr() = IP_BROADCAST;
> > hdrIp->dport() = hdrip->sport(); *//HOWTO WAIT A RANDOM TIME (in
> > miliseconds) before send back the packet ??* send(pktret,0); } else
> > { Packet::free(pkt); } Packet::free(pkt); return; }
> >
>
>
> - --
> =======================================================
> Undergraduate student Spatiotis Christos
> Department of Computer Engineering & Informatics (CEID)
> University of Patras, Greece
> e-mail: spati...@ceid.upatras.gr
> website: http://spatiotis.wordpress.com
> ========================================================
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.12 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://www.enigmail.net/
>
> iQEcBAEBAgAGBQJQbE/YAAoJEC9xXqfymW+O/uQIAIxGwtzvq/DuK9v/A2pkqm0g
> sAvwTQeoyA+w2psIVdAObud+mhuYh1GMTIBHlTEmCOt/8nSCUVnswqQlbONAOx7Y
> HecsOmhcTeDbRh1ncXqNc3iw4DKtGwS2RaiFYolfjV6pXSKz/EM0YDR29p4uZv5K
> eRAEW5TIGTTy3dYWzUf2+dexz9AiA5+UHBpP+AT9EgoTCv2u2DTyiUt3ysDl4zTd
> HgKKwZ8iBNXO0H35Eqf2ri6R6adYVtERKpSNk5fW5fxMkQuqR18szzEYcNPrfgbQ
> MjaQQmBHy7iFFbC/Hu2nVPPmL3d6o8Qn66IvX/Ap6Yy6Kwa/a/PRZOyoFV5q2U8=
> =riL2
> -----END PGP SIGNATURE-----
>



-- 
----------------------------------------------------------------------------------------------------------------
Rafael Perazzo B Mota
r <pera...@ime.usp.br>afaelpera...@gmail.com
Web-page: https://sites.google.com/site/rafaelperazzo/
Doutorando em Ciência da Computação
Universidade de São Paulo (USP)
Campus da Capital
Instituto de Matemática e estatística (IME)
------------------------------------------------------------------------------------------------------------------

Reply via email to