root/vic/branches/cc/cc/tfwc_rcvr.h

Revision 4859, 3.6 KB (checked in by soohyunc, 4 years ago)

*** finished TFRC/TFWC Retransmission Timer Mechanisms ***

min RTO - 200 ms (most Linux TCP implementation)
max RTO = 60 sec (RFC 2988)

Also, TfwcSndr? and TfrcSndr? can directly call functions defined in Transmitter.
This is specially usefule when TfwcSndr/TfrcSndr? want to call
Transmitter::output() method directly.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Rev URL
Line 
1/*
2 * Copyright (c) 2008-2010 University College London
3 * All rights reserved.
4 *
5 * AUTHOR: Soo-Hyun Choi <s.choi@cs.ucl.ac.uk>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 *    notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 *    notice, this list of conditions and the following disclaimer in the
14 *    documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor of the Laboratory may be used
16 *    to endorse or promote products derived from this software without
17 *    specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id$
32 */
33
34#ifndef vic_tfwc_rcvr_h
35#define vic_tfwc_rcvr_h
36
37#include <vector>
38#include <algorithm>
39#include "tfwc_sndr.h"
40
41class TfwcRcvr {
42public:
43        TfwcRcvr();
44
45        // receive AoA
46        void recv_aoa(u_int16_t type, u_int16_t *chunk);
47        // receive RTP data
48        void recv_seqno(u_int16_t seqno);
49
50        // AckVec clone
51        inline u_int16_t getvec(int i) { return tfwcAV[i]; }
52        // ts echo
53        inline u_int32_t ts_echo() { return ts_echo_; }
54        // AckVec begin seqno
55        inline u_int16_t begins() { return begins_; }
56        // AckVec end seqno plus one
57        inline u_int16_t ends() { return ends_; }
58        // number of AckVec array
59        inline u_int16_t numvec() { return numVec_; }
60
61        // TfwcRcvr instance
62        static inline TfwcRcvr& instance() { return instance_; }
63
64    // Transmitter
65        inline void manager(Transmitter* tm) { tm_ = tm; }
66
67protected:
68
69        static TfwcRcvr instance_;
70        Transmitter *tm_;
71
72        /*
73         * Variables
74         */
75        u_int16_t *tfwcAV;              // AckVec array (bit vector array)
76        u_int16_t ackofack_;    // ackofack
77    u_int16_t begins_;      // begin seqno that XR chunk is reporting
78    u_int16_t ends_;        // end seqno + 1 that XR chunk is reporting
79        int numElm_;                    // number of tfwcAV elements
80        int numVec_;                    // number of tfwcAV chunks
81private:
82        // TFWC sender's AckVec Routine
83        void tfwc_ackvec();
84        void reset();
85
86        // calculate the number of AckVec chunks
87        // (based on the number of given elements, i.e, numelm)
88        inline int getNumVec (int numelm) {
89                int num = numelm/BITLEN + 1;
90                if (numelm%BITLEN == 0) num--;
91                return num;
92        }
93
94        // returning AckOfAck
95        inline u_int16_t ackofack() { return ackofack_; }
96
97        // clear tfwcAV
98        inline void clear_avec(int num) {
99                for (int i = 0; i < num; i++)
100                        tfwcAV[i] = 0;
101        }
102
103        // print built AckVec
104        void print_tfwcAV();
105        void print_vec(std::vector<int> v);
106
107        /*
108         * Variables (private)
109         */
110        u_int32_t ts_echo_;     // for time stamp echoing
111
112        // actual AckVec and its iterator
113        std::vector<int> avec_;
114        std::vector<int>::iterator avit_;
115        // reference vector and its iterator
116        std::vector<int> rvec_;
117        std::vector<int>::iterator rvit_;
118
119        // out-of-order packet reception
120        u_int16_t __ackofack_;  // previous ackofack
121};
122
123#endif
Note: See TracBrowser for help on using the browser.