#include <TCPBasicClientApp.h>
Inheritance diagram for TCPBasicClientApp:
Public Member Functions | |
TCPBasicClientApp () | |
virtual | ~TCPBasicClientApp () |
Protected Member Functions | |
void | sendRequest () |
virtual void | initialize () |
virtual void | handleTimer (cMessage *msg) |
virtual void | socketEstablished (int connId, void *yourPtr) |
virtual void | socketDataArrived (int connId, void *yourPtr, cMessage *msg, bool urgent) |
virtual void | socketClosed (int connId, void *yourPtr) |
virtual void | socketFailure (int connId, void *yourPtr, int code) |
Protected Attributes | |
cMessage * | timeoutMsg |
bool | earlySend |
int | numRequestsToSend |
|
00025 { 00026 timeoutMsg = NULL; 00027 }
|
|
00030 { 00031 cancelAndDelete(timeoutMsg); 00032 }
|
|
Redefined. Implements TCPGenericCliAppBase. 00062 { 00063 switch (msg->kind()) 00064 { 00065 case MSGKIND_CONNECT: 00066 EV << "starting session\n"; 00067 connect(); // active OPEN 00068 00069 // significance of earlySend: if true, data will be sent already 00070 // in the ACK of SYN, otherwise only in a separate packet (but still 00071 // immediately) 00072 if (earlySend) 00073 sendRequest(); 00074 break; 00075 00076 case MSGKIND_SEND: 00077 sendRequest(); 00078 numRequestsToSend--; 00079 // no scheduleAt(): next request will be sent when reply to this one 00080 // arrives (see socketDataArrived()) 00081 break; 00082 } 00083 }
|
|
Redefined to schedule a connect(). Reimplemented from TCPGenericCliAppBase. 00035 { 00036 TCPGenericCliAppBase::initialize(); 00037 00038 timeoutMsg = new cMessage("timer"); 00039 00040 numRequestsToSend = 0; 00041 earlySend = false; // TBD make it parameter 00042 WATCH(numRequestsToSend); 00043 WATCH(earlySend); 00044 00045 timeoutMsg->setKind(MSGKIND_CONNECT); 00046 scheduleAt((simtime_t)par("startTime"), timeoutMsg); 00047 }
|
|
Utility: sends a request to the server 00050 { 00051 EV << "sending request, " << numRequestsToSend-1 << " more to go\n"; 00052 00053 long requestLength = par("requestLength"); 00054 long replyLength = par("replyLength"); 00055 if (requestLength<1) requestLength=1; 00056 if (replyLength<1) replyLength=1; 00057 00058 sendPacket(requestLength, replyLength); 00059 }
|
|
Redefined to start another session after a delay. Reimplemented from TCPGenericCliAppBase. 00117 { 00118 TCPGenericCliAppBase::socketClosed(connId, ptr); 00119 00120 // start another session after a delay 00121 timeoutMsg->setKind(MSGKIND_CONNECT); 00122 scheduleAt(simTime()+(simtime_t)par("idleInterval"), timeoutMsg); 00123 }
|
|
Redefined. Reimplemented from TCPGenericCliAppBase. 00100 { 00101 TCPGenericCliAppBase::socketDataArrived(connId, ptr, msg, urgent); 00102 00103 if (numRequestsToSend>0) 00104 { 00105 EV << "reply arrived\n"; 00106 timeoutMsg->setKind(MSGKIND_SEND); 00107 scheduleAt(simTime()+(simtime_t)par("thinkTime"), timeoutMsg); 00108 } 00109 else 00110 { 00111 EV << "reply to last request arrived, closing session\n"; 00112 close(); 00113 } 00114 }
|
|
Redefined. Reimplemented from TCPGenericCliAppBase. 00086 { 00087 TCPGenericCliAppBase::socketEstablished(connId, ptr); 00088 00089 // determine number of requests in this session 00090 numRequestsToSend = (long) par("numRequestsPerSession"); 00091 if (numRequestsToSend<1) numRequestsToSend=1; 00092 00093 // perform first request if not already done (next one will be sent when reply arrives) 00094 if (!earlySend) 00095 sendRequest(); 00096 numRequestsToSend--; 00097 }
|
|
Redefined to reconnect after a delay. Reimplemented from TCPGenericCliAppBase. 00126 { 00127 TCPGenericCliAppBase::socketFailure(connId, ptr, code); 00128 00129 // reconnect after a delay 00130 timeoutMsg->setKind(MSGKIND_CONNECT); 00131 scheduleAt(simTime()+(simtime_t)par("reconnectInterval"), timeoutMsg); 00132 }
|
|
|
|
|
|
|