[ns] recv() is not called

raja priya s_rajapriya85 at yahoo.co.in
Fri Apr 7 04:55:30 PDT 2006


Dear all,
   
  I tried creating a new agent which broadcasts the no of neighbors and then do som eprocessing. I just checked out by setting no of neighbors as 10. My code compiled and when i run i get the packetname as undefined. The problem is my recv function in cc is not at all called. I used some printf statement but the control is not passed to recv.
   
  Part of my cc file is
   
  void AntAgent::recv(Packet* pkt, Handler*)
  { 
  hdr_broad* hdrb = HDR_BROAD(pkt);
  char out[100];
  printf("In the receive function of ant.cc");
  sprintf(out, "%s no of neighbors is %d",name(),hdrb->no_of_neigh);
  fprintf (stdout,"[%s]" ,out);
  Tcl& tcl = Tcl::instance();
  tcl.eval(out);
  Packet::free(pkt);
  
  }
  void AntAgent::broadcast_neigh()
  {
  Packet* pkt = allocpkt();
  hdr_broad* hdrb = HDR_BROAD(pkt);
  printf("In the broadcast_neigh function");
  hdrb->no_of_neigh = 10; 
  send(pkt, 0);
  }
   
  In the shell it is printing 'In the broadcast_neigh function' but the statements i have given in recv is not getting printed which means it is not called.
   
  What might be the problem???? I need the problem to be fixed. I am not much experienced in NS. Please help me please...
   
  S.Rajapriya

			
---------------------------------
Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.


More information about the Ns-users mailing list