ns-allinone-2.35/ns-2.35/emulate/tcptap.cc
void
TCPTapAgent::recvpkt()
{
  if (net_->mode() != O_RDWR && net_->mode() != O_RDONLY) {
    fprintf(stderr,
	    "TCPTapAgent(%s): recvpkt called while in write-only mode!\n",
	    name());
    return;
  }
  
  int cc = net_->recv(pkt_handler, this);
  if (cc <= 0) {
    if (cc < 0) {
      perror("recv");
    }
    return;
  }
  TDEBUG4("%f: TCPTapAgent(%s): recvpkt, cc:%d\n", now(), name(), cc);

  // nothing to do coz pkt_handler would have called processpkt()
  // that would have injected packets into the simulator
}
/*
 * ns scheduler calls TapAgent::dispatch which calls recvpkt.
 * 
 * recvpkt then calls the network (net_) to receive as many packets
 * as there are from the packet capture facility.
 * For every packet received through the callback, it converts to ns
 * FullTcp packet and injects it into the simulator by calling target_->recv
 * 
 */
ns scheduler calls TapAgent::dispatch which calls recvpkt.

recvpkt then calls the network (net_) to receive as many packets
as there are from the packet capture facility.
For every packet received through the callback, it converts to ns
FullTcp packet and injects it into the simulator by calling target_->recv
ns scheduler calls TapAgent :: dispatch which calls recvpkt . recvpkt then calls the network ( net_ ) to receive as many packets as there are from the packet capture facility . For every packet received through the callback it converts to ns FullTcp packet and injects it into the simulator by calling target_ - > recv
void
TCPTapAgent::recvpkt()
{
  if (net_->mode() != O_RDWR && net_->mode() != O_RDONLY) {
    fprintf(stderr,
	    "TCPTapAgent(%s): recvpkt called while in write-only mode!\n",
	    name());
    return;
  }
  int cc = net_->recv(pkt_handler, this);
  if (cc <= 0) {
    if (cc < 0) {
      perror("recv");
    }
    return;
  }
  TDEBUG4("%f: TCPTapAgent(%s): recvpkt, cc:%d\n", now(), name(), cc);
}
void TCPTapAgent :: recvpkt ( ) { if ( net_ -> mode ( ) != O_RDWR && net_ -> mode ( ) != O_RDONLY ) { fprintf ( stderr , " \n " , name ( ) ) ; return ; } int cc = net_ -> recv ( pkt_handler , this ) ; if ( cc <= 0 ) { if ( cc < 0 ) { perror ( " " ) ; } return ; } TDEBUG4 ( " \n " , now ( ) , name ( ) , cc ) ; }
ns scheduler calls TapAgent::dispatch which calls recvpkt.
ns scheduler calls TapAgent :: dispatch which calls recvpkt .
// nothing to do coz pkt_handler would have called processpkt() // that would have injected packets into the simulator