12.07.2015 Views

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

The ns Manual (formerly ns Notes and Documentation)1 - NM Lab at ...

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

hdr_flags* nf = (hdr_flags*)npkt->access(off_flags_);nf->ecn_ = of->ecn_;}acker_->append_ack((hdr_cmn*)npkt->access(off_cmn_),ntcp, otcp->seqno());send(npkt, 0);<strong>The</strong> recv() method overrides the Agent::recv() method (which merely discards the received packet). It upd<strong>at</strong>es someinternal st<strong>at</strong>e with the sequence number of the received packet (<strong>and</strong> therefore requires the off_tcp_ variable to be properlyinitialized. It then gener<strong>at</strong>es an acknowledgment for the received packet. <strong>The</strong> ack() method makes liberal use of access topacket header fields including separ<strong>at</strong>e accesses to the TCP header, IP header, Flags header, <strong>and</strong> common header. <strong>The</strong> call tosend() invokes the Connector::send() method.10.5.4 Processing Respo<strong>ns</strong>es <strong>at</strong> the SenderOnce the simple TCP’s peer receives d<strong>at</strong>a <strong>and</strong> gener<strong>at</strong>es an ACK, the sender must (usually) process the ACK. In theTcpAgent agent, this is done as follows:/** main reception p<strong>at</strong>h - should only see acks, otherwise the* network connectio<strong>ns</strong> are misconfigured*/void TcpAgent::recv(Packet *pkt, H<strong>and</strong>ler*){hdr_tcp *tcph = (hdr_tcp*)pkt->access(off_tcp_);hdr_ip* iph = (hdr_ip*)pkt->access(off_ip_);...if (((hdr_flags*)pkt->access(off_flags_))->ecn_)quench(1);if (tcph->seqno() > last_ack_) {newack(pkt);opencwnd();} else if (tcph->seqno() == last_ack_) {if (++dupacks_ == NUMDUPACKS) {...}}Packet::free(pkt);send(0, 0, maxburst_);}This routine is invoked when an ACK arrives <strong>at</strong> the sender. In this case, once the inform<strong>at</strong>ion in the ACK is processed (bynewack) the packet is no longer needed <strong>and</strong> is returned to the packet memory alloc<strong>at</strong>or. In addition, the receipt of the ACKindic<strong>at</strong>es the possibility of sending additional d<strong>at</strong>a, so the TcpSimpleAgent::send() method is invoked which <strong>at</strong>temptsto send more d<strong>at</strong>a if the TCP window allows.102

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!