next up previous contents index
Next: 9.5.5 Implementing Timers Up: 9.5 Examples: Tcp, TCP Previous: 9.5.3 Processing Input at

   
9.5.4 Processing Responses at the Sender

Once the simple TCP's peer receives data and generates an ACK, the sender must (usually) process the ACK. In the TcpAgent agent, this is done as follows:

        /*
         * main reception path - should only see acks, otherwise the
         * network connections are misconfigured
         */
        void TcpAgent::recv(Packet *pkt, Handler*)
        {
                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) {
                                \ldots
                        }
                }
                Packet::free(pkt);
                send(0, 0, maxburst_);
       }
This routine is invoked when an ACK arrives at the sender. In this case, once the information in the ACK is processed (by newack) the packet is no longer needed and is returned to the packet memory allocator. In addition, the receipt of the ACK indicates the possibility of sending additional data, so the []TcpSimpleAgent::send method is invoked which attempts to send more data if the TCP window allows.




2000-08-24