tcp-session.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) 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 Daedalus Research
00017  *  Group at the University of California Berkeley.
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  * Contributed by the Daedalus Research Group, http://daedalus.cs.berkeley.edu
00035  *
00036  * @(#) $Header: /nfs/jade/vint/CVSROOT/ns-2/tcp/tcp-session.h,v 1.8 1999/09/09 03:25:26 salehi Exp $ (UCB)
00037  */
00038 
00039 #ifndef nc_tcp_session_h
00040 #define ns_tcp_session_h
00041 
00042 #include "agent.h"
00043 #include "timer-handler.h"
00044 #include "chost.h"
00045 
00046 #define FINE_ROUND_ROBIN 1
00047 #define COARSE_ROUND_ROBIN 2
00048 #define RANDOM 3
00049 
00050 class TcpSessionAgent;
00051 
00052 class SessionRtxTimer : public TimerHandler {
00053 public: 
00054     SessionRtxTimer(TcpSessionAgent *a) : TimerHandler() { a_ = a; }
00055 protected:
00056     virtual void expire(Event *e);
00057     TcpSessionAgent *a_;
00058 };
00059 
00060 class SessionResetTimer : public TimerHandler {
00061 public: 
00062     SessionResetTimer(TcpSessionAgent *a) : TimerHandler() { a_ = a; }
00063 protected:
00064     virtual void expire(Event *e);
00065     TcpSessionAgent *a_;
00066 };
00067 
00068 class SessionBurstSndTimer : public TimerHandler {
00069 public: 
00070     SessionBurstSndTimer(TcpSessionAgent *a) : TimerHandler() { a_ = a; }
00071 protected:
00072     virtual void expire(Event *e);
00073     TcpSessionAgent *a_;
00074 };
00075 
00076 /*
00077  * This class implements the notion of a TCP session. It integrates congestion 
00078  * control and loss detection functionality across the one or more IntTcp 
00079  * connections that comprise the session.
00080  */
00081 class TcpSessionAgent : public CorresHost {
00082 public:
00083     TcpSessionAgent();
00084     int command(int argc, const char*const* argv);
00085     void reset_rtx_timer(int mild, int backoff = 1); /* XXX mild needed ? */
00086     void set_rtx_timer();
00087     void cancel_rtx_timer();
00088     void cancel_timers();
00089     void newack(Packet *pkt);
00090     int fs_pkt();
00091     void rtt_update_exact(double tao);
00092     void timeout(int tno);
00093     virtual Segment* add_pkts(int size, int seqno, int sessionSeqno, int daddr, 
00094             int dport, int sport, double ts, IntTcpAgent *sender); 
00095     virtual void add_agent(IntTcpAgent *agent, int size, double winMult,
00096             int winInc, int ssthresh);
00097     int window();
00098     void set_weight(IntTcpAgent *tcp, int wt);
00099     void reset_dyn_weights();
00100     IntTcpAgent *who_to_snd(int how);
00101     void send_much(IntTcpAgent *agent, int force, int reason); 
00102     void recv(IntTcpAgent *agent, Packet *pkt, int amt_data_acked);
00103     void setflags(Packet *pkt);
00104     int findSessionSeqno(IntTcpAgent *sender, int seqno);
00105     void removeSessionSeqno(int sessionSeqno);
00106     void quench(int how, IntTcpAgent *sender, int seqno);
00107     virtual void traceVar(TracedVar* v);
00108 
00109 //  inline nsaddr_t& addr() {return addr_;}
00110 //  inline nsaddr_t& dst() {return dst_;}
00111     static Islist<TcpSessionAgent> sessionList_;
00112 
00113 protected:
00114     SessionRtxTimer rtx_timer_;
00115     SessionBurstSndTimer burstsnd_timer_;
00116     int sessionSeqno_;
00117     double last_send_time_;
00118     Segment *last_seg_sent_;
00119     IntTcpAgent *curConn_;
00120     int numConsecSegs_;
00121     int schedDisp_;
00122     int wtSum_;
00123     int dynWtSum_;
00124 };
00125 
00126 #endif

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