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

GAFAgent Class Reference

#include <gaf.h>

Inheritance diagram for GAFAgent:

Inheritance graph
[legend]
Collaboration diagram for GAFAgent:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 GAFAgent (nsaddr_t id)
virtual void recv (Packet *, Handler *)
void timeout (GafMsgType)
u_int32_t nodeid ()
double myttl ()
virtual void recv (Packet *p, const char *s)
void recvOnly (Packet *)
void send (Packet *p, Handler *h)
virtual void send (int sz, AppData *data)
virtual void send (int nbytes)
virtual void timeout (int tno)
virtual void sendmsg (int sz, AppData *, const char *flags=0)
virtual void sendmsg (int nbytes, const char *flags=0)
virtual void sendto (int sz, AppData *, const char *flags, nsaddr_t dst)
virtual void sendto (int nbytes, const char *flags, nsaddr_t dst)
virtual void connect (nsaddr_t dst)
virtual void close ()
virtual void listen ()
virtual void attachApp (Application *app)
virtual int & size ()
nsaddr_taddr ()
nsaddr_tport ()
nsaddr_tdaddr ()
nsaddr_tdport ()
void set_pkttype (packet_t pkttype)
packet_t get_pkttype ()
NsObjecttarget ()
virtual void drop (Packet *p)
int isdebug () const
virtual void debug (const char *fmt,...)

Protected Member Functions

int command (int argc, const char *const *argv)
void node_on ()
void node_off ()
void duty_timeout ()
void send_discovery ()
void makeUpDiscoveryMsg (Packet *p)
void processDiscoveryMsg (Packet *p)
void schedule_wakeup (struct DiscoveryMsg)
void setGAFstate (GafNodeState)
virtual void delay_bind_init_all ()
virtual int delay_bind_dispatch (const char *varName, const char *localName, TclObject *tracer)
virtual void recvBytes (int bytes)
virtual void idle ()
Packetallocpkt () const
Packetallocpkt (int) const
void initpkt (Packet *) const
virtual void trace (TracedVar *v)
void deleteAgentTrace ()
void addAgentTrace (const char *name)
void monitorAgentTrace ()
OldValuelookupOldValue (TracedVar *v)
void insertOldValue (TracedVar *v, const char *value)
void dumpTracedVars ()
virtual void trace_event (char *eventtype)
virtual void drop (Packet *p, const char *s)
virtual void reset ()
void handle (Event *)

Protected Attributes

double beacon_
int randomflag_
GAFDiscoverTimer timer_
GAFSelectTimer stimer_
GAFDutyTimer dtimer_
int seqno_
int gid_
int nid_
Nodethisnode
int maxttl_
GafNodeState state_
int leader_settime_
int adapt_mobility_
ns_addr_t here_
ns_addr_t dst_
int size_
packet_t type_
int fid_
int prio_
int flags_
int defttl_
Tcl_Channel channel_
char * traceName_
OldValueoldValueList_
Applicationapp_
EventTraceet_
NsObjecttarget_
NsObjectdrop_
int debug_

Static Protected Attributes

int uidcnt_

Constructor & Destructor Documentation

GAFAgent::GAFAgent nsaddr_t  id  ) 
 

Definition at line 72 of file gaf.cc.

References GAF_FREE, Node::get_node_by_address(), God::getMyGrid(), gid_, God::instance(), nid_, PT_GAF, seqno_, and thisnode.

00072                               : Agent(PT_GAF), beacon_(1), randomflag_(1), timer_(this), stimer_(this), dtimer_(this), maxttl_(5), state_(GAF_FREE),leader_settime_(0),adapt_mobility_(0)
00073 {
00074         double x = 0.0, y = 0.0, z = 0.0;
00075 
00076         seqno_ = -1;
00077         nid_ = id;
00078         thisnode = Node::get_node_by_address(nid_); 
00079         // gid_ = nid_; // temporary setting, MUST BE RESET
00080 
00081         // grid caculation
00082         // no need to update location becasue getLoc will do it
00083 
00084         ((MobileNode *)thisnode)->getLoc(&x, &y, &z);
00085         gid_ = God::instance()->getMyGrid(x,y);
00086         
00087         if (gid_ < 0) {
00088             printf("fatal error: node is outside topography\n");
00089         }
00090 }

Here is the call graph for this function:


Member Function Documentation

void Agent::addAgentTrace const char *  name  )  [protected, inherited]
 

Definition at line 326 of file agent.cc.

References ns_addr_t::addr_, Agent::channel_, Scheduler::clock(), Agent::dst_, Agent::here_, Scheduler::instance(), TIME_FORMAT, and Agent::traceName_.

Referenced by Agent::command().

00327 {
00328         char wrk[256];
00329         int n;
00330         double curTime = (&Scheduler::instance() == NULL ? 0 : 
00331                           Scheduler::instance().clock());
00332         
00333         sprintf(wrk, "a -t "TIME_FORMAT" -s %d -d %d -n %s",
00334                 curTime, here_.addr_, dst_.addr_, name);
00335         n = strlen(wrk);
00336         wrk[n] = '\n';
00337         wrk[n+1] = 0;
00338         if (channel_)
00339                 (void)Tcl_Write(channel_, wrk, n+1);
00340         // keep agent trace name
00341         if (traceName_ != NULL)
00342                 delete[] traceName_;
00343         traceName_ = new char[strlen(name)+1];
00344         strcpy(traceName_, name);
00345 }

Here is the call graph for this function:

nsaddr_t& Agent::addr  )  [inline, inherited]
 

Definition at line 96 of file agent.h.

References ns_addr_t::addr_, Agent::here_, and nsaddr_t.

Referenced by LandmarkAgent::assign_lmaddress(), SSMSRMAgent::command(), IntTcpAgent::createTcpSession(), Agent::flushAVar(), LmsSender::handle_lms_pkt(), SSMSRMAgent::is_active(), QSNewRenoTcpAgent::recv(), TcpAsymSink::recv(), SRMAgent::recv(), SSMSRMAgent::recv(), QSAgent::recv(), MIPBSAgent::recv(), LmsAgent::recv(), HttpInvalAgent::recv(), CtrMcastEncap::recv(), SSMSRMAgent::recv_glb_sess(), SSMSRMAgent::recv_loc_sess(), SSMSRMAgent::recv_rep_sess(), SRMAgent::recv_sess(), TapAgent::recvpkt(), MIPMHAgent::reg(), MIPBSAgent::send_ads(), LmsSender::send_dmcast(), LmsReceiver::send_dmcast(), LmsAgent::send_downstream(), SSMSRMAgent::send_glb_sess(), LmsSender::send_lms_pkt(), SSMSRMAgent::send_loc_sess(), LmsReceiver::send_nak(), LmsReceiver::send_refresh(), SSMSRMAgent::send_rep_sess(), SRMAgent::send_sess(), MIPMHAgent::send_sols(), LmsSender::send_spm(), LmsAgent::send_upstream(), SRMAgent::sendmsg(), LmsSender::solicit_naks(), SRMAgent::start(), TcpAgent::trace_event(), TcpAgent::traceAll(), TcpAsymAgent::traceAll(), TcpAgent::traceVar(), TcpSessionAgent::traceVar(), and TcpAsymAgent::traceVar().

00096 { return here_.addr_; }

Packet * Agent::allocpkt int   )  const [protected, inherited]
 

Definition at line 517 of file agent.cc.

References Packet::allocdata(), and Agent::allocpkt().

00518 {
00519         Packet* p = allocpkt();
00520 
00521         if (n > 0)
00522                 p->allocdata(n);
00523 
00524         return(p);
00525 }

Here is the call graph for this function:

Packet * Agent::allocpkt  )  const [protected, inherited]
 

Definition at line 506 of file agent.cc.

References Packet::alloc(), and Agent::initpkt().

Referenced by TcpSink::ack(), QSTcpSink::ack(), Agent::allocpkt(), PingAgent::command(), MessageAgent::command(), mcastControlAgent::command(), LmsAgent::command(), LDPAgent::command(), LandmarkAgent::command(), IvsReceiver::command(), DSDV_Agent::command(), OmniMcastAgent::create_packet(), FloodingAgent::create_packet(), DiffusionAgent::create_packet(), SinkAgent::create_packet(), SensorQueryAgent::generate_query(), DSRAgent::getRouteForPacket(), LandmarkAgent::makeUpdate(), DSDV_Agent::makeUpdate(), TcpAgent::output(), VegasTcpAgent::output(), RFC793eduTcpAgent::output(), QSNewRenoTcpAgent::output(), IntTcpAgent::output(), AbsTcpAgent::output(), TCPTapAgent::processpkt(), AbsDelAckSink::recv(), AbsTcpSink::recv(), SAack_Agent::recv(), PingAgent::recv(), Encapsulator::recv(), TapAgent::recvpkt(), MIPMHAgent::reg(), DSRAgent::replyFromRouteCache(), DSRAgent::returnSrcRouteToRequestor(), HttpInvalAgent::send(), MIPBSAgent::send_ads(), SRMAgent::send_ctrl(), SSMSRMAgent::send_ctrl(), MFTPSndAgent::send_data(), send_discovery(), LmsSender::send_dmcast(), LmsReceiver::send_dmcast(), SSMSRMAgent::send_glb_sess(), LmsSender::send_lms_pkt(), SSMSRMAgent::send_loc_sess(), MFTPRcvAgent::send_nak(), LmsReceiver::send_nak(), LmsReceiver::send_refresh(), SSMSRMAgent::send_rep_sess(), SRMAgent::send_sess(), MIPMHAgent::send_sols(), LmsSender::send_spm(), MFTPSndAgent::send_status_request(), RapAgent::SendAck(), UdpAgent::sendmsg(), SimpleTcpAgent::sendmsg(), SRMAgent::sendmsg(), SA_Agent::sendmsg(), RTPAgent::sendmsg(), PushbackAgent::sendMsg(), LmsSender::sendmsg(), FullTcpAgent::sendpacket(), BayFullTcpAgent::sendpacket(), RapAgent::SendPacket(), TfrcAgent::sendpkt(), TfrcSinkAgent::sendpkt(), SA_Agent::sendpkt(), rtProtoDV::sendpkt(), RTPAgent::sendpkt(), RTCPAgent::sendpkt(), RLM_Sender::sendpkt(), IvsSource::sendpkt(), IcmpAgent::sendredirect(), SA_Agent::sendreq(), DSRAgent::sendRouteShortening(), SA_Agent::sendteardown(), LmsSender::solicit_naks(), and AbsDelAckSink::timeout().

00507 {
00508         Packet* p = Packet::alloc();
00509         initpkt(p);
00510         return (p);
00511 }

Here is the call graph for this function:

void Agent::attachApp Application app  )  [virtual, inherited]
 

Definition at line 372 of file agent.cc.

References Agent::app_.

Referenced by HttpMInvalCache::command(), Application::command(), TcpApp::TcpApp(), and TcpApp::~TcpApp().

00373 {
00374         app_ = app;
00375 }

void Agent::close  )  [virtual, inherited]
 

Reimplemented in FullTcpAgent.

Definition at line 377 of file agent.cc.

Referenced by Agent::command().

00378 {
00379 }

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

Reimplemented from Agent.

Definition at line 392 of file gaf.cc.

References adapt_mobility_, Agent::command(), GAF_STARTUP_JITTER, gafjitter(), maxttl_, TimerHandler::resched(), and timer_.

00393 {
00394         if (argc == 2) {
00395           if (strcmp (argv[1], "start-gaf") == 0) {
00396             // schedule the discovery timer randomly
00397             timer_.resched(gafjitter(GAF_STARTUP_JITTER, 1));
00398             // schedule the select phase after certain time
00399             // of discovery msg exchange, as fast as possible
00400             // stimer_.resched(Random::uniform(GAF_LEADER_JITTER,GAF_LEADER_JITTER+1)); 
00401 
00402             return (TCL_OK); 
00403           }
00404               
00405         }
00406         if (argc == 3) {
00407             if (strcmp(argv[1], "adapt-mobility") == 0) {
00408                         adapt_mobility_ = atoi(argv[2]);
00409                         //timer_.resched(Random::uniform(0, beacon_));
00410                         return TCL_OK;
00411             }
00412         
00413             if (strcmp(argv[1], "maxttl") == 0) {
00414                 maxttl_ = atoi(argv[2]);
00415                 return TCL_OK;
00416             }
00417 
00418         }
00419         return (Agent::command(argc, argv));
00420 }

Here is the call graph for this function:

void Agent::connect nsaddr_t  dst  )  [virtual, inherited]
 

Definition at line 389 of file agent.cc.

Referenced by Agent::command().

00390 {
00391 /*
00392         dst_ = dst;
00393 */
00394 }

nsaddr_t& Agent::daddr  )  [inline, inherited]
 

Definition at line 98 of file agent.h.

References ns_addr_t::addr_, Agent::dst_, and nsaddr_t.

Referenced by IntTcpAgent::createTcpSession(), DSDV_Agent::lost_link(), TcpAsymSink::recv(), CtrMcastEncap::recv(), PingResponder::reflect(), IntTcpAgent::rxmit_last(), LmsSender::send_dmcast(), LmsSender::send_lms_pkt(), IntTcpAgent::send_one(), rtProtoDV::sendpkt(), LmsSender::solicit_naks(), TcpAgent::trace_event(), TcpAgent::traceAll(), TcpAsymAgent::traceAll(), TcpAgent::traceVar(), TcpSessionAgent::traceVar(), and TcpAsymAgent::traceVar().

00098 { return dst_.addr_; }

void NsObject::debug const char *  fmt,
... 
[virtual, inherited]
 

Definition at line 102 of file object.cc.

References NsObject::debug_.

00103 {
00104         if (!debug_)
00105                 return;
00106         va_list ap;
00107         va_start(ap, fmt);
00108         vprintf(fmt, ap);
00109 }

int Agent::delay_bind_dispatch const char *  varName,
const char *  localName,
TclObject tracer
[protected, virtual, inherited]
 

Reimplemented from NsObject.

Reimplemented in BayFullTcpAgent, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

Definition at line 93 of file agent.cc.

References ns_addr_t::addr_, Agent::defttl_, NsObject::delay_bind_dispatch(), Agent::dst_, Agent::fid_, Agent::flags_, Agent::here_, ns_addr_t::port_, and Agent::prio_.

Referenced by TcpAgent::delay_bind_dispatch(), TcpSink::delay_bind_dispatch(), and LDPAgent::delay_bind_dispatch().

00094 {
00095         if (delay_bind(varName, localName, "agent_addr_", (int*)&(here_.addr_), tracer)) return TCL_OK;
00096         if (delay_bind(varName, localName, "agent_port_", (int*)&(here_.port_), tracer)) return TCL_OK;
00097         if (delay_bind(varName, localName, "dst_addr_", (int*)&(dst_.addr_), tracer)) return TCL_OK;
00098         if (delay_bind(varName, localName, "dst_port_", (int*)&(dst_.port_), tracer)) return TCL_OK;
00099         if (delay_bind(varName, localName, "fid_", (int*)&fid_, tracer)) return TCL_OK;
00100         if (delay_bind(varName, localName, "prio_", (int*)&prio_, tracer)) return TCL_OK;
00101         if (delay_bind(varName, localName, "flags_", (int*)&flags_, tracer)) return TCL_OK;
00102         if (delay_bind(varName, localName, "ttl_", &defttl_, tracer)) return TCL_OK;
00103         if (delay_bind(varName, localName, "class_", (int*)&fid_, tracer)) return TCL_OK;
00104         return Connector::delay_bind_dispatch(varName, localName, tracer);
00105 }

Here is the call graph for this function:

void Agent::delay_bind_init_all  )  [protected, virtual, inherited]
 

Reimplemented from NsObject.

Reimplemented in BayFullTcpAgent, LDPAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, TcpSink, TcpAgent, and VegasTcpAgent.

Definition at line 78 of file agent.cc.

References NsObject::delay_bind_init_all().

Referenced by TcpAgent::delay_bind_init_all(), TcpSink::delay_bind_init_all(), and LDPAgent::delay_bind_init_all().

00079 {
00080         delay_bind_init_one("agent_addr_");
00081         delay_bind_init_one("agent_port_");
00082         delay_bind_init_one("dst_addr_");
00083         delay_bind_init_one("dst_port_");
00084         delay_bind_init_one("fid_");
00085         delay_bind_init_one("prio_");
00086         delay_bind_init_one("flags_");
00087         delay_bind_init_one("ttl_");
00088         delay_bind_init_one("class_");
00089         Connector::delay_bind_init_all();
00090 }

Here is the call graph for this function:

void Agent::deleteAgentTrace  )  [protected, inherited]
 

Definition at line 222 of file agent.cc.

References ns_addr_t::addr_, Agent::dst_, Agent::flushAVar(), Agent::here_, Scheduler::instance(), TIME_FORMAT, and Agent::traceName_.

Referenced by Agent::command().

00223 {
00224         char wrk[256];
00225 
00226         // XXX we don't know InstVar outside of Tcl! Is there any
00227         // tracedvars hidden in InstVar? If so, shall we have a tclclInt.h?
00228         TracedVar* var = tracedvar_;
00229         for ( ;  var != 0;  var = var->next_) 
00230                 flushAVar(var);
00231 
00232         // we need to flush all var values to trace file, 
00233         // so nam can do backtracing
00234         sprintf(wrk, "a -t "TIME_FORMAT" -s %d -d %d -n %s -x",
00235                 Scheduler::instance().clock(), here_.addr_,
00236                 dst_.addr_, traceName_); 
00237         if (traceName_ != NULL)
00238                 delete[] traceName_;
00239         traceName_ = NULL;
00240 }

Here is the call graph for this function:

nsaddr_t& Agent::dport  )  [inline, inherited]
 

Definition at line 99 of file agent.h.

References Agent::dst_, nsaddr_t, and ns_addr_t::port_.

Referenced by DSDV_Agent::lost_link(), TcpAsymSink::recv(), CtrMcastEncap::recv(), IntTcpAgent::rxmit_last(), IntTcpAgent::send_one(), rtProtoDV::sendpkt(), TcpAgent::trace_event(), TcpAgent::traceAll(), TcpAsymAgent::traceAll(), TcpAgent::traceVar(), TcpSessionAgent::traceVar(), and TcpAsymAgent::traceVar().

00099 { return dst_.port_; }

void Connector::drop Packet p,
const char *  s
[protected, virtual, inherited]
 

Definition at line 114 of file connector.cc.

References Connector::drop_, Packet::free(), and NsObject::recv().

00115 {
00116         if (drop_ != 0)
00117                 drop_->recv(p, s);
00118         else
00119                 Packet::free(p);
00120 }

Here is the call graph for this function:

void Connector::drop Packet p  )  [virtual, inherited]
 

Definition at line 106 of file connector.cc.

References Connector::drop_, Packet::free(), and NsObject::recv().

Referenced by DSRAgent::acceptRouteReply(), ARPTable::arpresolve(), JoBS::dropFront(), Vq::dropPacketForECN(), DSRAgent::dropSendBuff(), JoBS::dropTail(), dsREDQueue::edrop(), Vq::enque(), SRR::enque(), SimpleIntServ::enque(), SFQ::enque(), rtqueue::enque(), RIOQueue::enque(), REMQueue::enque(), REDQueue::enque(), RedPDQueue::enque(), PIQueue::enque(), Marker::enque(), GK::enque(), dsREDQueue::enque(), DRR::enque(), DropTail::enque(), Demarker::enque(), aodv_rqueue::enque(), toraAgent::forward(), AODV::forward(), LandmarkAgent::ForwardPacket(), DSDV_Agent::forwardPacket(), DSRAgent::getRouteForPacket(), Snoop::handle(), DSRAgent::handleFlowForwarding(), DSRAgent::handleForwarding(), DSDV_Agent::lost_link(), TCPTapAgent::processpkt(), CMUPriQueue::prq_enqueue(), rtqueue::purge(), imepAgent::purgeReXmitQ(), SessionTTLChecker::recv(), TTLChecker::recv(), toraAgent::recv(), FullTcpAgent::recv(), BayFullTcpAgent::recv(), TBF::recv(), SatLL::recv(), LL::recv(), GAFPartner::recv(), FloodAgent::recv(), Filter::recv(), DynamicLink::recv(), DSDV_Agent::recv(), AODV::recv(), AODV::recvError(), PriQueue::recvHighPriority(), AODV::recvReply(), toraAgent::reset(), Queue< T >::reset(), LinkDelay::reset(), AODV::rt_ll_failed(), AODV::rt_purge(), AODV::rt_resolve(), toraAgent::rtRoutePacket(), TCPTapAgent::sendpkt(), TapAgent::sendpkt(), IPTapAgent::sendpkt(), AODV::sendRequest(), SatLL::sendUp(), LL::sendUp(), PriQueue::Terminate(), DSRAgent::Terminate(), CMUPriQueue::Terminate(), ARPTable::Terminate(), and DSRAgent::undeliverablePkt().

00107 {
00108         if (drop_ != 0)
00109                 drop_->recv(p);
00110         else
00111                 Packet::free(p);
00112 }

Here is the call graph for this function:

void Agent::dumpTracedVars  )  [protected, inherited]
 

void GAFAgent::duty_timeout  )  [protected]
 

Definition at line 367 of file gaf.cc.

References GAF_NONSTART_JITTER, gafjitter(), God::getMyGrid(), gid_, God::instance(), node_on(), TimerHandler::resched(), send_discovery(), thisnode, and timer_.

Referenced by timeout().

00368 {
00369     double x=0.0, y=0.0, z=0.0;
00370 
00371     // find where I am
00372     
00373     ((MobileNode *)thisnode)->getLoc(&x, &y, &z);
00374     gid_ = God::instance()->getMyGrid(x,y);
00375 
00376 
00377     // wake up myself
00378     node_on();
00379     
00380     // send discovery first to try to find whether
00381     // there is a leader around me
00382 
00383     send_discovery();
00384 
00385     // schedule the discovery timer randomly
00386     // can wait longer to get a chance to be replaced
00387 
00388     timer_.resched(gafjitter(GAF_NONSTART_JITTER, 1));
00389 
00390 }

Here is the call graph for this function:

packet_t Agent::get_pkttype  )  [inline, inherited]
 

Definition at line 101 of file agent.h.

References packet_t, and Agent::type_.

Referenced by CBR_Traffic::init().

00101 { return type_; }

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

Implements Handler.

Reimplemented in LinkDelay, LL, AckRecons, and Snoop.

Definition at line 91 of file object.cc.

References NsObject::recv().

00092 {
00093         recv((Packet*)e);
00094 }

Here is the call graph for this function:

void Agent::idle  )  [protected, virtual, inherited]
 

Definition at line 363 of file agent.cc.

References Agent::app_, and Application::resume().

Referenced by FullTcpAgent::foutput(), TcpAgent::output(), VegasTcpAgent::output(), RFC793eduTcpAgent::output(), QSNewRenoTcpAgent::output(), IntTcpAgent::output(), BayFullTcpAgent::output(), UdpAgent::sendmsg(), SA_Agent::sendmsg(), and RTPAgent::sendmsg().

00364 {
00365         if (app_)
00366                 app_->resume();
00367 }

Here is the call graph for this function:

void Agent::initpkt Packet  )  const [protected, inherited]
 

Definition at line 446 of file agent.cc.

References hdr_nv::access(), hdr_flags::access(), hdr_ip::access(), hdr_cmn::access(), ns_addr_t::addr_, Scheduler::clock(), hdr_flags::cong_action_, hdr_ip::daddr(), Agent::defttl_, hdr_cmn::direction(), hdr_ip::dport(), Agent::dst_, hdr_flags::ecn_, hdr_flags::ecn_capable_, hdr_flags::ecn_to_echo_, hdr_flags::eln_, hdr_cmn::error(), Agent::fid_, hdr_ip::flowid(), hdr_flags::fs_, NixNode::GetNixVector(), NixNode::GetNodeObject(), hdr_nv::h_used, Agent::here_, hdr_cmn::iface(), Scheduler::instance(), hdr_flags::no_ts_, hdr_cmn::NONE, hdr_nv::nv(), hdr_ip::offset(), hdr_nv::offset(), ns_addr_t::port_, hdr_flags::pri_, hdr_ip::prio(), Agent::prio_, hdr_cmn::ptype(), NixVec::Reset(), hdr_ip::saddr(), hdr_cmn::size(), Agent::size_, hdr_ip::sport(), hdr_cmn::timestamp(), hdr_ip::ttl(), Agent::type_, hdr_cmn::uid(), and Agent::uidcnt_.

Referenced by Agent::allocpkt(), and PingResponder::recv().

00447 {
00448         hdr_cmn* ch = hdr_cmn::access(p);
00449         ch->uid() = uidcnt_++;
00450         ch->ptype() = type_;
00451         ch->size() = size_;
00452         ch->timestamp() = Scheduler::instance().clock();
00453         ch->iface() = UNKN_IFACE.value(); // from packet.h (agent is local)
00454         ch->direction() = hdr_cmn::NONE;
00455 
00456         ch->error() = 0;        /* pkt not corrupt to start with */
00457 
00458         hdr_ip* iph = hdr_ip::access(p);
00459         iph->saddr() = here_.addr_;
00460         iph->sport() = here_.port_;
00461         iph->daddr() = dst_.addr_;
00462         iph->dport() = dst_.port_;
00463         
00464         //DEBUG
00465         //if (dst_ != -1)
00466         //  printf("pl break\n");
00467         
00468         iph->flowid() = fid_;
00469         iph->prio() = prio_;
00470         iph->ttl() = defttl_;
00471 
00472         hdr_flags* hf = hdr_flags::access(p);
00473         hf->ecn_capable_ = 0;
00474         hf->ecn_ = 0;
00475         hf->eln_ = 0;
00476         hf->ecn_to_echo_ = 0;
00477         hf->fs_ = 0;
00478         hf->no_ts_ = 0;
00479         hf->pri_ = 0;
00480         hf->cong_action_ = 0;
00481 #ifdef HAVE_STL
00482 
00483         hdr_nv* nv = hdr_nv::access(p);
00484         if (0)
00485                 printf("Off hdr_nv %d, ip_hdr %d myaddr %ld\n",
00486                        hdr_nv::offset(), hdr_ip::offset(), here_.addr_);
00487         NixNode* pNixNode = NixNode::GetNodeObject(here_.addr_);
00488         if (0)
00489                 printf("Node Object %p\n", pNixNode);
00490         if (pNixNode) { 
00491                 // If we get non-null, indicates nixvector routing in use
00492                 // Delete any left over nv in the packet
00493                 // Get a nixvector to the target (may create new)
00494                 NixVec* pNv = pNixNode->GetNixVector(dst_.addr_);
00495                 pNv->Reset();
00496                 nv->nv() = pNv; // And set the nixvec in the packet
00497                 nv->h_used = 0; // And reset used portion to 0
00498         }
00499 #endif //HAVE_STL
00500 }

Here is the call graph for this function:

void Agent::insertOldValue TracedVar *  v,
const char *  value
[protected, inherited]
 

Definition at line 250 of file agent.cc.

References min, OldValue::next_, Agent::oldValueList_, TRACEVAR_MAXVALUELENGTH, OldValue::val_, and OldValue::var_.

Referenced by Agent::trace().

00251 {
00252         OldValue *p = new OldValue;
00253         assert(p != NULL);
00254         strncpy(p->val_, value, min(strlen(value)+1, TRACEVAR_MAXVALUELENGTH));
00255         p->var_ = v;
00256         p->next_ = NULL;
00257         if (oldValueList_ == NULL) 
00258                 oldValueList_ = p;
00259         else {
00260                 p->next_ = oldValueList_;
00261                 oldValueList_ = p;
00262         }
00263 }

int NsObject::isdebug  )  const [inline, inherited]
 

Definition at line 61 of file object.h.

References NsObject::debug_.

00061 { return debug_; }

void Agent::listen  )  [virtual, inherited]
 

Reimplemented in BayFullTcpAgent, RapAgent, and FullTcpAgent.

Definition at line 381 of file agent.cc.

Referenced by Agent::command().

00382 {
00383 }

OldValue * Agent::lookupOldValue TracedVar *  v  )  [protected, inherited]
 

Definition at line 242 of file agent.cc.

References OldValue::next_, Agent::oldValueList_, and OldValue::var_.

Referenced by Agent::trace().

00243 {
00244         OldValue *p = oldValueList_;
00245         while ((p != NULL) && (p->var_ != v))
00246                 p = p->next_;
00247         return p;
00248 }

void GAFAgent::makeUpDiscoveryMsg Packet p  )  [protected]
 

Definition at line 444 of file gaf.cc.

References hdr_cmn::access(), hdr_ip::access(), Packet::accessdata(), hdr_cmn::addr_type_, Packet::allocdata(), hdr_ip::daddr(), hdr_ip::dport(), GAF_LEADER, God::getMyGridSize(), gid_, God::instance(), Address::instance(), IP_BROADCAST, IP_HDR_LEN, leader_settime_, MIN_LIFETIME, myttl(), hdr_cmn::next_hop_, nid_, Address::nodeshift(), NOW, NS_AF_INET, hdr_cmn::size_, state_, thisnode, and u_int32_t.

Referenced by send_discovery().

00445 {
00446   hdr_ip *iph = hdr_ip::access(p);
00447   hdr_cmn *hdrc = hdr_cmn::access(p);
00448   u_int32_t ttl,stime;
00449   unsigned char *walk;
00450   double gridsize, speed;
00451 
00452   // fill up the header
00453   hdrc->next_hop_ = IP_BROADCAST;
00454   hdrc->addr_type_ = NS_AF_INET;
00455   iph->daddr() = IP_BROADCAST << Address::instance().nodeshift();
00456   iph->dport() = 254;
00457 
00458   // hdrc->direction() = hdr_cmn::DOWN;
00459 
00460   // fill up the data
00461 
00462   p->allocdata(sizeof(DiscoveryMsg));
00463   walk = p->accessdata ();
00464   hdrc->size_ = sizeof(DiscoveryMsg) + IP_HDR_LEN; // Existence Msg + IP
00465 
00466   *(walk++) = gid_ >> 24;
00467   *(walk++) = (gid_ >> 16) & 0xFF;
00468   *(walk++) = (gid_ >> 8) & 0xFF;
00469   *(walk++) = (gid_ >> 0) & 0xFF;
00470   *(walk++) = nid_ >> 24;
00471   *(walk++) = (nid_ >> 16) & 0xFF;
00472   *(walk++) = (nid_ >> 8) & 0xFF;
00473   *(walk++) = (nid_ >> 0) & 0xFF;
00474 
00475   // access my state
00476 
00477   *(walk++) = state_ >> 24;
00478   *(walk++) = (state_ >> 16) & 0xFF;
00479   *(walk++) = (state_ >> 8) & 0xFF;
00480   *(walk++) = (state_ >> 0) & 0xFF;  
00481 
00482 
00483   // ttl tells the receiver that how much longer the sender can
00484   // survive, cut it into half for the purpose of load balance
00485 
00486   if (state_ == GAF_LEADER) {
00487       // must send real msg because I am the leader
00488         ttl = (int)(leader_settime_ - NOW);
00489         if (ttl < 0) ttl = 0;
00490 
00491   } else {
00492 
00493       if ((ttl = (u_int32_t)myttl()) > MIN_LIFETIME) {
00494           ttl = (u_int32_t) ttl/2;
00495       }
00496 
00497   }
00498   *(walk++) = ttl >> 24;
00499   *(walk++) = (ttl >> 16) & 0xFF;
00500   *(walk++) = (ttl >> 8) & 0xFF;
00501   *(walk++) = (ttl >> 0) & 0xFF;
00502   
00503 
00504   // fill my possible time of leaving this grid
00505   
00506   
00507   speed = ((MobileNode*)thisnode)->speed();
00508 
00509   if (speed == 0) {
00510     // make stime big enough
00511     stime = 2*ttl;
00512   } else {
00513     gridsize = God::instance()->getMyGridSize();
00514     stime = (u_int32_t) (gridsize/speed);
00515   }
00516 
00517   *(walk++) = stime >> 24;
00518   *(walk++) = (stime >> 16) & 0xFF;
00519   *(walk++) = (stime >> 8) & 0xFF;
00520   *(walk++) = (stime >> 0) & 0xFF;
00521 
00522   //printf("Node %d send out Exitence msg gid/nid %d %d\n", nid_, gid_, nid_);
00523 
00524 }

Here is the call graph for this function:

void Agent::monitorAgentTrace  )  [protected, inherited]
 

Definition at line 310 of file agent.cc.

References ns_addr_t::addr_, Agent::channel_, Scheduler::clock(), Agent::here_, Scheduler::instance(), TIME_FORMAT, and Agent::traceName_.

Referenced by Agent::command().

00311 {
00312         char wrk[256];
00313         int n;
00314         double curTime = (&Scheduler::instance() == NULL ? 0 : 
00315                           Scheduler::instance().clock());
00316         
00317         sprintf(wrk, "v -t "TIME_FORMAT" -e monitor_agent %d %s",
00318                 curTime, here_.addr_, traceName_);
00319         n = strlen(wrk);
00320         wrk[n] = '\n';
00321         wrk[n+1] = 0;
00322         if (channel_)
00323                 (void)Tcl_Write(channel_, wrk, n+1);
00324 }

Here is the call graph for this function:

double GAFAgent::myttl  ) 
 

Definition at line 261 of file gaf.cc.

References Node::energy_model(), Node::ifhead(), and thisnode.

Referenced by makeUpDiscoveryMsg(), processDiscoveryMsg(), and timeout().

00262 {
00263   double ce,maxp;
00264   Phy *phyp; 
00265   double ttl; 
00266   
00267   ce = (thisnode->energy_model())->energy();
00268 
00269   phyp = (thisnode->ifhead()).lh_first;
00270 
00271   if (phyp) {
00272               maxp = ((WirelessPhy *)phyp)->getPtconsume();
00273   } 
00274 
00275   ttl = ce/maxp;
00276   
00277   return ttl;
00278 
00279 }

Here is the call graph for this function:

void GAFAgent::node_off  )  [protected]
 

Definition at line 528 of file gaf.cc.

References Node::energy_model(), GAF_SLEEP, Node::ifhead(), EnergyModel::node_on(), setGAFstate(), and thisnode.

Referenced by schedule_wakeup().

00529 {
00530     Phy *p;
00531     EnergyModel *em;
00532 
00533     //printf ("Node (%d %d) goes SLEEP from %d at %f\n",nid_, gid_, state_, Scheduler::instance().clock());
00534 
00535         
00536     // if I am in the data transfer state, do not turn off
00537 
00538     // if (state_ == GAF_TRAFFIC) return;
00539 
00540     // set node state
00541     em = thisnode->energy_model();
00542     em->node_on() = false;
00543     //((MobileNode *)thisnode->energy_model())->node_on() = false;
00544 
00545     // notify phy
00546     p  = (thisnode->ifhead()).lh_first;
00547     if (p) {
00548         ((WirelessPhy *)p)->node_off();
00549     }
00550     // change agent state
00551     setGAFstate(GAF_SLEEP);
00552 }

Here is the call graph for this function:

void GAFAgent::node_on  )  [protected]
 

Definition at line 555 of file gaf.cc.

References Node::energy_model(), GAF_FREE, Node::ifhead(), EnergyModel::node_on(), setGAFstate(), and thisnode.

Referenced by duty_timeout().

00556 {
00557     Phy *p;
00558     EnergyModel* em;
00559 
00560     // set node state
00561 
00562     em = thisnode->energy_model();
00563     em->node_on() = true;
00564 
00565     //(MobileNode *)thisnode->energy_model()->node_on() = true;
00566 
00567     // notify phy
00568 
00569     p = (thisnode->ifhead()).lh_first;
00570     if (p) {
00571         ((WirelessPhy *)p)->node_on();
00572     }
00573     
00574     setGAFstate(GAF_FREE);
00575 }

Here is the call graph for this function:

u_int32_t GAFAgent::nodeid  )  [inline]
 

Definition at line 128 of file gaf.h.

References nid_, and u_int32_t.

00128 {return nid_;}

nsaddr_t& Agent::port  )  [inline, inherited]
 

Definition at line 97 of file agent.h.

References Agent::here_, nsaddr_t, and ns_addr_t::port_.

Referenced by LmsAgent::pkt2agent(), TcpAsymSink::recv(), MIPBSAgent::recv(), LmsAgent::recv(), HttpInvalAgent::recv(), CtrMcastEncap::recv(), IntTcpAgent::rxmit_last(), IntTcpAgent::send_one(), LmsReceiver::send_refresh(), IcmpAgent::sendredirect(), TcpAgent::trace_event(), TcpAgent::traceAll(), TcpAsymAgent::traceAll(), TcpAgent::traceVar(), TcpSessionAgent::traceVar(), and TcpAsymAgent::traceVar().

00097 { return here_.port_; }

void GAFAgent::processDiscoveryMsg Packet p  )  [protected]
 

Definition at line 112 of file gaf.cc.

References Packet::accessdata(), TimerHandler::force_cancel(), GAF_FREE, GAF_LEADER, God::getMyGrid(), DiscoveryMsg::gid, gid_, God::instance(), leader_settime_, MIN_LIFETIME, myttl(), DiscoveryMsg::nid, nid_, NOW, schedule_wakeup(), send_discovery(), DiscoveryMsg::state, state_, DiscoveryMsg::stime, stimer_, thisnode, DiscoveryMsg::ttl, and u_int32_t.

Referenced by recv().

00113 {
00114         struct DiscoveryMsg emsg;
00115         u_int32_t dst;
00116         unsigned char *w = p->accessdata ();
00117         double x = 0.0, y = 0.0, z = 0.0;
00118         int ttl;
00119 
00120 
00121         dst = *(w++);
00122         dst = dst << 8 | *(w++);
00123         dst = dst << 8 | *(w++);
00124         dst = dst << 8 | *(w++);
00125         
00126         emsg.gid = dst;
00127         
00128         dst = *(w++);
00129         dst = dst << 8 | *(w++);
00130         dst = dst << 8 | *(w++);
00131         dst = dst << 8 | *(w++);
00132 
00133         emsg.nid = dst;
00134 
00135         dst = *(w++);
00136         dst = dst << 8 | *(w++);
00137         dst = dst << 8 | *(w++);
00138         dst = dst << 8 | *(w++);
00139         
00140         emsg.state = dst;
00141 
00142         dst = *(w++);
00143         dst = dst << 8 | *(w++);
00144         dst = dst << 8 | *(w++);
00145         dst = dst << 8 | *(w++);
00146         
00147         emsg.ttl = dst;
00148         
00149         dst = *(w++);
00150         dst = dst << 8 | *(w++);
00151         dst = dst << 8 | *(w++);
00152         dst = dst << 8 | *(w++);
00153         
00154         emsg.stime = dst;
00155 
00156 
00157         // first, check if this node has changed its grid
00158         ((MobileNode *)thisnode)->getLoc(&x, &y, &z);
00159         gid_  = God::instance()->getMyGrid(x,y);
00160         
00161         // If the msg is not from my grid, ignore it
00162         if (((u_int32_t)gid_) != (u_int32_t)emsg.gid) return;
00163 
00164 
00165         switch (emsg.state) {
00166 
00167         case GAF_LEADER:
00168 
00169           // I receives a "whoami" msg from the leader in this grid
00170           // I am supposed to discard if I am in GAF_LEADER
00171           // state too, or put myself into sleep if I am in GAF_FREE
00172           
00173           switch (state_) {
00174           case GAF_LEADER:
00175 
00176             ttl = (int)(leader_settime_ - NOW);
00177             if (ttl < 0) ttl = 0;
00178 
00179             if ( ((u_int32_t)ttl) > (u_int32_t) emsg.ttl) {
00180                   //supress the partner
00181                   send_discovery();
00182                   return; 
00183             
00184             } else {
00185                   if (((u_int32_t)ttl) == emsg.ttl && (u_int32_t)nid_ < emsg.nid) {
00186                       send_discovery();
00187                       return;
00188                   }
00189                   // from LEADER to SLEEP, cancel my timer
00190                   stimer_.force_cancel();
00191                   leader_settime_ = 0;
00192 
00193                   // turn off my self
00194                   schedule_wakeup(emsg);
00195             }
00196 
00197             break;
00198           
00199           case GAF_FREE:
00200             schedule_wakeup(emsg);
00201 
00202             break;
00203           default:
00204             break;
00205 
00206           }
00207 
00208           break;
00209         case GAF_FREE:
00210           if (state_ == GAF_FREE) {
00211               if ((ttl = (int)myttl()) > MIN_LIFETIME) {
00212                  ttl = ttl/2;
00213               }
00214     
00215               if ( ttl > (int)emsg.ttl) {
00216                   //supress other node
00217                   send_discovery();
00218                   return; 
00219               } else {
00220                   if ((u_int32_t)ttl == emsg.ttl && (u_int32_t)nid_ < emsg.nid) {
00221                       send_discovery();
00222                       return;
00223                   }
00224     
00225                   schedule_wakeup(emsg);
00226 
00227               }             
00228           }
00229           
00230           if (state_ == GAF_LEADER) {
00231               send_discovery();
00232           }
00233 
00234           break;
00235         default:
00236           printf("%d gets wrong discovery msg\n",nid_ );;
00237           break;
00238         }
00239 
00240 }

Here is the call graph for this function:

void NsObject::recv Packet p,
const char *  s
[virtual, inherited]
 

Reimplemented in CMUTrace.

Definition at line 96 of file object.cc.

References Packet::free().

00097 {
00098         Packet::free(p);
00099 }

Here is the call graph for this function:

void GAFAgent::recv Packet ,
Handler
[virtual]
 

Reimplemented from Agent.

Definition at line 92 of file gaf.cc.

References hdr_gaf::access(), Packet::free(), GAF_DISCOVER, GAF_SLEEP, processDiscoveryMsg(), state_, and hdr_gaf::type_.

00093 {
00094         hdr_gaf *gafh = hdr_gaf::access(p);
00095 
00096         switch (gafh->type_) {
00097 
00098         case GAF_DISCOVER:
00099 
00100           if (state_ != GAF_SLEEP)
00101               processDiscoveryMsg(p);
00102           Packet::free(p);
00103           break;
00104 
00105         default:
00106           Packet::free(p);
00107           break;
00108         }
00109 }

Here is the call graph for this function:

void Agent::recvBytes int  bytes  )  [protected, virtual, inherited]
 

Definition at line 354 of file agent.cc.

References Agent::app_, and Application::recv().

Referenced by DelAckSink::recv(), TcpSink::recv(), QSTcpSink::recv(), FullTcpAgent::recv(), and TcpAsymSink::recv().

00355 {
00356         if (app_)
00357                 app_->recv(nbytes);     
00358 }

Here is the call graph for this function:

void Agent::recvOnly Packet  )  [inline, virtual, inherited]
 

Reimplemented from NsObject.

Definition at line 78 of file agent.h.

00078 {};

void NsObject::reset  )  [protected, virtual, inherited]
 

Reimplemented in BayFullTcpAgent, HashClassifier, IvsSource, dsREDQueue, DiffusionRate, SinkAgent, DiffusionAgent, FloodingAgent, OmniMcastAgent, LinkDelay, CBQueue, DropTail, ErrorModel, PIQueue, Queue< T >, RedPDQueue, REDQueue, REMQueue, RIOQueue, Snoop, FackTcpAgent, FullTcpAgent, SackFullTcpAgent, RFC793eduTcpAgent, Sack1TcpAgent, TcpSink, DelAckSink, TcpAgent, VegasTcpAgent, toraAgent, and Queue< T >.

Definition at line 70 of file object.cc.

Referenced by NsObject::command().

00071 {
00072 }

void GAFAgent::schedule_wakeup struct  DiscoveryMsg  )  [protected]
 

Definition at line 242 of file gaf.cc.

References adapt_mobility_, dtimer_, MIN_TURNOFFTIME, node_off(), TimerHandler::resched(), DiscoveryMsg::stime, DiscoveryMsg::ttl, and Random::uniform().

Referenced by processDiscoveryMsg().

00242                                                        {
00243 
00244   int waketime;
00245   waketime = emsg.ttl;
00246  
00247   // control whether using mobility adaption
00248   if (adapt_mobility_ > 0 ) {
00249       if (emsg.stime < emsg.ttl) waketime = emsg.stime;
00250   }
00251 
00252   // node does not go switch to sleep if the lifetime
00253   // it senses is less than MIN_SWITCHTIME
00254 
00255   if (waketime > MIN_TURNOFFTIME ) { 
00256      node_off();
00257      dtimer_.resched(Random::uniform(waketime/2, waketime)); 
00258   }
00259 }

Here is the call graph for this function:

virtual void Agent::send int  nbytes  )  [inline, virtual, inherited]
 

Reimplemented in SRMAgent.

Definition at line 89 of file agent.h.

References Agent::sendmsg().

00089 { sendmsg(nbytes); }

Here is the call graph for this function:

virtual void Agent::send int  sz,
AppData data
[inline, virtual, inherited]
 

Reimplemented in HttpInvalAgent.

Definition at line 84 of file agent.h.

References Agent::sendmsg().

00084 { sendmsg(sz, data, 0); }

Here is the call graph for this function:

void Agent::send Packet p,
Handler h
[inline, inherited]
 

Reimplemented from Connector.

Definition at line 80 of file agent.h.

References NsObject::recv(), and Connector::target_.

Referenced by TcpSink::ack(), QSTcpSink::ack(), SinkAgent::bcast_interest(), PingAgent::command(), MessageAgent::command(), mcastControlAgent::command(), LmsAgent::command(), LDPAgent::command(), SinkAgent::data_ready(), DSDV_Agent::forwardPacket(), FullTcpAgent::foutput(), TcpAgent::output(), VegasTcpAgent::output(), RFC793eduTcpAgent::output(), QSNewRenoTcpAgent::output(), IntTcpAgent::output(), BayFullTcpAgent::output(), AbsTcpAgent::output(), AbsDelAckSink::recv(), AbsTcpSink::recv(), SRAgent::recv(), PingAgent::recv(), NatAgent::recv(), MIPBSAgent::recv(), Encapsulator::recv(), Decapsulator::recv(), MIPMHAgent::reg(), HttpInvalAgent::send(), send_discovery(), RapAgent::SendAck(), SimpleTcpAgent::sendmsg(), PushbackAgent::sendMsg(), FullTcpAgent::sendpacket(), BayFullTcpAgent::sendpacket(), RapAgent::SendPacket(), TfrcAgent::sendpkt(), TfrcSinkAgent::sendpkt(), SinkAgent::sendpkt(), IcmpAgent::sendredirect(), and AbsDelAckSink::timeout().

00080 { target_->recv(p, h); }

Here is the call graph for this function:

void GAFAgent::send_discovery  )  [protected]
 

Definition at line 422 of file gaf.cc.

References hdr_gaf::access(), Agent::allocpkt(), GAF_DISCOVER, God::getMyGrid(), gid_, God::instance(), makeUpDiscoveryMsg(), Agent::send(), seqno_, hdr_gaf::seqno_, thisnode, and hdr_gaf::type_.

Referenced by duty_timeout(), processDiscoveryMsg(), and timeout().

00423 {
00424         Packet *p = allocpkt();
00425         double x=0.0, y=0.0, z=0.0;
00426 
00427         hdr_gaf *h = hdr_gaf::access(p);
00428         //hdr_ip *iph = hdr_ip::access(p);
00429 
00430         h->type_ = GAF_DISCOVER;
00431         h->seqno_ = ++seqno_;
00432 
00433         // update my grid infomation
00434         
00435         ((MobileNode *)thisnode)->getLoc(&x, &y, &z);
00436         gid_ = God::instance()->getMyGrid(x,y);
00437     
00438         makeUpDiscoveryMsg(p);
00439 
00440         send(p,0);
00441 }

Here is the call graph for this function:

void Agent::sendmsg int  nbytes,
const char *  flags = 0
[virtual, inherited]
 

Reimplemented in SA_Agent, RTPAgent, UdpAgent, LmsSender, SRMAgent, FullTcpAgent, TcpAgent, TfrcAgent, and SimpleTcpAgent.

Definition at line 415 of file agent.cc.

00416 {
00417 }

void Agent::sendmsg int  sz,
AppData ,
const char *  flags = 0
[virtual, inherited]
 

Reimplemented in UdpAgent.

Definition at line 400 of file agent.cc.

References abort().

Referenced by Agent::command(), Application::send(), Agent::send(), TrafficTrace::timeout(), TelnetApp::timeout(), EXPOO_Traffic::timeout(), and CBR_PP_Traffic::timeout().

00401 {
00402         fprintf(stderr, 
00403         "Agent::sendmsg(int, AppData*, const char*) not implemented\n");
00404         abort();
00405 }

Here is the call graph for this function:

virtual void Agent::sendto int  nbytes,
const char *  flags,
nsaddr_t  dst
[virtual, inherited]
 

void Agent::sendto int  sz,
AppData ,
const char *  flags,
nsaddr_t  dst
[virtual, inherited]
 

Definition at line 407 of file agent.cc.

References abort().

Referenced by Agent::command().

00409 {
00410         fprintf(stderr, 
00411         "Agent::sendmsg(int, AppData*, const char*) not implemented\n");
00412         abort();
00413 }

Here is the call graph for this function:

void Agent::set_pkttype packet_t  pkttype  )  [inline, inherited]
 

Definition at line 100 of file agent.h.

References Agent::type_.

Referenced by Agent::command(), HttpUInvalClass::create(), RA_Traffic::init(), POO_Traffic::init(), EXPOO_Traffic::init(), CBR_Traffic::init(), and CBR_PP_Traffic::init().

00100 { type_ = pkttype; }

void GAFAgent::setGAFstate GafNodeState   )  [protected]
 

Definition at line 578 of file gaf.cc.

References state_.

Referenced by node_off(), node_on(), and timeout().

00579 {
00580   //printf("Node (%d %d) changes state from %d to %d at %f\n", nid_, gid_, state_,gs,Scheduler::instance().clock());
00581 
00582    state_ = gs;
00583 }

virtual int& Agent::size  )  [inline, virtual, inherited]
 

Reimplemented in FullTcpAgent.

Definition at line 95 of file agent.h.

References Agent::size_.

Referenced by rtProtoDV::command(), RLM_Sender::command(), imepAgent::getResponseListSize(), LandmarkAgent::makeUpdate(), Agent::recv(), SSMSRMAgent::send_glb_sess(), SSMSRMAgent::send_loc_sess(), SSMSRMAgent::send_rep_sess(), SRMAgent::send_sess(), and TelnetApp::timeout().

00095 { return size_; }

NsObject* Connector::target  )  [inline, inherited]
 

Definition at line 48 of file connector.h.

References Connector::target_.

Referenced by JoBS::assignRateDropsADC(), FQ::deque(), QSAgent::recv(), and MIPMHAgent::reg().

00048 { return target_; }

void Agent::timeout int  tno  )  [virtual, inherited]
 

Reimplemented in SA_Agent, RTPAgent, FtpClientAgent, BayFullTcpAgent, SinkAgent, RLM_Sender, MIPBSAgent, MIPMHAgent, RapAgent, RTCPAgent, TcpAsymSink, FackTcpAgent, FullTcpAgent, QSNewRenoTcpAgent, RBPVegasTcpAgent, RBPRenoTcpAgent, SackRHTcpAgent, Sack1TcpAgent, TcpSessionAgent, DelAckSink, TcpAgent, RenoTcpAgent, VegasTcpAgent, and SimpleTcpAgent.

Definition at line 347 of file agent.cc.

Referenced by SimpleTimer::expire().

00348 {
00349 }

void GAFAgent::timeout GafMsgType   ) 
 

Definition at line 282 of file gaf.cc.

References duty_timeout(), GAF_DISCOVER, GAF_DUTY, GAF_FREE, GAF_LEADER, GAF_SELECT, GAF_SLEEP, leader_settime_, MAX_DISCOVERY_TIME, MIN_LIFETIME, myttl(), NOW, TimerHandler::resched(), send_discovery(), setGAFstate(), state_, stimer_, timer_, and Random::uniform().

Referenced by GAFDutyTimer::expire(), GAFSelectTimer::expire(), and GAFDiscoverTimer::expire().

00283 {
00284   
00285   int ttl;
00286 
00287 //printf ("Node (%d %d) get signal %d at %f\n",nid_, gid_, msgt, Scheduler::instance().clock());
00288 
00289     switch (msgt) {
00290     case GAF_DISCOVER:
00291 
00292       switch (state_) {
00293       case GAF_SLEEP:
00294         break;
00295        
00296       case GAF_FREE:
00297 
00298         if ((ttl = (int)myttl()) > MIN_LIFETIME) {
00299                 ttl = (int) ttl/2;
00300         }
00301         
00302         leader_settime_ = (int) (ttl + NOW);  
00303 
00304         // schdule to tell me that I can switch after ttl
00305 
00306         stimer_.resched(ttl); 
00307         
00308         setGAFstate(GAF_LEADER);
00309 
00310         send_discovery();
00311 
00312         //printf ("Node (%d %d) becomes a leader at %f\n",nid_, gid_, Scheduler::instance().clock());
00313 
00314          timer_.resched(Random::uniform(MAX_DISCOVERY_TIME-1,MAX_DISCOVERY_TIME));
00315         
00316         // fall through
00317          break; 
00318 
00319       case GAF_LEADER:
00320 
00321         send_discovery();
00322 
00323         timer_.resched(Random::uniform(MAX_DISCOVERY_TIME-1,MAX_DISCOVERY_TIME));
00324         break;
00325       default:
00326         break;
00327 
00328       }
00329 
00330       break;
00331 
00332     case GAF_SELECT:
00333         switch (state_) {
00334 
00335           case GAF_LEADER:
00336 
00337             // I just finish my LEADER role, put myself into FREE
00338             // state so that I have chance to go sleep
00339             // put myself into FREE does not hurt anything
00340 
00341             //printf("Node (%d %d) go BACK to FREE from LEADER at %f\n",nid_,gid_,Scheduler::instance().clock());
00342 
00343             duty_timeout();
00344 
00345             leader_settime_ = 0;
00346 
00347             break;
00348 
00349           case GAF_FREE:
00350           case GAF_SLEEP:
00351             break;
00352           default:
00353             break;
00354         }
00355         break;
00356     case GAF_DUTY:
00357         duty_timeout();
00358         break;
00359     default:
00360         printf("Wrong GAF msg time!\n");
00361     }
00362 
00363 }

Here is the call graph for this function:

void Agent::trace TracedVar *  v  )  [protected, virtual, inherited]
 

Reimplemented in TcpAgent.

Definition at line 266 of file agent.cc.

References ns_addr_t::addr_, Agent::channel_, Agent::dst_, Agent::here_, Agent::insertOldValue(), Scheduler::instance(), Agent::lookupOldValue(), min, TIME_FORMAT, Agent::traceName_, TRACEVAR_MAXVALUELENGTH, and OldValue::val_.

Referenced by TcpAgent::trace().

00267 {
00268         if (channel_ == 0)
00269                 return;
00270         char wrk[256], value[128];
00271         int n;
00272 
00273         // XXX we need to keep track of old values. What's the best way?
00274         v->value(value, 128);
00275 
00276         // XXX hack: how do I know ns has not started yet?
00277         // if there's nothing in value, return
00278         static int started = 0;
00279         if (!started) {
00280                 Tcl::instance().evalc("[Simulator instance] is-started");
00281                 if (Tcl::instance().result()[0] == '0')
00282                         // Simulator not started, do nothing
00283                         return;
00284                 // remember for next time (so we don't always have to call to tcl)
00285                 started = 1;
00286         };
00287 
00288         OldValue *ov = lookupOldValue(v);
00289         if (ov != NULL) {
00290                 sprintf(wrk, 
00291                         "f -t "TIME_FORMAT" -s %d -d %d -n %s -a %s -v %s -o %s -T v",
00292                         Scheduler::instance().clock(), here_.addr_,
00293                         dst_.addr_, v->name(), traceName_, value, ov->val_);
00294                 strncpy(ov->val_, 
00295                         value,
00296                         min(strlen(value)+1, TRACEVAR_MAXVALUELENGTH));
00297         } else {
00298                 // if there is value, insert it into old value list
00299                 sprintf(wrk, "f -t "TIME_FORMAT" -s %d -d %d -n %s -a %s -v %s -T v",
00300                         Scheduler::instance().clock(), here_.addr_,
00301                         dst_.addr_, v->name(), traceName_, value);
00302                 insertOldValue(v, value);
00303         }
00304         n = strlen(wrk);
00305         wrk[n] = '\n';
00306         wrk[n+1] = 0;
00307         (void)Tcl_Write(channel_, wrk, n+1);
00308 }

Here is the call graph for this function:

virtual void Agent::trace_event char *  eventtype  )  [inline, protected, virtual, inherited]
 

Reimplemented in TcpAgent.

Definition at line 146 of file agent.h.

00146 {}


Member Data Documentation

int GAFAgent::adapt_mobility_ [protected]
 

Definition at line 156 of file gaf.h.

Referenced by command(), and schedule_wakeup().

Application* Agent::app_ [protected, inherited]
 

Reimplemented in BayFullTcpAgent.

Definition at line 134 of file agent.h.

Referenced by Agent::attachApp(), Agent::idle(), RapAgent::IpgTimeout(), UdpAgent::recv(), SimpleTcpAgent::recv(), RapAgent::recv(), HttpInvalAgent::recv(), Agent::recv(), and Agent::recvBytes().

double GAFAgent::beacon_ [protected]
 

Definition at line 142 of file gaf.h.

Tcl_Channel Agent::channel_ [protected, inherited]
 

Definition at line 130 of file agent.h.

Referenced by Agent::addAgentTrace(), Agent::command(), Agent::flushAVar(), Agent::monitorAgentTrace(), TcpAsymSink::recv(), Agent::trace(), TcpAgent::traceAll(), TcpAsymAgent::traceAll(), TcpAgent::traceVar(), TcpSessionAgent::traceVar(), and TcpAsymAgent::traceVar().

int NsObject::debug_ [protected, inherited]
 

Reimplemented in FECModel, FloodAgent, and LandmarkAgent.

Definition at line 66 of file object.h.

Referenced by REDQueue::command(), RedPDQueue::command(), PushbackQueue::command(), NsObject::debug(), NsObject::delay_bind_dispatch(), RedPDQueue::enque(), PushbackQueue::enque(), NsObject::isdebug(), NsObject::NsObject(), TfrcAgent::recv(), PushbackQueue::reportDrop(), and REDQueue::reset().

int Agent::defttl_ [protected, inherited]
 

Definition at line 121 of file agent.h.

Referenced by Agent::delay_bind_dispatch(), and Agent::initpkt().

NsObject* Connector::drop_ [protected, inherited]
 

Definition at line 57 of file connector.h.

Referenced by Connector::command(), Connector::drop(), and ErrorModel::recv().

ns_addr_t Agent::dst_ [protected, inherited]
 

Reimplemented in AckRecons.

Definition at line 115 of file agent.h.

Referenced by Agent::addAgentTrace(), Agent::daddr(), Agent::delay_bind_dispatch(), Agent::deleteAgentTrace(), Agent::dport(), DSRProto::DSRProto(), Agent::flushAVar(), Agent::initpkt(), SRMAgent::recv(), SSMSRMAgent::recv(), NatAgent::recv(), SRMAgent::sendmsg(), PushbackAgent::sendMsg(), and Agent::trace().

GAFDutyTimer GAFAgent::dtimer_ [protected]
 

Definition at line 147 of file gaf.h.

Referenced by schedule_wakeup().

EventTrace* Agent::et_ [protected, inherited]
 

Definition at line 145 of file agent.h.

Referenced by TcpAgent::command(), and TcpAgent::trace_event().

int Agent::fid_ [protected, inherited]
 

Definition at line 118 of file agent.h.

Referenced by Agent::delay_bind_dispatch(), AbsTcpAgent::flowid(), Agent::initpkt(), FullTcpAgent::recv(), CtrMcastEncap::recv(), AbsTcpAgent::send_batch(), Sack1TcpAgent::timeout(), and TcpAgent::trace_event().

int Agent::flags_ [protected, inherited]
 

Reimplemented in BayFullTcpAgent, RapAgent, and FullTcpAgent.

Definition at line 120 of file agent.h.

Referenced by Agent::delay_bind_dispatch().

int GAFAgent::gid_ [protected]
 

Definition at line 149 of file gaf.h.

Referenced by duty_timeout(), GAFAgent(), makeUpDiscoveryMsg(), processDiscoveryMsg(), and send_discovery().

ns_addr_t Agent::here_ [protected, inherited]
 

Definition at line 114 of file agent.h.

Referenced by Agent::addAgentTrace(), Agent::addr(), SinkAgent::bcast_interest(), SinkAgent::data_ready(), OmniMcastAgent::DataForSink(), FloodingAgent::DataForSink(), DiffusionAgent::DataForSink(), Agent::delay_bind_dispatch(), Agent::deleteAgentTrace(), DiffusionProb::ForwardData(), DiffusionProb::ForwardTxFailed(), DiffusionRate::FwdOriginal(), DiffusionProb::FwdPosReinf(), DiffusionRate::FwdSubsample(), OmniMcastAgent::GodForwardData(), Agent::initpkt(), OmniMcastAgent::MACprepare(), FloodingAgent::MACprepare(), DiffusionAgent::MACprepare(), Agent::monitorAgentTrace(), Agent::port(), OmniMcastAgent::prepare_message(), FloodingAgent::prepare_message(), DiffusionAgent::prepare_message(), SSMSRMAgent::recv(), PingAgent::recv(), NatAgent::recv(), DumbAgent::recv(), SinkAgent::sendpkt(), SinkAgent::set_addr(), SinkAgent::Terminate(), and Agent::trace().

int GAFAgent::leader_settime_ [protected]
 

Definition at line 155 of file gaf.h.

Referenced by makeUpDiscoveryMsg(), processDiscoveryMsg(), and timeout().

int GAFAgent::maxttl_ [protected]
 

Definition at line 152 of file gaf.h.

Referenced by command().

int GAFAgent::nid_ [protected]
 

Definition at line 150 of file gaf.h.

Referenced by GAFAgent(), makeUpDiscoveryMsg(), nodeid(), and processDiscoveryMsg().

OldValue* Agent::oldValueList_ [protected, inherited]
 

Definition at line 132 of file agent.h.

Referenced by Agent::insertOldValue(), Agent::lookupOldValue(), and Agent::~Agent().

int Agent::prio_ [protected, inherited]
 

Definition at line 119 of file agent.h.

Referenced by Agent::delay_bind_dispatch(), and Agent::initpkt().

int GAFAgent::randomflag_ [protected]
 

Definition at line 144 of file gaf.h.

int GAFAgent::seqno_ [protected]
 

Definition at line 148 of file gaf.h.

Referenced by GAFAgent(), and send_discovery().

int Agent::size_ [protected, inherited]
 

Reimplemented in SA_Agent, and AckRecons.

Definition at line 116 of file agent.h.

Referenced by AbsDelAckSink::AbsDelAckSink(), AbsTcpAgent::AbsTcpAgent(), AbsTcpRenoAckAgent::AbsTcpRenoAckAgent(), AbsTcpRenoDelAckAgent::AbsTcpRenoDelAckAgent(), AbsTcpSink::AbsTcpSink(), AbsTcpTahoeAckAgent::AbsTcpTahoeAckAgent(), AbsTcpTahoeDelAckAgent::AbsTcpTahoeDelAckAgent(), RTCPAgent::command(), LDPAgent::command(), SinkAgent::command(), IntTcpAgent::createTcpSession(), TfrcAgent::decrease_rate(), TcpAgent::delay_bind_dispatch(), TcpSink::delay_bind_dispatch(), FullTcpAgent::foutput(), DSRAgent::getRouteForPacket(), TfrcAgent::increase_rate(), TcpAgent::initial_window(), Agent::initpkt(), RapAgent::IpgTimeout(), IvsReceiver::IvsReceiver(), LmsAgent::LmsAgent(), LmsReceiver::LmsReceiver(), mcastControlAgent::mcastControlAgent(), MessageAgent::MessageAgent(), MIPBSAgent::MIPBSAgent(), MIPMHAgent::MIPMHAgent(), TfrcAgent::nextpkt(), IntTcpAgent::opencwnd(), PingAgent::PingAgent(), RapAgent::RapAgent(), TfrcAgent::recv(), TcpSessionAgent::recv(), NewRenoTcpAgent::recv(), TfrcAgent::reduce_rate_on_no_feedback(), RLM_Sender::RLM_Sender(), RTCPAgent::RTCPAgent(), RTPAgent::RTPAgent(), IntTcpAgent::rxmit_last(), LmsSender::send_lms_pkt(), TcpSessionAgent::send_much(), LmsReceiver::send_nak(), IntTcpAgent::send_one(), LmsReceiver::send_refresh(), UdpAgent::sendmsg(), TfrcAgent::sendmsg(), TcpAgent::sendmsg(), SRMAgent::sendmsg(), RTPAgent::sendmsg(), RapAgent::SendPacket(), TfrcAgent::sendpkt(), rtProtoDV::sendpkt(), SinkAgent::sendpkt(), SinkAgent::SinkAgent(), Agent::size(), TfrcAgent::slowstart(), TfrcAgent::start(), TfrcAgent::TfrcAgent(), TfrcSinkAgent::TfrcSinkAgent(), RTPAgent::timeout(), RTCPAgent::timeout(), and UdpAgent::UdpAgent().

GafNodeState GAFAgent::state_ [protected]
 

Definition at line 154 of file gaf.h.

Referenced by makeUpDiscoveryMsg(), processDiscoveryMsg(), recv(), setGAFstate(), and timeout().

GAFSelectTimer GAFAgent::stimer_ [protected]
 

Definition at line 146 of file gaf.h.

Referenced by processDiscoveryMsg(), and timeout().

NsObject* Connector::target_ [protected, inherited]
 

Definition at line 56 of file connector.h.

Referenced by SRAgent::command(), SA_Agent::command(), IvsReceiver::command(), MultiFieldFilter::command(), Filter::command(), Connector::command(), DiffusionAgent::DiffusionAgent(), DSRAgent::DSRAgent(), PromotionTimer::expire(), FloodingAgent::FloodingAgent(), toraAgent::forward(), AODV::forward(), LandmarkAgent::ForwardPacket(), DSDV_Agent::forwardPacket(), SensorQueryAgent::generate_query(), DSDVTriggerHandler::handle(), AckRecons::handle(), DSRAgent::handlePacketReceipt(), DSDV_Agent::helper_callback(), AODV::initialized(), DSDV_Agent::lost_link(), OmniMcastAgent::OmniMcastAgent(), LandmarkAgent::periodic_callback(), LandmarkAgent::ProcessHierUpdate(), TCPTapAgent::processpkt(), IPTapAgent::processpkt(), CMUPriQueue::prq_enqueue(), CMUPriQueue::prq_resume(), DequeTrace::recv(), Trace::recv(), TraceIpMac::recv(), TraceIp::recv(), TBF::recv(), SRMAgent::recv(), SSMSRMAgent::recv(), SatDequeTrace::recv(), SAack_Agent::recv(), Queue< T >::recv(), PingResponder::recv(), MIPEncapsulator::recv(), LmsAgent::recv(), HackLossyLink::recv(), GAFPartner::recv(), FQ::recv(), FloodAgent::recv(), ErrorModel::recv(), DynamicLink::recv(), DumbAgent::recv(), DSRAgent::recv(), DelayModel::recv(), LinkDelay::recv(), CtrMcastDecap::recv(), CtrMcastEncap::recv(), CMUTrace::recv(), PriQueue::recvHighPriority(), Trace::recvOnly(), TapAgent::recvpkt(), Queue< T >::resume(), LinkDelay::send(), Connector::send(), Agent::send(), MIPBSAgent::send_ads(), SRMAgent::send_ctrl(), SSMSRMAgent::send_ctrl(), MFTPSndAgent::send_data(), LmsSender::send_dmcast(), LmsReceiver::send_dmcast(), LmsAgent::send_downstream(), SSMSRMAgent::send_glb_sess(), LmsSender::send_lms_pkt(), SSMSRMAgent::send_loc_sess(), MFTPRcvAgent::send_nak(), LmsReceiver::send_nak(), LmsReceiver::send_refresh(), SSMSRMAgent::send_rep_sess(), SRMAgent::send_sess(), MIPMHAgent::send_sols(), LmsSender::send_spm(), MFTPSndAgent::send_status_request(), LmsAgent::send_upstream(), LandmarkAgent::SendChangedTagListUpdate(), AODV::sendError(), AODV::sendHello(), UdpAgent::sendmsg(), SRMAgent::sendmsg(), SA_Agent::sendmsg(), RTPAgent::sendmsg(), LmsSender::sendmsg(), DSDV_Agent::sendOutBCastPkt(), SA_Agent::sendpkt(), rtProtoDV::sendpkt(), RTPAgent::sendpkt(), RTCPAgent::sendpkt(), IvsSource::sendpkt(), AODV::sendReply(), AODV::sendRequest(), LmsSender::solicit_naks(), Connector::target(), TBF::timeout(), and toraAgent::tora_output().

Node* GAFAgent::thisnode [protected]
 

Definition at line 151 of file gaf.h.

Referenced by duty_timeout(), GAFAgent(), makeUpDiscoveryMsg(), myttl(), node_off(), node_on(), processDiscoveryMsg(), and send_discovery().

GAFDiscoverTimer GAFAgent::timer_ [protected]
 

Definition at line 145 of file gaf.h.

Referenced by command(), duty_timeout(), and timeout().

char* Agent::traceName_ [protected, inherited]
 

Definition at line 131 of file agent.h.

Referenced by Agent::addAgentTrace(), Agent::command(), Agent::deleteAgentTrace(), Agent::flushAVar(), Agent::monitorAgentTrace(), and Agent::trace().

packet_t Agent::type_ [protected, inherited]
 

Definition at line 117 of file agent.h.

Referenced by Agent::get_pkttype(), Agent::initpkt(), FullTcpAgent::listen(), BayFullTcpAgent::listen(), RapAgent::SendAck(), SRMAgent::sendmsg(), RapAgent::SendPacket(), and Agent::set_pkttype().

int Agent::uidcnt_ [static, protected, inherited]
 

Definition at line 68 of file agent.cc.

Referenced by imepAgent::handlerControlTimer(), imepAgent::handlerReXmitTimer(), Agent::initpkt(), imepAgent::sendAck(), imepAgent::sendBeacon(), toraAgent::sendCLR(), imepAgent::sendHello(), toraAgent::sendQRY(), DSRAgent::sendUnknownFlow(), toraAgent::sendUPD(), and DSRAgent::xmitFailed().


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