scoreboard-rq.cc

Go to the documentation of this file.
00001 /* Copyright (c) 2002 Tom Kelly, University of Cambridge
00002  * All rights reserved.
00003  * 
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions
00006  * are met:
00007  * 1. Redistributions of source code must retain the above copyright
00008  *    notice, this list of conditions and the following disclaimer.
00009  * 2. Redistributions in binary form must reproduce the above copyright
00010  *    notice, this list of conditions and the following disclaimer in the
00011  *    documentation and/or other materials provided with the distribution.
00012  * 3. All advertising materials mentioning features or use of this software
00013  *    must display the following acknowledgement:
00014  *  This product includes software developed by the MASH Research
00015  *  Group at the University of California Berkeley.
00016  * 4. Neither the name of the University nor of the Research Group may be
00017  *    used to endorse or promote products derived from this software without
00018  *    specific prior written permission.
00019  * 
00020  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
00021  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00024  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00025  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00026  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00027  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00028  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00029  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00030  * SUCH DAMAGE.
00031  *
00032  */
00033 
00034 #include <stdlib.h>
00035 #include <stdio.h>
00036 #include "scoreboard-rq.h"
00037 
00038 // Implementation of a ScoreBoard shim for 
00039 // the FullTCP reassembly queue code
00040 
00041 int ScoreBoardRQ::IsEmpty(){
00042     printf("ScoreBoardRQ::IsEmpty not implemented\n");
00043     exit(1);
00044 }
00045 
00046 int ScoreBoardRQ::GetNextRetran(){
00047     int seq;
00048     int fcnt;
00049     int fbytes;
00050 
00051     if(h_seqno_ < sack_min) h_seqno_ = sack_min;
00052     seq = h_seqno_;
00053     
00054     if((seq = rq_.nexthole(seq, fcnt, fbytes)) > 0) {
00055         // adjust h_seqno, as we may have
00056         // been "jumped ahead" by learning
00057         // about a filled hole
00058         
00059         if(fcnt <= 0) return (-1); // no holes above
00060 
00061         //printf("%.4f ", Scheduler::instance().clock());
00062         //printf("GetNextRetran sack_min: %i h_seqno: %i seq: %i\n", sack_min, h_seqno_, seq);
00063         if(seq > h_seqno_)
00064             h_seqno_ = seq;
00065 
00066         return (seq);
00067     }
00068     return (-1);
00069 }
00070 
00071 int ScoreBoardRQ::UpdateScoreBoard(int last_ack_, hdr_tcp* tcph){
00072     int old_total = rq_.total();
00073     changed_ = 0;
00074     
00075     if(sack_min <= last_ack_){
00076         // beginning of retransmission queue is one beyond last_ack
00077         sack_min = last_ack_+1; 
00078         if(!rq_.empty()){
00079             rq_.cleartonxt();
00080             changed_ = 1;
00081         }
00082     }
00083 
00084     for(int i = 0 ; i < tcph->sa_length() ; i++){
00085         //printf("l: %i r: %i\n", tcph->sa_left(i), tcph->sa_right(i));
00086         rq_.add(tcph->sa_left(i), tcph->sa_right(i), 0); 
00087     }
00088     changed_ = changed_  || (old_total != rq_.total());
00089     return 0;
00090     
00091     //printf("UpdateScoreBoard dump changed_: %i\n", changed_);
00092     //printf("%.4f ", Scheduler::instance().clock());
00093     //rq_.dumplist();
00094     
00095 }
00096 
00097 
00098 /*
00099  * GetNextUnacked returns sequence number of next unacked pkt,
00100  * starting with seqno.
00101  * Returns -1 if there is no unacked packet in that range.
00102  */
00103 int ScoreBoardRQ::GetNextUnacked (int seqno)
00104 {
00105       int nxtcnt;   // not used
00106       int nxtbytes; // not used
00107       int unacked = rq_.nexthole(seqno, nxtcnt, nxtbytes);
00108       return (unacked);
00109 }
00110 
00111 int ScoreBoardRQ::CheckSndNxt(hdr_tcp* h) {
00112     printf("ScoreBoardRQ::CheckSndNxt not implemented\n");
00113     exit(1);
00114 }
00115 
00116 void ScoreBoardRQ::Dump() {
00117   rq_.dumplist();
00118 }

Generated on Tue Mar 6 16:47:50 2007 for ns2 Network Simulator 2.29 by  doxygen 1.4.6