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

EmpFtpTrafPool Class Reference

#include <empftp.h>

Inheritance diagram for EmpFtpTrafPool:

Inheritance graph
[legend]
Collaboration diagram for EmpFtpTrafPool:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 EmpFtpTrafPool ()
virtual ~EmpFtpTrafPool ()
void doneSession (int idx)
TcpAgentpicktcp (int size)
TcpSinkpicksink ()
int nTcp ()
int nSink ()
int isdebug ()
virtual void delay_bind_init_all ()
virtual int delay_bind_dispatch (const char *, const char *, TclObject *)
int num_pages () const
int num_pages () const

Public Attributes

int nSrcL_
int nClientL_
int nSrc_
Node ** server_

Protected Member Functions

virtual int command (int argc, const char *const *argv)
 LIST_HEAD (AgentList, AgentListElem)
void insertAgent (AgentList *l, Agent *a)
AgentdetachHead (AgentList *l)
int lookup_rv (EmpiricalRandomVariable *&rv, const char *name)
TclObjectlookup_obj (const char *name)
TclObjectlookup_obj (const char *name)

Protected Attributes

int nSession_
EmpFtpTrafSession ** session_
int nClient_
Node ** client_
int nTcp_
int nSink_
AgentList tcpPool_
AgentList sinkPool_
int debug_
int num_pages_
double start_time_
double end_time_
int duration_

Constructor & Destructor Documentation

EmpFtpTrafPool::EmpFtpTrafPool  ) 
 

Definition at line 167 of file empftp.cc.

References LIST_INIT, sinkPool_, and tcpPool_.

00167                                : 
00168         nSrc_(0), server_(NULL), session_(NULL), nClient_(0), client_(NULL),
00169         nTcp_(0), nSink_(0)
00170 {
00171         LIST_INIT(&tcpPool_);
00172         LIST_INIT(&sinkPool_);
00173 }

EmpFtpTrafPool::~EmpFtpTrafPool  )  [virtual]
 

Definition at line 139 of file empftp.cc.

References client_, nSession_, server_, and session_.

00140 {
00141         if (session_ != NULL) {
00142                 for (int i = 0; i < nSession_; i++)
00143                         delete session_[i];
00144                 delete []session_;
00145         }
00146         if (server_ != NULL)
00147                 delete []server_;
00148         if (client_ != NULL)
00149                 delete []client_;
00150         // XXX Destroy tcpPool_ and sinkPool_ ?
00151 }


Member Function Documentation

int EmpFtpTrafPool::command int  argc,
const char *const *  argv
[protected, virtual]
 

Reimplemented from PagePool.

Definition at line 208 of file empftp.cc.

References client_, EmpFtpTrafSession::clientWin(), PagePool::command(), EmpFtpTrafSession::fileSize(), insertAgent(), EmpFtpTrafSession::interFile(), PagePool::lookup_obj(), lookup_rv(), lt, nClient_, nClientL_, nSession_, nSink_, nSrc_, nSrcL_, nTcp_, TimerHandler::sched(), server_, EmpFtpTrafSession::serverSel(), EmpFtpTrafSession::serverWin(), session_, EmpFtpTrafSession::setClient(), EmpFtpTrafSession::setServer(), sinkPool_, tcpPool_, Random::uniform(), and EmpiricalRandomVariable::value().

00209 {
00210         if (argc == 3) {
00211                 if (strcmp(argv[1], "set-num-session") == 0) {
00212                         if (session_ != NULL) {
00213                                 for (int i = 0; i < nSession_; i++) 
00214                                         delete session_[i];
00215                                 delete []session_;
00216                         }
00217                         nSession_ = atoi(argv[2]);
00218                         session_ = new EmpFtpTrafSession*[nSession_];
00219                         memset(session_, 0, sizeof(EmpFtpTrafSession*)*nSession_);
00220                         return (TCL_OK);
00221                 } else if (strcmp(argv[1], "set-num-server-lan") == 0) {
00222                         nSrcL_ = atoi(argv[2]);
00223                         if (nSrcL_ >  nSrc_) {
00224                                 fprintf(stderr, "Wrong server index %d\n", nSrcL_);
00225                                 return TCL_ERROR;
00226                         }
00227                         return (TCL_OK);
00228                 } else if (strcmp(argv[1], "set-num-remote-client") == 0) {
00229                         nClientL_ = atoi(argv[2]);
00230                         if (nClientL_ > nClient_) {
00231                                 fprintf(stderr, "Wrong client index %d\n", nClientL_);
00232                                 return TCL_ERROR;
00233                         }
00234                         return (TCL_OK);
00235                 } else if (strcmp(argv[1], "set-num-server") == 0) {
00236                         nSrc_ = atoi(argv[2]);
00237                         if (server_ != NULL) 
00238                                 delete []server_;
00239                         server_ = new Node*[nSrc_];
00240                         return (TCL_OK);
00241                 } else if (strcmp(argv[1], "set-num-client") == 0) {
00242                         nClient_ = atoi(argv[2]);
00243                         if (client_ != NULL) 
00244                                 delete []client_;
00245                         client_ = new Node*[nClient_];
00246                         return (TCL_OK);
00247                 }
00248         } else if (argc == 4) {
00249                 if (strcmp(argv[1], "set-server") == 0) {
00250                         Node* cli = (Node*)lookup_obj(argv[3]);
00251                         if (cli == NULL)
00252                                 return (TCL_ERROR);
00253                         int nc = atoi(argv[2]);
00254                         if (nc >= nSrc_) {
00255                                 fprintf(stderr, "Wrong server index %d\n", nc);
00256                                 return TCL_ERROR;
00257                         }
00258                         server_[nc] = cli;
00259                         return (TCL_OK);
00260                 } else if (strcmp(argv[1], "set-client") == 0) {
00261                         Node* s = (Node*)lookup_obj(argv[3]);
00262                         if (s == NULL)
00263                                 return (TCL_ERROR);
00264                         int n = atoi(argv[2]);
00265                         if (n >= nClient_) {
00266                                 fprintf(stderr, "Wrong client index %d\n", n);
00267                                 return TCL_ERROR;
00268                         }
00269                         client_[n] = s;
00270                         return (TCL_OK);
00271                 } else if (strcmp(argv[1], "recycle") == 0) {
00272                         // <obj> recycle <tcp> <sink>
00273                         //
00274                         // Recycle a TCP source/sink pair
00275                         Agent* tcp = (Agent*)lookup_obj(argv[2]);
00276                         Agent* snk = (Agent*)lookup_obj(argv[3]);
00277                         nTcp_++, nSink_++;
00278                         if ((tcp == NULL) || (snk == NULL))
00279                                 return (TCL_ERROR);
00280                         // XXX TBA: recycle tcp agents
00281                         insertAgent(&tcpPool_, tcp);
00282                         insertAgent(&sinkPool_, snk);
00283                         return (TCL_OK);
00284                 }
00285         } else if (argc == 11) {
00286                 if (strcmp(argv[1], "create-session") == 0) {
00287                         // <obj> create-session <session_index>
00288                         //   <files_per_sess> <launch_time>
00289                         //   <inter_file_rv> <file_size_rv>
00290                         //   <server_sel_rv>
00291                         //   <inbound/outbound flag>
00292                         int n = atoi(argv[2]);
00293                         if ((n < 0)||(n >= nSession_)||(session_[n] != NULL)) {
00294                                 fprintf(stderr,"Invalid session index %d\n",n);
00295                                 return (TCL_ERROR);
00296                         }
00297                         int nfile = (int)strtod(argv[3], NULL);
00298                         double lt = strtod(argv[4], NULL);
00299 
00300                         int flip = atoi(argv[10]);
00301                         if ((flip < 0)||(flip > 1)) {
00302                                 fprintf(stderr,"Invalid I/O flag %d\n",flip);
00303                                 return (TCL_ERROR);
00304                         }
00305 
00306 
00307                         EmpFtpTrafSession* p = 
00308                                 new EmpFtpTrafSession(this, nfile, n);
00309 
00310                         int res = lookup_rv(p->interFile(), argv[5]);
00311                         res = (res == TCL_OK) ? 
00312                                 lookup_rv(p->fileSize(), argv[6]) : TCL_ERROR;
00313                         res = (res == TCL_OK) ?
00314                                 lookup_rv(p->serverSel(), argv[7]) : TCL_ERROR;
00315                         res = (res == TCL_OK) ?
00316                                 lookup_rv(p->serverWin(), argv[8]) : TCL_ERROR;
00317                         res = (res == TCL_OK) ?
00318                                 lookup_rv(p->clientWin(), argv[9]) : TCL_ERROR;
00319                         if (res == TCL_ERROR) {
00320                                 delete p;
00321                                 fprintf(stderr, "Invalid random variable\n");
00322                                 return (TCL_ERROR);
00323                         }
00324 
00325                         int cl, svr;
00326                         if (flip == 1) {
00327                                 cl = int(floor(Random::uniform(0, nClientL_)));
00328                                 svr=0;
00329                         } else {
00330                                 cl = int(floor(Random::uniform(nClientL_, nClient_)));
00331                                 svr= int(ceil(p->serverSel()->value()));
00332                         }
00333                         assert((cl >= 0) && (cl < nClient_));
00334                         assert((svr >= 0) && (svr < nSrc_));
00335                         Node* c=client_[cl];
00336                         Node* s=server_[svr];
00337 
00338                         p->setClient(c);
00339                         p->setServer(s);
00340 
00341                         p->sched(lt);
00342                         session_[n] = p;
00343                        
00344                         return (TCL_OK);
00345                 }
00346         }
00347         return PagePool::command(argc, argv);
00348 }

Here is the call graph for this function:

int EmpFtpTrafPool::delay_bind_dispatch const char *  ,
const char *  ,
TclObject
[virtual]
 

Definition at line 159 of file empftp.cc.

References debug_.

00161 {
00162         if (delay_bind_bool(varName, localName, "debug_", &debug_, tracer)) 
00163                 return TCL_OK;
00164         return PagePool::delay_bind_dispatch(varName, localName, tracer);
00165 }

void EmpFtpTrafPool::delay_bind_init_all  )  [virtual]
 

Definition at line 153 of file empftp.cc.

00154 {
00155         delay_bind_init_one("debug_");
00156         PagePool::delay_bind_init_all();
00157 }

Agent* EmpFtpTrafPool::detachHead AgentList l  )  [inline, protected]
 

Definition at line 147 of file empftp.h.

References EmpFtpTrafPool::AgentListElem::agt_, and LIST_REMOVE.

Referenced by picksink(), and picktcp().

00147                                                {
00148                 AgentListElem *e = l->lh_first;
00149                 if (e == NULL)
00150                         return NULL;
00151                 Agent *a = e->agt_;
00152                 LIST_REMOVE(e, link);
00153                 delete e;
00154                 return a;
00155         }

void EmpFtpTrafPool::doneSession int  idx  )  [inline]
 

Definition at line 97 of file empftp.h.

References isdebug(), nSession_, and session_.

Referenced by EmpFtpTrafSession::handle().

00097                                          { 
00098 
00099                 assert((idx>=0) && (idx<nSession_) && (session_[idx]!=NULL));
00100                 if (isdebug()) {
00101                         printf("deleted session %d \n", idx );
00102                 }
00103                 delete session_[idx];
00104                 session_[idx] = NULL; 
00105         }

Here is the call graph for this function:

void EmpFtpTrafPool::insertAgent AgentList l,
Agent a
[inline, protected]
 

Definition at line 143 of file empftp.h.

References LIST_INSERT_HEAD.

Referenced by command().

00143                                                         {
00144                 AgentListElem *e = new AgentListElem(a);
00145                 LIST_INSERT_HEAD(l, e, link);
00146         }

int EmpFtpTrafPool::isdebug  )  [inline]
 

Definition at line 110 of file empftp.h.

References debug_.

Referenced by doneSession(), EmpFtpTrafSession::expire(), and EmpFtpTrafSession::sendFile().

00110 { return debug_; }

EmpFtpTrafPool::LIST_HEAD AgentList  ,
AgentListElem 
[protected]
 

TclObject* PagePool::lookup_obj const char *  name  )  [inline, protected, inherited]
 

Definition at line 242 of file pagepool.h.

00242                                                 {
00243                 TclObject* obj = Tcl::instance().lookup(name);
00244                 if (obj == NULL) 
00245                         fprintf(stderr, "Bad object name %s\n", name);
00246                 return obj;
00247         }

TclObject* PagePool::lookup_obj const char *  name  )  [inline, protected, inherited]
 

Definition at line 30 of file persconn.h.

Referenced by WebTrafPool::command(), EmpWebTrafPool::command(), command(), WebTrafPool::lookup_rv(), EmpWebTrafPool::lookup_rv(), lookup_rv(), WebTrafPool::picksink(), EmpWebTrafPool::picksink(), picksink(), WebTrafPool::picktcp(), EmpWebTrafPool::picktcp(), and picktcp().

00030                                                 {
00031                 TclObject* obj = Tcl::instance().lookup(name);
00032                 if (obj == NULL) 
00033                         fprintf(stderr, "Bad object name %s\n", name);
00034                 return obj;
00035         }

int EmpFtpTrafPool::lookup_rv EmpiricalRandomVariable *&  rv,
const char *  name
[inline, protected]
 

Definition at line 161 of file empftp.h.

References PagePool::lookup_obj().

Referenced by command().

00161                                                                              {
00162                 if (rv != NULL)
00163                         Tcl::instance().evalf("delete %s", rv->name());
00164                 rv = (EmpiricalRandomVariable*)lookup_obj(name);
00165                 return rv ? (TCL_OK) : (TCL_ERROR);
00166         }

Here is the call graph for this function:

int EmpFtpTrafPool::nSink  )  [inline]
 

Definition at line 109 of file empftp.h.

References nSink_.

Referenced by EmpFtpTrafSession::sendFile().

00109 { return nSink_; }

int EmpFtpTrafPool::nTcp  )  [inline]
 

Definition at line 108 of file empftp.h.

References nTcp_.

Referenced by EmpFtpTrafSession::sendFile().

00108 { return nTcp_; }

int PagePool::num_pages  )  const [inline, inherited]
 

Definition at line 233 of file pagepool.h.

References PagePool::num_pages_.

00233 { return num_pages_; }

int PagePool::num_pages  )  const [inline, inherited]
 

Definition at line 21 of file persconn.h.

References PagePool::num_pages_.

00021 { return num_pages_; }

TcpSink * EmpFtpTrafPool::picksink  ) 
 

Definition at line 192 of file empftp.cc.

References abort(), detachHead(), PagePool::lookup_obj(), nSink_, and sinkPool_.

Referenced by EmpFtpTrafSession::sendFile().

00193 {
00194         TcpSink* a = (TcpSink*)detachHead(&sinkPool_);
00195         if (a == NULL) {
00196                 Tcl& tcl = Tcl::instance();
00197                 tcl.evalf("%s alloc-tcp-sink", name());
00198                 a = (TcpSink*)lookup_obj(tcl.result());
00199                 if (a == NULL) {
00200                         fprintf(stderr, "Failed to allocate a TCP sink\n");
00201                         abort();
00202                 }
00203         } else 
00204                 nSink_--;
00205         return a;
00206 }

Here is the call graph for this function:

TcpAgent * EmpFtpTrafPool::picktcp int  size  ) 
 

Definition at line 175 of file empftp.cc.

References abort(), detachHead(), PagePool::lookup_obj(), nTcp_, and tcpPool_.

Referenced by EmpFtpTrafSession::sendFile().

00176 {
00177 
00178         TcpAgent* a = (TcpAgent*)detachHead(&tcpPool_);
00179         if (a == NULL) {
00180                 Tcl& tcl = Tcl::instance();
00181                 tcl.evalf("%s alloc-tcp %d", name(), win);
00182                 a = (TcpAgent*)lookup_obj(tcl.result());
00183                 if (a == NULL) {
00184                         fprintf(stderr, "Failed to allocate a TCP agent\n");
00185                         abort();
00186                 }
00187         } else 
00188                 nTcp_--;
00189         return a;
00190 }

Here is the call graph for this function:


Member Data Documentation

Node** EmpFtpTrafPool::client_ [protected]
 

Definition at line 131 of file empftp.h.

Referenced by command(), and ~EmpFtpTrafPool().

int EmpFtpTrafPool::debug_ [protected]
 

Definition at line 168 of file empftp.h.

Referenced by delay_bind_dispatch(), and isdebug().

int PagePool::duration_ [protected, inherited]
 

Definition at line 239 of file pagepool.h.

Referenced by TracePagePool::change_time(), ProxyTracePagePool::command(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), MediaPagePool::command(), ProxyTracePagePool::find_info(), and MediaPagePool::MediaPagePool().

double PagePool::end_time_ [protected, inherited]
 

Definition at line 238 of file pagepool.h.

Referenced by TracePagePool::change_time(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), MediaPagePool::command(), TracePagePool::load_page(), and PagePool::PagePool().

int EmpFtpTrafPool::nClient_ [protected]
 

Definition at line 130 of file empftp.h.

Referenced by command().

int EmpFtpTrafPool::nClientL_
 

Definition at line 116 of file empftp.h.

Referenced by command().

int EmpFtpTrafPool::nSession_ [protected]
 

Definition at line 127 of file empftp.h.

Referenced by command(), doneSession(), and ~EmpFtpTrafPool().

int EmpFtpTrafPool::nSink_ [protected]
 

Definition at line 156 of file empftp.h.

Referenced by command(), nSink(), and picksink().

int EmpFtpTrafPool::nSrc_
 

Definition at line 119 of file empftp.h.

Referenced by command().

int EmpFtpTrafPool::nSrcL_
 

Definition at line 115 of file empftp.h.

Referenced by command().

int EmpFtpTrafPool::nTcp_ [protected]
 

Definition at line 156 of file empftp.h.

Referenced by command(), nTcp(), and picktcp().

int PagePool::num_pages_ [protected, inherited]
 

Definition at line 236 of file pagepool.h.

Referenced by ClientPagePool::add_page(), EPATracePagePool::command(), ProxyTracePagePool::command(), ClientPagePool::command(), CompMathPagePool::command(), TracePagePool::command(), MediaPagePool::command(), CompMathPagePool::CompMathPagePool(), ProxyTracePagePool::find_info(), TracePagePool::get_page(), ProxyTracePagePool::init_page(), TracePagePool::load_page(), MathPagePool::MathPagePool(), PagePool::num_pages(), PagePool::PagePool(), and ClientPagePool::remove_page().

Node** EmpFtpTrafPool::server_
 

Definition at line 120 of file empftp.h.

Referenced by command(), and ~EmpFtpTrafPool().

EmpFtpTrafSession** EmpFtpTrafPool::session_ [protected]
 

Definition at line 128 of file empftp.h.

Referenced by command(), doneSession(), and ~EmpFtpTrafPool().

AgentList EmpFtpTrafPool::sinkPool_ [protected]
 

Definition at line 158 of file empftp.h.

Referenced by command(), EmpFtpTrafPool(), and picksink().

double PagePool::start_time_ [protected, inherited]
 

Definition at line 237 of file pagepool.h.

Referenced by TracePagePool::change_time(), ProxyTracePagePool::command(), CompMathPagePool::command(), MathPagePool::command(), TracePagePool::command(), MediaPagePool::command(), TracePagePool::load_page(), ProxyTracePagePool::load_req(), and PagePool::PagePool().

AgentList EmpFtpTrafPool::tcpPool_ [protected]
 

Definition at line 157 of file empftp.h.

Referenced by command(), EmpFtpTrafPool(), and picktcp().


The documentation for this class was generated from the following files:
Generated on Tue Apr 20 12:45:06 2004 for NS2.26SourcesOriginal by doxygen 1.3.3