#include <empftp.h>
Inheritance diagram for EmpFtpTrafPool:


Public Member Functions | |
| EmpFtpTrafPool () | |
| virtual | ~EmpFtpTrafPool () |
| void | doneSession (int idx) |
| TcpAgent * | picktcp (int size) |
| TcpSink * | picksink () |
| 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) |
| Agent * | detachHead (AgentList *l) |
| int | lookup_rv (EmpiricalRandomVariable *&rv, const char *name) |
| TclObject * | lookup_obj (const char *name) |
| TclObject * | lookup_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_ |
|
|
Definition at line 167 of file empftp.cc. References LIST_INIT, sinkPool_, and tcpPool_.
|
|
|
Definition at line 139 of file empftp.cc. References client_, nSession_, server_, and session_.
|
|
||||||||||||
|
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:

|
||||||||||||||||
|
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 }
|
|
|
Definition at line 153 of file empftp.cc.
00154 {
00155 delay_bind_init_one("debug_");
00156 PagePool::delay_bind_init_all();
00157 }
|
|
|
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 }
|
|
|
Definition at line 97 of file empftp.h. References isdebug(), nSession_, and session_. Referenced by EmpFtpTrafSession::handle().
|
Here is the call graph for this function:

|
||||||||||||
|
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 }
|
|
|
Definition at line 110 of file empftp.h. References debug_. Referenced by doneSession(), EmpFtpTrafSession::expire(), and EmpFtpTrafSession::sendFile().
00110 { return debug_; }
|
|
||||||||||||
|
|
|
|
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 }
|
|
|
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 }
|
|
||||||||||||
|
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:

|
|
Definition at line 109 of file empftp.h. References nSink_. Referenced by EmpFtpTrafSession::sendFile().
00109 { return nSink_; }
|
|
|
Definition at line 108 of file empftp.h. References nTcp_. Referenced by EmpFtpTrafSession::sendFile().
00108 { return nTcp_; }
|
|
|
Definition at line 233 of file pagepool.h. References PagePool::num_pages_.
00233 { return num_pages_; }
|
|
|
Definition at line 21 of file persconn.h. References PagePool::num_pages_.
00021 { return num_pages_; }
|
|
|
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:

|
|
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:

|
|
Definition at line 131 of file empftp.h. Referenced by command(), and ~EmpFtpTrafPool(). |
|
|
Definition at line 168 of file empftp.h. Referenced by delay_bind_dispatch(), and isdebug(). |
|
|
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(). |
|
|
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(). |
|
|
Definition at line 130 of file empftp.h. Referenced by command(). |
|
|
Definition at line 116 of file empftp.h. Referenced by command(). |
|
|
Definition at line 127 of file empftp.h. Referenced by command(), doneSession(), and ~EmpFtpTrafPool(). |
|
|
Definition at line 156 of file empftp.h. Referenced by command(), nSink(), and picksink(). |
|
|
Definition at line 119 of file empftp.h. Referenced by command(). |
|
|
Definition at line 115 of file empftp.h. Referenced by command(). |
|
|
|
|
|
|
Definition at line 120 of file empftp.h. Referenced by command(), and ~EmpFtpTrafPool(). |
|
|
Definition at line 128 of file empftp.h. Referenced by command(), doneSession(), and ~EmpFtpTrafPool(). |
|
|
Definition at line 158 of file empftp.h. Referenced by command(), EmpFtpTrafPool(), and picksink(). |
|
|
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(). |
|
|
Definition at line 157 of file empftp.h. Referenced by command(), EmpFtpTrafPool(), and picktcp(). |
1.3.3