Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members

tcp-sink.h

Go to the documentation of this file.
00001 /* -*-  Mode:C++; c-basic-offset:8; tab-width:8; indent-tabs-mode:t -*- */
00002 /*
00003  * Copyright (c) 1991-1997 Regents of the University of California.
00004  * All rights reserved.
00005  *
00006  * Redistribution and use in source and binary forms, with or without
00007  * modification, are permitted provided that the following conditions
00008  * are met:
00009  * 1. Redistributions of source code must retain the above copyright
00010  *    notice, this list of conditions and the following disclaimer.
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  * 3. All advertising materials mentioning features or use of this software
00015  *    must display the following acknowledgement:
00016  *      This product includes software developed by the Computer Systems
00017  *      Engineering Group at Lawrence Berkeley Laboratory.
00018  * 4. Neither the name of the University nor of the Laboratory may be used
00019  *    to endorse or promote products derived from this software without
00020  *    specific prior written permission.
00021  *
00022  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
00023  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00024  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00025  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
00026  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00027  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00028  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00029  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00030  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00031  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00032  * SUCH DAMAGE.
00033  *
00034  */
00035  
00036 #ifndef ns_tcpsink_h
00037 #define ns_tcpsink_h
00038 
00039 #include <math.h>
00040 #include "agent.h"
00041 #include "tcp.h"
00042 
00043 /* max window size */
00044 // #define MWS 1024  
00045 #define MWS 64
00046 #define MWM (MWS-1)
00047 #define HS_MWS 65536
00048 #define HS_MWM (MWS-1)
00049 /* For Tahoe TCP, the "window" parameter, representing the receiver's
00050  * advertised window, should be less than MWM.  For Reno TCP, the
00051  * "window" parameter should be less than MWM/2.
00052  */
00053 
00054 class TcpSink;
00055 class Acker {
00056 public:
00057         Acker();
00058         virtual ~Acker() { delete[] seen_; }
00059         void update_ts(int seqno, double ts);
00060         int update(int seqno, int numBytes);
00061         void update_ecn_unacked(int value);
00062         inline int Seqno() const { return (next_ - 1); }
00063         virtual void append_ack(hdr_cmn*, hdr_tcp*, int oldSeqno) const;
00064         void reset();
00065         double ts_to_echo() { return ts_to_echo_;}
00066         int ecn_unacked() { return ecn_unacked_;}
00067         inline int Maxseen() const { return (maxseen_); }
00068         void resize_buffers(int sz);  // resize the seen_ buffer
00069 
00070 protected:
00071         int next_;              /* next packet expected */
00072         int maxseen_;           /* max packet number seen */
00073         int wndmask_;           /* window mask - either MWM or HS_MWM - Sylvia */ 
00074         int ecn_unacked_;       /* ECN forwarded to sender, but not yet
00075                                  * acknowledged. */
00076         int *seen_;             /* array of packets seen */
00077         double ts_to_echo_;     /* timestamp to echo to peer */
00078         int is_dup_;            // A duplicate packet.
00079 };
00080 
00081 // derive Sacker from TclObject to allow for traced variable
00082 class SackStack;
00083 class Sacker : public Acker, public TclObject {
00084 public: 
00085         Sacker() : base_nblocks_(-1), sf_(0) { };
00086         ~Sacker();
00087         void append_ack(hdr_cmn*, hdr_tcp*, int oldSeqno) const;
00088         void reset();
00089         void configure(TcpSink*);
00090 protected:
00091         int base_nblocks_;
00092         int* dsacks_;           // Generate DSACK blocks.
00093         SackStack *sf_;
00094         void trace(TracedVar*);
00095 };
00096 
00097 class TcpSink : public Agent {
00098 public:
00099         TcpSink(Acker*);
00100         void recv(Packet* pkt, Handler*);
00101         void reset();
00102         int command(int argc, const char*const* argv);
00103         TracedInt& maxsackblocks() { return max_sack_blocks_; }
00104 protected:
00105         void ack(Packet*);
00106         virtual void add_to_ack(Packet* pkt);
00107 
00108         virtual void delay_bind_init_all();
00109         virtual int delay_bind_dispatch(const char *varName, const char *localName, TclObject *tracer);
00110 
00111         Acker* acker_;
00112         int ts_echo_bugfix_;
00113 
00114         friend void Sacker::configure(TcpSink*);
00115         TracedInt max_sack_blocks_;     /* used only by sack sinks */
00116         Packet* save_;          /* place to stash saved packet while delaying */
00117                                 /* used by DelAckSink */
00118         int generate_dsacks_;   // used only by sack sinks
00119         int qs_enabled_; // to enable QuickStart 
00120         int RFC2581_immediate_ack_;     // Used to generate ACKs immediately 
00121         int bytes_;     // for JOBS
00122                                         // for RFC2581-compliant gap-filling.
00123         double lastreset_;      /* W.N. used for detecting packets  */
00124                                 /* from previous incarnations */
00125 };
00126 
00127 class DelAckSink;
00128 
00129 class DelayTimer : public TimerHandler {
00130 public:
00131         DelayTimer(DelAckSink *a) : TimerHandler() { a_ = a; }
00132 protected:
00133         virtual void expire(Event *e);
00134         DelAckSink *a_;
00135 };
00136 
00137 class DelAckSink : public TcpSink {
00138 public:
00139         DelAckSink(Acker* acker);
00140         void recv(Packet* pkt, Handler*);
00141         virtual void timeout(int tno);
00142         void reset();
00143 protected:
00144         double interval_;
00145         DelayTimer delay_timer_;
00146 };
00147 
00148 #endif

Generated on Tue Apr 20 12:14:36 2004 for NS2.26SourcesOriginal by doxygen 1.3.3