#include <tcpapp.h>
Inheritance diagram for TcpApp:


Public Member Functions | |
| TcpApp (Agent *tcp) | |
| ~TcpApp () | |
| virtual void | recv (int nbytes) |
| virtual void | send (int nbytes, AppData *data) |
| void | connect (TcpApp *dst) |
| virtual void | process_data (int size, AppData *data) |
| virtual AppData * | get_data (int &, AppData *) |
| virtual void | resume () |
| virtual void | send (int nbytes) |
| Process *& | target () |
| virtual void | send_data (int size, AppData *data=0) |
Protected Member Functions | |
| virtual int | command (int argc, const char *const *argv) |
| CBuf * | rcvr_retrieve_data () |
| virtual void | start () |
| virtual void | stop () |
Protected Attributes | |
| TcpApp * | dst_ |
| CBufList | cbuf_ |
| CBuf * | curdata_ |
| int | curbytes_ |
| Agent * | agent_ |
| int | enableRecv_ |
| int | enableResume_ |
| Process * | target_ |
|
|
Definition at line 133 of file tcpapp.cc. References Application::agent_, and Agent::attachApp().
|
Here is the call graph for this function:

|
|
Definition at line 140 of file tcpapp.cc. References Application::agent_, and Agent::attachApp().
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented from Application. Reimplemented in HttpUInvalAgent. Definition at line 219 of file tcpapp.cc. References Application::command(), connect(), dst_, send(), and TcpAppString::set_string(). Referenced by HttpUInvalAgent::command().
00220 {
00221 Tcl& tcl = Tcl::instance();
00222
00223 if (strcmp(argv[1], "connect") == 0) {
00224 dst_ = (TcpApp *)TclObject::lookup(argv[2]);
00225 if (dst_ == NULL) {
00226 tcl.resultf("%s: connected to null object.", name_);
00227 return (TCL_ERROR);
00228 }
00229 dst_->connect(this);
00230 return (TCL_OK);
00231 } else if (strcmp(argv[1], "send") == 0) {
00232 /*
00233 * <app> send <size> <tcl_script>
00234 */
00235 int size = atoi(argv[2]);
00236 if (argc == 3)
00237 send(size, NULL);
00238 else {
00239 TcpAppString *tmp = new TcpAppString();
00240 tmp->set_string(argv[3]);
00241 send(size, tmp);
00242 }
00243 return (TCL_OK);
00244 } else if (strcmp(argv[1], "dst") == 0) {
00245 tcl.resultf("%s", dst_->name());
00246 return TCL_OK;
00247 }
00248 return Application::command(argc, argv);
00249 }
|
Here is the call graph for this function:

|
|
Definition at line 90 of file tcpapp.h. References dst_. Referenced by command().
00090 { dst_ = dst; }
|
|
||||||||||||
|
Reimplemented from Process. Reimplemented in HttpUInvalAgent. Definition at line 93 of file tcpapp.h. References abort().
00093 {
00094 // Not supported
00095 abort();
00096 return NULL;
00097 }
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented from Process. Reimplemented in HttpUInvalAgent. Definition at line 251 of file tcpapp.cc. References Process::send_data(), TcpAppString::str(), Process::target(), TCPAPP_STRING, and AppData::type(). Referenced by recv().
00252 {
00253 if (data == NULL)
00254 return;
00255 // XXX Default behavior:
00256 // If there isn't a target, use tcl to evaluate the data
00257 if (target())
00258 send_data(size, data);
00259 else if (data->type() == TCPAPP_STRING) {
00260 TcpAppString *tmp = (TcpAppString*)data;
00261 Tcl::instance().eval(tmp->str());
00262 }
00263 }
|
Here is the call graph for this function:

|
|
Definition at line 104 of file tcpapp.h. References cbuf_, and CBufList::detach(). Referenced by recv().
|
Here is the call graph for this function:

|
|
Reimplemented from Application. Definition at line 159 of file tcpapp.cc. References abort(), CBuf::bytes(), curbytes_, curdata_, CBuf::data(), dst_, Scheduler::instance(), process_data(), rcvr_retrieve_data(), and CBuf::size().
00160 {
00161 // If it's the start of a new transmission, grab info from dest,
00162 // and execute callback
00163 if (curdata_ == 0)
00164 curdata_ = dst_->rcvr_retrieve_data();
00165 if (curdata_ == 0) {
00166 fprintf(stderr, "[%g] %s receives a packet but no callback!\n",
00167 Scheduler::instance().clock(), name_);
00168 return;
00169 }
00170 curbytes_ += size;
00171 #ifdef TCPAPP_DEBUG
00172 fprintf(stderr, "[%g] %s gets data size %d, %s\n",
00173 Scheduler::instance().clock(), name(), curbytes_,
00174 curdata_->data());
00175 #endif
00176 if (curbytes_ == curdata_->bytes()) {
00177 // We've got exactly the data we want
00178 // If we've received all data, execute the callback
00179 process_data(curdata_->size(), curdata_->data());
00180 // Then cleanup this data transmission
00181 delete curdata_;
00182 curdata_ = NULL;
00183 curbytes_ = 0;
00184 } else if (curbytes_ > curdata_->bytes()) {
00185 // We've got more than we expected. Must contain other data.
00186 // Continue process callbacks until the unfinished callback
00187 while (curbytes_ >= curdata_->bytes()) {
00188 process_data(curdata_->size(), curdata_->data());
00189 curbytes_ -= curdata_->bytes();
00190 #ifdef TCPAPP_DEBUG
00191 fprintf(stderr,
00192 "[%g] %s gets data size %d(left %d)\n",
00193 Scheduler::instance().clock(),
00194 name(),
00195 curdata_->bytes(), curbytes_);
00196 //curdata_->data());
00197 #endif
00198 delete curdata_;
00199 curdata_ = dst_->rcvr_retrieve_data();
00200 if (curdata_ != 0)
00201 continue;
00202 if ((curdata_ == 0) && (curbytes_ > 0)) {
00203 fprintf(stderr, "[%g] %s gets extra data!\n",
00204 Scheduler::instance().clock(), name_);
00205 Tcl::instance().eval("[Simulator instance] flush-trace");
00206 abort();
00207 } else
00208 // Get out of the look without doing a check
00209 break;
00210 }
00211 }
00212 }
|
Here is the call graph for this function:

|
|
Reimplemented from Application. Definition at line 214 of file tcpapp.cc.
00215 {
00216 // Do nothing
00217 }
|
|
|
Definition at line 109 of file app.cc. References Application::agent_, and Agent::sendmsg(). Referenced by Application::command(), send(), and TrafficGenerator::timeout().
|
Here is the call graph for this function:

|
||||||||||||
|
Reimplemented in HttpUInvalAgent. Definition at line 148 of file tcpapp.cc. References cbuf_, Scheduler::clock(), CBufList::insert(), Scheduler::instance(), and Application::send(). Referenced by command(), HttpApp::command(), and HttpUInvalAgent::send().
00149 {
00150 CBuf *p = new CBuf(cbk, nbytes);
00151 #ifdef TCPAPP_DEBUG
00152 p->time() = Scheduler::instance().clock();
00153 #endif
00154 cbuf_.insert(p);
00155 Application::send(nbytes);
00156 }
|
Here is the call graph for this function:

|
||||||||||||
|
Definition at line 106 of file ns-process.h. References Process::process_data(), and Process::target_. Referenced by process_data(), and MediaApp::process_data().
00106 {
00107 if (target_)
00108 target_->process_data(size, data);
00109 }
|
Here is the call graph for this function:

|
|
Reimplemented from Application. Definition at line 107 of file tcpapp.h. References abort().
00107 { abort(); }
|
Here is the call graph for this function:

|
|
Reimplemented from Application. Definition at line 108 of file tcpapp.h. References abort().
00108 { abort(); }
|
Here is the call graph for this function:

|
|
Definition at line 97 of file ns-process.h. References Process::target_. Referenced by QA::check_availability(), Process::command(), HttpApp::command(), MediaApp::get_data(), QA::output(), and process_data().
00097 { return target_; }
|
|
|
Definition at line 60 of file app.h. Referenced by Application::command(), RA_Traffic::init(), POO_Traffic::init(), EXPOO_Traffic::init(), CBR_Traffic::init(), CBR_PP_Traffic::init(), QA::rap(), MediaApp::rap(), Application::send(), TcpApp(), TrafficTrace::timeout(), TelnetApp::timeout(), EXPOO_Traffic::timeout(), CBR_PP_Traffic::timeout(), and ~TcpApp(). |
|
|
Definition at line 111 of file tcpapp.h. Referenced by rcvr_retrieve_data(), and send(). |
|
|
Definition at line 113 of file tcpapp.h. Referenced by recv(). |
|
|
Definition at line 112 of file tcpapp.h. Referenced by recv(). |
|
|
|
|
|
Definition at line 61 of file app.h. Referenced by Application::command(), and Application::recv(). |
|
|
Definition at line 62 of file app.h. Referenced by Application::command(), and Application::resume(). |
|
|
Definition at line 113 of file ns-process.h. Referenced by HttpUInvalAgent::command(), Process::Process(), HttpUInvalAgent::process_data(), Process::send_data(), and Process::target(). |
1.3.3