scoreboard-rh.h
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:4k
源码类别:

通讯编程

开发平台:

Visual C++

  1. /* -*- Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
  2. /*
  3.  * Copyright (c) @ Regents of the University of California.
  4.  * All rights reserved.
  5.  * 
  6.  * Redistribution and use in source and binary forms, with or without
  7.  * modification, are permitted provided that the following conditions
  8.  * are met:
  9.  * 1. Redistributions of source code must retain the above copyright
  10.  *    notice, this list of conditions and the following disclaimer.
  11.  * 2. Redistributions in binary form must reproduce the above copyright
  12.  *    notice, this list of conditions and the following disclaimer in the
  13.  *    documentation and/or other materials provided with the distribution.
  14.  * 3. All advertising materials mentioning features or use of this software
  15.  *    must display the following acknowledgement:
  16.  *  This product includes software developed by the MASH Research
  17.  *  Group at the University of California Berkeley.
  18.  * 4. Neither the name of the University nor of the Research Group may be
  19.  *    used to endorse or promote products derived from this software without
  20.  *    specific prior written permission.
  21.  * 
  22.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  23.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  25.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  26.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  28.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  29.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  31.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  32.  * SUCH DAMAGE.
  33.  *
  34.  * @(#) $Header: /cvsroot/nsnam/ns-2/tcp/scoreboard-rh.h,v 1.2 2000/08/12 21:46:10 sfloyd Exp $
  35.  */
  36. #ifndef ns_scoreboard_h
  37. #define ns_scoreboard_h
  38. //  Definition of the scoreboard class:
  39. #define SBSIZE 1024
  40. #include "tcp.h"
  41. class ScoreBoardRH {
  42.   public:
  43.         ScoreBoardRH(int *numdupacks) : numdupacks_(numdupacks) {first_=0; length_=0; retran_occured_=0;}
  44. int IsEmpty () {return (length_ == 0);}
  45. void ClearScoreBoard (); 
  46. int GetNextRetran ();
  47. void MarkRetran (int retran_seqno, int snd_nxt, int rh_id);
  48. int UpdateScoreBoard (int last_ack_, hdr_tcp*, int rh_id);
  49. int CheckSndNxt (int sack_max);
  50. int GetFack (int last_ack);
  51. int GetNewHoles ();
  52. void TimeoutScoreBoard (int snd_nxt);
  53. int FakeSack (int last_ack, int num_dupacks);
  54. int RetranSacked (int rh_id);
  55. int RetranOccurred (int rh_id) {return (retran_occured_ == rh_id);}
  56.   protected:
  57. int first_, length_;
  58. int retran_occured_;             /* This variable stores the last adjustment interval
  59.     in which a retransmission occured  */
  60. int retran_sacked_;              /* This variable stores the last adjustment interval
  61.     in which a retransmission was sacked  */
  62.         int *numdupacks_;  /* I know, it stinks...  But this is numdupacks_ from
  63.   * our parent TCP stack. */
  64.    
  65. struct ScoreBoardNode {
  66. int seq_no_; /* Packet number */
  67. int ack_flag_; /* Acked by cumulative ACK */
  68. int sack_flag_; /* Acked by SACK block */
  69. int retran_; /* Packet retransmitted */
  70. int snd_nxt_; /* snd_nxt at time of retransmission */
  71. int sack_cnt_; /* number of reports for this hole */
  72. int rh_id_;             /* The id of the rate-halving adjustment interval */
  73. } SBN[SBSIZE+1];
  74. };
  75. #endif