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(); send(pktret,0); } else { Packet::free(pkt); } Packet::free(pkt); return; } -- ---------------------------------------------------------------------------------------------------------------- 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) ------------------------------------------------------------------------------------------------------------------