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

WebServer Class Reference

#include <webserver.h>

Inheritance diagram for WebServer:

Inheritance graph
[legend]
Collaboration diagram for WebServer:

Collaboration graph
[legend]
List of all members.

Public Types

enum  TimerStatus { TIMER_IDLE, TIMER_PENDING, TIMER_HANDLING }

Public Member Functions

 WebServer (WebTrafPool *)
void set_node (Node *)
Nodeget_node ()
int get_nid ()
void set_rate (double)
void set_mode (int)
void set_queue_limit (int)
double job_arrival (int, Node *, Agent *, Agent *, int, void *)
void sched (double delay)
void resched (double delay)
void cancel ()
void force_cancel ()
int status ()

Protected Member Functions

virtual void handle (Event *)

Protected Attributes

int status_
Event event_

Private Member Functions

virtual void expire (Event *e)
double job_departure ()
void schedule_next_job ()

Private Attributes

WebTrafPoolweb_pool_
Nodenode
double rate_
int mode_
job_shead
job_stail
int queue_size_
int queue_limit_
int busy_

Member Enumeration Documentation

enum TimerHandler::TimerStatus [inherited]
 

Enumeration values:
TIMER_IDLE 
TIMER_PENDING 
TIMER_HANDLING 

Definition at line 66 of file timer-handler.h.


Constructor & Destructor Documentation

WebServer::WebServer WebTrafPool  ) 
 

Definition at line 34 of file webserver.cc.

References busy_, head, queue_limit_, queue_size_, set_mode(), set_rate(), tail, and web_pool_.

00034                                          {
00035   web_pool_ = webpool;
00036   
00037   // clean busy flag
00038   busy_ = 0;
00039   
00040   // Initialize function flag:
00041   // 0: there's no server processing delay
00042   // 1: server processing delay from FCFS scheduling policy
00043   // 2: server processing delay from STF scheduling policy
00044   set_mode(0);
00045   
00046   // Initialize server processing raste
00047   set_rate(1);
00048   
00049   // initialize the job queue
00050   head = tail = NULL;
00051   queue_size_ = 0;
00052   queue_limit_ = 0;
00053 
00054   //cancel();
00055 }

Here is the call graph for this function:


Member Function Documentation

void TimerHandler::cancel  )  [inherited]
 

Definition at line 31 of file timer-handler.cc.

References TimerHandler::_cancel(), abort(), TimerHandler::status_, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING.

Referenced by BayFullTcpAgent::cancel_rtx_timeout(), PushbackTimer::cancelStatus(), SmacCsTimer::checkToCancel(), LmsReceiver::delete_nak(), QA::get_data(), SMAC::handleACK(), SMAC::handleCTS(), SMAC::handleSYNC(), LandmarkAgent::periodic_callback(), LandmarkAgent::ProcessHierUpdate(), DelAckSink::recv(), TcpAsymSink::recv(), AbsDelAckSink::recv(), MIPMHAgent::recv(), FtpClientAgent::recv(), PushbackTimer::removeEvents(), DelAckSink::reset(), FackTcpAgent::send_much(), TcpSessionAgent::set_rtx_timer(), TcpFsAgent::set_rtx_timer(), TrafficGenerator::stop(), SA_Agent::stop(), RTCPAgent::stop(), RapAgent::stop(), QA::stop(), LandmarkAgent::stop(), Estimator::stop(), NeighborCache::~NeighborCache(), PacketTypeLog::~PacketTypeLog(), QA::~QA(), and TBF::~TBF().

00032 {
00033         if (status_ != TIMER_PENDING) {
00034                 fprintf(stderr,
00035                   "Attempting to cancel timer at %p which is not scheduled\n",
00036                   this);
00037                 abort();
00038         }
00039         _cancel();
00040         status_ = TIMER_IDLE;
00041 }

Here is the call graph for this function:

void WebServer::expire Event e  )  [private, virtual]
 

Implements TimerHandler.

Definition at line 191 of file webserver.cc.

References job_departure().

00191                                {
00192   job_departure();
00193 }

Here is the call graph for this function:

void TimerHandler::force_cancel  )  [inline, inherited]
 

Definition at line 60 of file timer-handler.h.

References TimerHandler::_cancel(), TimerHandler::status_, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING.

Referenced by TcpAgent::cancel_rtx_timer(), TcpSessionAgent::cancel_rtx_timer(), TcpFsAgent::cancel_rtx_timer(), AbsTcpAgent::cancel_timer(), TcpAgent::cancel_timers(), TcpSessionAgent::cancel_timers(), FullTcpAgent::cancel_timers(), TcpFsAgent::cancel_timers(), SinkAgent::command(), UnslottedAlohaMac::end_of_contention(), GAFAgent::processDiscoveryMsg(), RTPAgent::rate_change(), TfrcAgent::stop(), RTPAgent::stop(), and SinkAgent::stop().

00060                                    {    // cancel!
00061                 if (status_ == TIMER_PENDING) {
00062                         _cancel();
00063                         status_ = TIMER_IDLE;
00064                 }
00065         }

Here is the call graph for this function:

int WebServer::get_nid  ) 
 

Definition at line 74 of file webserver.cc.

References node, and Node::nodeid().

Referenced by WebTrafPool::command(), and WebTrafPool::find_server().

00074                        {
00075   return(node->nodeid());
00076 }

Here is the call graph for this function:

Node * WebServer::get_node  ) 
 

Definition at line 83 of file webserver.cc.

References node.

Referenced by WebTrafPool::pickdst(), and LogWebTrafPool::pickdst().

00083                           {
00084   return(node);
00085 }

void TimerHandler::handle Event  )  [protected, virtual, inherited]
 

Implements Handler.

Reimplemented in EmpFtpTrafSession, EmpWebPage, EmpWebTrafSession, HBTimer, WebPage, and WebTrafSession.

Definition at line 69 of file timer-handler.cc.

References abort(), TimerHandler::expire(), TimerHandler::status_, TimerHandler::TIMER_HANDLING, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING.

Referenced by WebTrafSession::handle(), WebPage::handle(), HBTimer::handle(), EmpWebTrafSession::handle(), EmpWebPage::handle(), and EmpFtpTrafSession::handle().

00070 {
00071         if (status_ != TIMER_PENDING)   // sanity check
00072                 abort();
00073         status_ = TIMER_HANDLING;
00074         expire(e);
00075         // if it wasn't rescheduled, it's done
00076         if (status_ == TIMER_HANDLING)
00077                 status_ = TIMER_IDLE;
00078 }

Here is the call graph for this function:

double WebServer::job_arrival int  ,
Node ,
Agent ,
Agent ,
int  ,
void * 
 

Definition at line 87 of file webserver.cc.

References busy_, job_s::clnt, job_s::data, head, WebTrafPool::launchResp(), mode_, job_s::next, node, job_s::obj_id, queue_limit_, queue_size_, schedule_next_job(), job_s::size, job_s::snk, tail, job_s::tcp, and web_pool_.

Referenced by WebTrafPool::command().

00087                                                                                                   {
00088   // There's no server processing delay
00089   if (! mode_) {
00090     web_pool_->launchResp(obj_id, node, clnt, tcp, snk, size, data);
00091 
00092     return 1;
00093   }
00094 
00095   //printf("%d %d\n", queue_limit_, queue_size_);
00096   if (!queue_limit_ || queue_size_ < queue_limit_) {
00097     // Insert the new job to the job queue
00098     job_s *new_job = new(job_s);
00099     new_job->obj_id = obj_id;
00100     new_job->clnt = clnt;
00101     new_job->tcp = tcp;
00102     new_job->snk = snk;
00103     new_job->size = size;
00104     new_job->data = data;
00105     new_job->next = NULL; 
00106 
00107     // always insert the new job to the tail.
00108     if (tail)
00109       tail->next = new_job;
00110     else
00111       head = new_job;
00112     tail = new_job;
00113 
00114     queue_size_++;
00115   } else {
00116     // drop the incoming job
00117     //printf("server drop job\n");
00118     return 0;
00119   }
00120 
00121   // Schedule the dequeue time when there's no job being processed
00122   if (!busy_) 
00123     schedule_next_job();
00124   
00125   return 1;
00126 }

Here is the call graph for this function:

double WebServer::job_departure  )  [private]
 

Definition at line 129 of file webserver.cc.

References job_s::clnt, job_s::data, head, WebTrafPool::launchResp(), job_s::next, node, job_s::obj_id, queue_size_, schedule_next_job(), job_s::size, job_s::snk, tail, job_s::tcp, and web_pool_.

Referenced by expire().

00129                                 {
00130   if (head) {
00131     web_pool_->launchResp(head->obj_id, node, head->clnt, head->tcp, head->snk, head->size, head->data);
00132     
00133     // delete the first job
00134     job_s *p = head;
00135     if (head->next)
00136       head = head->next;
00137     else 
00138       head = tail = NULL;
00139     
00140     delete(p);
00141     queue_size_--;
00142   }
00143   
00144   // Schedule next job
00145   schedule_next_job();
00146   return 0;
00147 }

Here is the call graph for this function:

void TimerHandler::resched double  delay  )  [inherited]
 

Definition at line 60 of file timer-handler.cc.

References TimerHandler::_cancel(), TimerHandler::_sched(), TimerHandler::status_, and TimerHandler::TIMER_PENDING.

Referenced by UnslottedAlohaMac::backoff(), SinkAgent::bcast_interest(), PIQueue::calculate_p(), SMAC::collision(), MIPMHAgent::command(), MIPBSAgent::command(), GAFAgent::command(), SinkAgent::command(), LmsReceiver::create_nak(), GAFAgent::duty_timeout(), PacketTypeLog::expire(), QSTimer::expire(), OmniMcastSendBufTimer::expire(), OmniMcastArpBufferTimer::expire(), QATimer::expire(), PromotionTimer::expire(), SendBufferTimer::expire(), SendBufTimer::expire(), ArpBufferTimer::expire(), EnergyTimer::expire(), DiffusionRate::GradientTimeOut(), SatLinkHandoffMgr::handoff(), TermLinkHandoffMgr::handoff(), RapAgent::IpgTimeout(), RapAgent::LossHandler(), DiffusionRate::NegReinfTimeOut(), TfrcAgent::nextpkt(), TfrcSinkAgent::nextpkt(), RBPRenoTcpAgent::paced_send_one(), RBPVegasTcpAgent::paced_send_one(), QSNewRenoTcpAgent::paced_send_one(), PacketTypeLog::PacketTypeLog(), LandmarkAgent::periodic_callback(), LandmarkAgent::ProcessHierUpdate(), LogWebTrafPool::processLog(), PushbackQueue::PushbackQueue(), QSAgent::QSAgent(), RTPAgent::rate_change(), TfrcAgent::recv(), DelAckSink::recv(), FullTcpAgent::recv(), BayFullTcpAgent::recv(), TcpAsymSink::recv(), AbsDelAckSink::recv(), TBF::recv(), SMAC::recv(), SA_Agent::recv(), FtpClientAgent::recv(), TfrcAgent::reduce_rate_on_no_feedback(), MIPMHAgent::reg(), SinkAgent::report(), LivenessTimer::resched(), HBTimer::resched(), RapAgent::RttTimeout(), SmacCounterTimer::sched(), PushbackTimer::schedule(), schedule_next_job(), GAFAgent::schedule_wakeup(), TcpFsAgent::send_helper(), TcpAsymAgent::send_helper(), TcpAgent::send_much(), TcpSessionAgent::send_much(), Sack1TcpAgent::send_much(), SackRHTcpAgent::send_much(), IntTcpAgent::send_much(), FullTcpAgent::send_much(), BayFullTcpAgent::send_much(), FackTcpAgent::send_much(), UnslottedAlohaMac::sendDown(), UnslottedAlohaMac::sendUp(), TcpAgent::set_rtx_timer(), TcpSessionAgent::set_rtx_timer(), TcpFsAgent::set_rtx_timer(), AbsTcpAgent::set_timer(), REMQueue::set_update_timer(), TrafficGenerator::start(), TfrcAgent::start(), RTPAgent::start(), RTCPAgent::start(), FtpClientAgent::start(), Estimator::start(), SinkAgent::start(), DiffusionRate::Start(), DiffusionProb::Start(), TrafficGenerator::timeout(), TrafficTrace::timeout(), TelnetApp::timeout(), FullTcpAgent::timeout(), BayFullTcpAgent::timeout(), TBF::timeout(), SA_Agent::timeout(), RTPAgent::timeout(), RTCPAgent::timeout(), PushbackQueue::timeout(), MIPMHAgent::timeout(), MIPBSAgent::timeout(), LmsReceiver::timeout(), GAFAgent::timeout(), EXPOO_Traffic::timeout(), Estimator::timeout(), SinkAgent::timeout(), CBR_PP_Traffic::timeout(), WirelessPhy::UpdateIdleEnergy(), SMAC::updateNav(), SMAC::updateNeighNav(), and WirelessPhy::WirelessPhy().

00061 {
00062         if (status_ == TIMER_PENDING)
00063                 _cancel();
00064         _sched(delay);
00065         status_ = TIMER_PENDING;
00066 }

Here is the call graph for this function:

void TimerHandler::sched double  delay  )  [inherited]
 

Reimplemented in SmacRecvTimer, SmacNeighNavTimer, and SmacCounterTimer.

Definition at line 49 of file timer-handler.cc.

References TimerHandler::_sched(), abort(), TimerHandler::status_, TimerHandler::TIMER_IDLE, and TimerHandler::TIMER_PENDING.

Referenced by SMAC::checkToSend(), WebTrafPool::command(), EmpWebTrafPool::command(), EmpFtpTrafPool::command(), DSRAgent::command(), EmpWebPage::doneObject(), WebTrafSession::donePage(), EmpWebTrafSession::donePage(), QA::get_data(), WebTrafSession::handle(), WebPage::handle(), EmpWebTrafSession::handle(), EmpWebPage::handle(), EmpFtpTrafSession::handle(), SMAC::handleCounterTimer(), LandmarkAgent::ProcessHierUpdate(), SmacCounterTimer::sched(), SmacNeighNavTimer::sched(), SmacRecvTimer::sched(), LivenessTimer::sched(), PushTimer::sched(), HBTimer::sched(), SMAC::sentDATA(), SMAC::sentRTS(), SMAC::SMAC(), TelnetApp::start(), OmniMcastAgent::Start(), DiffusionAgent::Start(), LandmarkAgent::startUp(), and SMAC::transmit().

00050 {
00051         if (status_ != TIMER_IDLE) {
00052                 fprintf(stderr,"Couldn't schedule timer");
00053                 abort();
00054         }
00055         _sched(delay);
00056         status_ = TIMER_PENDING;
00057 }

Here is the call graph for this function:

void WebServer::schedule_next_job  )  [private]
 

Definition at line 149 of file webserver.cc.

References busy_, job_s::clnt, job_s::data, head, mode_, job_s::next, job_s::obj_id, rate_, TimerHandler::resched(), job_s::size, and STF_DELAY.

Referenced by job_arrival(), and job_departure().

00149                                   {
00150   job_s *p, *q;
00151   
00152   if (head) {
00153     // do shortest task first scheduling
00154     if (mode_ == STF_DELAY) { 
00155       // find the shortest task
00156       p = q = head;
00157       while (q) {
00158         if (p->size > q->size)
00159           p = q;
00160         
00161         q = q->next;
00162       }
00163       
00164       // exchange the queue head with the shortest job
00165       int obj_id = p->obj_id;
00166       Node *clnt = p->clnt;
00167       int size = p->size;
00168       void *data = p->data;
00169       
00170       p->obj_id = head->obj_id;
00171       p->clnt = head->clnt;
00172       p->size = head->size;
00173       p->data = head->data;
00174 
00175       head->obj_id = obj_id;
00176       head->clnt = clnt;
00177       head->size = size;
00178       head->data = data;
00179     }
00180     
00181     // Schedule the processing timer
00182     double delay_ = head->size / rate_;
00183     resched(delay_);
00184     busy_ = 1;
00185     //  printf("%d, %f, %f\n", head->size, rate_, delay_);
00186   } else
00187     busy_ = 0;
00188 }

Here is the call graph for this function:

void WebServer::set_mode int   ) 
 

Definition at line 63 of file webserver.cc.

References mode_.

Referenced by WebTrafPool::command(), and WebServer().

00063                                    {
00064   mode_ = s_mode;
00065 }

void WebServer::set_node Node  ) 
 

Definition at line 79 of file webserver.cc.

References node.

Referenced by WebTrafPool::command().

00079                                 {
00080   node = n;
00081 }

void WebServer::set_queue_limit int   ) 
 

Definition at line 68 of file webserver.cc.

References queue_limit_.

Referenced by WebTrafPool::command().

00068                                          {
00069   queue_limit_ = limit;
00070 }

void WebServer::set_rate double   ) 
 

Definition at line 58 of file webserver.cc.

References rate_.

Referenced by WebTrafPool::command(), and WebServer().

00058                                       {
00059   rate_ = s_rate;
00060 }

int TimerHandler::status  )  [inline, inherited]
 

Definition at line 67 of file timer-handler.h.

References TimerHandler::status_.

Referenced by TcpSessionAgent::add_pkts(), BayFullTcpAgent::cancel_rtx_timeout(), HttpMInvalCache::command(), FullTcpAgent::foutput(), QA::get_data(), TcpAgent::output(), VegasTcpAgent::output(), RFC793eduTcpAgent::output(), QSNewRenoTcpAgent::output(), BayFullTcpAgent::output(), DelAckSink::recv(), FullTcpAgent::recv(), BayFullTcpAgent::recv(), TcpAsymSink::recv(), AbsDelAckSink::recv(), MIPMHAgent::recv(), DelAckSink::reset(), TcpAgent::send_much(), TcpSessionAgent::send_much(), Sack1TcpAgent::send_much(), SackRHTcpAgent::send_much(), IntTcpAgent::send_much(), FullTcpAgent::send_much(), BayFullTcpAgent::send_much(), FackTcpAgent::send_much(), TcpSessionAgent::set_rtx_timer(), TcpFsAgent::set_rtx_timer(), RapAgent::stop(), QA::stop(), and QA::~QA().

00067 { return status_; };


Member Data Documentation

int WebServer::busy_ [private]
 

Definition at line 103 of file webserver.h.

Referenced by job_arrival(), schedule_next_job(), and WebServer().

Event TimerHandler::event_ [protected, inherited]
 

Definition at line 75 of file timer-handler.h.

Referenced by TimerHandler::_cancel(), TimerHandler::_sched(), WebPage::start(), and EmpWebPage::start().

job_s* WebServer::head [private]
 

Definition at line 94 of file webserver.h.

Referenced by job_arrival(), job_departure(), schedule_next_job(), and WebServer().

int WebServer::mode_ [private]
 

Definition at line 91 of file webserver.h.

Referenced by job_arrival(), schedule_next_job(), and set_mode().

Node* WebServer::node [private]
 

Definition at line 82 of file webserver.h.

Referenced by get_nid(), get_node(), job_arrival(), job_departure(), and set_node().

int WebServer::queue_limit_ [private]
 

Definition at line 96 of file webserver.h.

Referenced by job_arrival(), set_queue_limit(), and WebServer().

int WebServer::queue_size_ [private]
 

Definition at line 95 of file webserver.h.

Referenced by job_arrival(), job_departure(), and WebServer().

double WebServer::rate_ [private]
 

Definition at line 85 of file webserver.h.

Referenced by schedule_next_job(), and set_rate().

int TimerHandler::status_ [protected, inherited]
 

Definition at line 74 of file timer-handler.h.

Referenced by SmacTimer::busy(), TimerHandler::cancel(), SmacCsTimer::checkToCancel(), TimerHandler::force_cancel(), TimerHandler::handle(), TimerHandler::resched(), TimerHandler::sched(), SmacCounterTimer::sched(), WebPage::start(), EmpWebPage::start(), TimerHandler::status(), TimerHandler::TimerHandler(), EmpFtpTrafSession::~EmpFtpTrafSession(), EmpWebTrafSession::~EmpWebTrafSession(), and WebTrafSession::~WebTrafSession().

job_s * WebServer::tail [private]
 

Definition at line 94 of file webserver.h.

Referenced by job_arrival(), job_departure(), and WebServer().

WebTrafPool* WebServer::web_pool_ [private]
 

Definition at line 79 of file webserver.h.

Referenced by job_arrival(), job_departure(), and WebServer().


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