am.h

00001 /*
00002  * Copyright (c) 2003 Ericsson Telecommunicatie B.V.
00003  * All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions
00007  * are met:
00008  * 1. Redistributions of source code must retain the above copyright
00009  *     notice, this list of conditions and the following disclaimer.
00010  * 2. Redistributions in binary form must reproduce the above copyright
00011  *     notice, this list of conditions and the following disclaimer in the
00012  *     documentation and/or other materials provided with the
00013  *     distribution.
00014  * 3. Neither the name of Ericsson Telecommunicatie B.V. may be used
00015  *     to endorse or promote products derived from this software without
00016  *     specific prior written permission.
00017  * 
00018  * 
00019  * THIS SOFTWARE IS PROVIDED BY ERICSSON TELECOMMUNICATIE B.V. AND
00020  * CONTRIBUTORS "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES,
00021  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00022  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00023  * IN NO EVENT SHALL ERICSSON TELECOMMUNICATIE B.V., THE AUTHOR OR HIS
00024  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00025  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00026  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00028  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00029  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00030  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031  * 
00032  * 
00033  * Contact for feedback on EURANE: eurane@ti-wmc.nl
00034  * EURANE = Enhanced UMTS Radio Access Network Extensions
00035  * website: http://www.ti-wmc.nl/eurane/
00036  */
00037 
00038 /*
00039  * $Id: am.h,v 1.14 2004/01/21 15:55:12 wtdavid Exp $
00040  */
00041 
00042 
00043 #ifndef ns_am_h
00044 #define ns_am_h
00045 
00046 #include <rlc.h>
00047 #include <um.h>
00048 #include <umts-timers.h>
00049 #include <umts-queue.h>
00050 #include <umts-packet.h>
00051 #include <umts-headers.h>
00052 
00053 // max window size 
00054 #define MWS 4096             
00055 
00056 // The "win_" parameter, representing the RLC window,
00057 // should be less than equal to MWM.
00058 #define MWM (MWS-1)          
00059 
00060 #define BITMAP_LENGTH (MAX_BITMAP_OCTETS*8)
00061 
00062 
00063 #define SEND_STATUS_NONE     0x0000
00064 #define SEND_STATUS_BITMAP   0x0001
00065 #define SEND_STATUS_MRW      0x0002
00066 #define SEND_STATUS_MRWACK   0x0004
00067 
00068 class AM;
00069 
00070 class AM:   public RLC {
00071 
00072 public:
00073    AM();
00074    int         buff_size();
00075    void        timeout(int tno, int flowID = -1);
00076    void        CSwitch(double, double);
00077    int        &addr() {
00078       return (address_);
00079    } int      &daddr() {
00080       return (d_address_);
00081    }
00082    virtual void recv(Packet *, Handler *);
00083    int         getTotPDUs()  {return tot_PDUs_; }
00084    int         getErrPDUs()  {return err_PDUs_; }
00085    int         getAckPDUs()  {return ack_PDUs_; }
00086    int         getAckSDUs()  {return ack_SDUs_; }
00087    int         getDropPDUs() {return drop_PDUs_;}
00088    int         getDropSDUs() {return drop_SDUs_;}
00089 
00090  protected:
00091    int         bRxtSeq(int);
00092    void        ack(Packet *);
00093    Packet*     make_status(Packet *);
00094    Packet     *make_bitmap_SUFI(Packet *);
00095    Packet     *make_mrw_SUFI(Packet *);
00096    Packet     *make_mrwack_SUFI(Packet *);
00097    Packet     *make_positive_ack(Packet *);
00098    void        newack(Packet *);
00099    void        makeSDU(int);
00100    void        send_much(int);
00101    void        newback(Packet *);
00102    Packet     *allocpkt(int);
00103    void        sendDown(Packet *);
00104    int         update(int, int);
00105    int         command(int, const char *const *);
00106 
00107    bool        chk_size(Packet *);
00108    Packet     *makePDU(int);
00109    int         PB_S_PDU();
00110    int         PB_PA_PDU();
00111    bool        PA_Piggybackable(Packet *);
00112    int         AckPDUSize();
00113    bool        S_Piggybackable(Packet *);
00114    int         StatusPDUSize();
00115    int         SUFI_bitmap_size();
00116    int         SUFI_mrw_size();
00117    double      send_time(int);
00118 
00119    void        set_rtx_timer();
00120    void        set_poll_timer();
00121    void        reset_rtx_timer();
00122    void        cancel_rtx_timer();
00123    void        cancel_poll_timer();
00124    void        set_status_prohibit_timer();
00125    virtual  void        ackSDU(int oldFSN, int newFSN);
00126    void        discardSDU(int dsn);
00127 
00128    int         win_;            // RLC window size VT(WS)
00129    double      maxRBSize_;      // max length of the receive buffer 
00130    int         ack_mode_;       // ack option. Selective repeat (==1) or Bitmap (==2)
00131    int         poll_PDU_;       // number of PDUs before a bitmap poll should be sent
00132    double      overhead_;       // Time that is needed to contruct SDUs
00133    double      rtx_timeout_;
00134    double      poll_timeout_;   // rtt value to be used for timeout to recv status PDU
00135    double      stprob_timeout_; // value for the status prohibit timer
00136    int         noFastRetrans_;  // No Fast Retransmit option
00137    int         numdupacks_;     // dup ACKs before fast retransmit
00138 
00139    int         payload_;        // user data per DATA PDU
00140    double      bandwidth_;
00141    double      TTI_;
00142    double      next_TTI_;
00143 
00144    int         ack_pdu_header_;
00145    int         status_pdu_header_;
00146    int         length_indicator_;
00147    int         min_concat_data_;
00148    double      max_status_delay_;
00149    double      max_ack_delay_;
00150 
00151    int         sent_TTI_PDUs_;
00152    int         TTI_PDUs_;
00153    double      earliest_status_send_;
00154    double      earliest_ack_send_;
00155    int         set_poll_;
00156    int         send_ack_;       // indicates if a positive ack is to be transmitted
00157    int         send_status_;    // indicates if a status PDU is to be transmitted;
00158                                 // which SUFIs are to be included is indicated 
00159                                 // by bitwise-OR of SEND_STATUS_* values
00160    int         SDU_size_;       // stores the original size of the SDU when a part already
00161                                 // was concatenated
00162 
00163 
00164    int         dupacks_;        // number of (pos) duplicate acks
00165    int         rtt_seq_;
00166 
00167 /*    int         poll_seq_;       // stores the highest sequence number of a packet including */
00168 /*                                 // a poll bit */
00169 
00170    int         rtt_active_;
00171    int         prohibited_;
00172 
00173    int         FSN_;            // First Sequence Number of the window
00174                                 // of the transmitter, a.k.a. VT(A)
00175 
00176    int         MRW_delta;       // the difference between the sender
00177                                 // window and the receiver window. It
00178                                 // is set when sender window is moved and reset
00179                                 // when a MRW_ACK is received. Used to
00180                                 // limit the window size of the sender
00181                                 // until the receiver has moved the window.
00182 
00183    int         b_bal_;          // number of 0s in bitmap (number of nacks in bitmap)
00184    int         length_;         // length of bitmap
00185    int         bitmap_[BITMAP_LENGTH];
00186 
00187    /* NOTE: for bitmap acknowledgement t_seqno_ and maxseq_ are
00188       redundant since they are always offset by 1 */
00189    int         maxseq_;         // highest seqno transmitted so far,
00190                                 // a.k.a. VT(S) - 1
00191    int         t_seqno_;        // Seqno of next PDU to be
00192                                 // transmitted, a.k.a VT(S)
00193 
00194    int         highest_ack_;    // highest ack received by sender,
00195 
00196    int         maxseen_;        // max PDU (seqno)number seen by
00197                                 // receiver
00198                                 // a.k.a. VR(H) - 1
00199    int        seen_[MWS];      
00200 
00201 
00202 
00203 
00204 
00205    int         next_;           // next PDU expected by receiver
00206                                 // a.k.a. VR(R) 
00207    int         eopno_[MWS];     // if PDU n is end-of-SDU 
00208                                 // then eopno_[n] == n 
00209                                 // else eopno_[n] == -1
00210   
00211    u_int8_t    txcount_[MWS];    // TX counter for each AMD PDU (
00212                                  // a.k.a. VT(DAT) )
00213    int         maxdat_;         // Maximum number of transmission
00214                                 // attempts for each AMD PDU
00215 
00216    int         tx_PDUs_before_poll;       
00217 
00218 
00219    
00220 
00221    int         tot_PDUs_;      
00222    int         err_PDUs_;      
00223 
00224 
00225 
00226 
00227 
00228 
00229 
00230    int         ack_PDUs_;      
00231    int         ack_SDUs_;      
00232    int         drop_PDUs_;     
00233    int         drop_SDUs_;     
00234    int         rx_PDUs_;        
00235    int         rx_SDUs_;
00236 
00237 
00238    int         address_;        // address of this RLC Entity
00239    int         d_address_;      // destination address of this RLC Entity
00240 
00241    double      TTI_time_;
00242 
00243    UmtsTimer   rtx_timer_;
00244    UmtsTimer   poll_timer_;
00245    UmtsTimer   delsnd_timer_;
00246    UmtsTimer   stprob_timer_;
00247    UmtsTimer   tti_timer_;
00248    UmtsTimer   mrwack_timer_;
00249 
00250    umtsQueue   rcvB_;
00251    umtsQueue   rxtB_;
00252    umtsQueue   sduB_;
00253 
00254    int         flowID_;         // The flow-id of the incoming
00255                                 // packets, is used to set the 
00256                                 // flow-id of outgoing packets.
00257 
00258 
00259    int sender_debug_;           
00260    int receiver_debug_;
00261    
00262 
00263 };
00264 
00265 #endif

Generated on Wed Nov 26 15:47:29 2008 for NS-MIRACLE library by  doxygen 1.5.2