⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 trace.cc.cc

📁 在网络的边缘路由器中并不能完全接受所到的包
💻 CC
📖 第 1 页 / 共 2 页
字号:
			tcph->flags(),
			tcph->hlen(),
			tcph->sa_length());
	}

        // begin archanakrishna 
      
           hdr_cmn* hdr = (hdr_cmn*)p->access(off_cmn_);

           // This part of code should be included only when the egress
           // router is congested using crosstraffic src2

           if(congest1_ == 1)
           {
              if(src_nodeaddr[0] == '3') 
              {
                if((s == 4)&&(s < d)&&(tt == '+'))
                {
                   double now = round(Scheduler::instance().clock());
                   hdr->arrivaltimestamp() = now;
                }
              }
              else
              {
                 if((hdr->pktingressnode() == s)&&(s < d)&&(tt == '+'))
                 {
                    double now = round(Scheduler::instance().clock());
                    hdr->arrivaltimestamp() = now;
                 }
              }
           }
            
           if(congest1_ == 0)
           {
             if((hdr->pktingressnode() == s)&&(s < d)&&(tt == '+'))
             {
                double now = round(Scheduler::instance().clock());
                hdr->arrivaltimestamp() = now;
             }
           }
        // end archanakrishna  


        // begin archanakrishna

             // This part of code should be included only when the ingress
             // router is congested using crosstraffic src1

             if(congest2_ == 2)
             {
               if(src_nodeaddr[0] == '0')
               {
                 if((s == 3)&&(s < d)&&(tt == '-'))
                 {
                   double now1 = hdr->arrivaltimestamp();
                   double now2 = round(Scheduler::instance().clock());
                   double diff = now2 - now1;
                   double servicetime = now1 + diff;
                   hdr->servicetimestamp() = servicetime;
                   ++snoopqueuecount;
                   measure[snoopqueuecount].createPacketinfolist(p);
                 }
               }
               else
               {
                  if((hdr->pktegressnode() == s)&&(s < d)&&(tt == '-')) 
                  {
                    double now1 = hdr->arrivaltimestamp();
                    double now2 = round(Scheduler::instance().clock());
                    double diff = now2 - now1;
                    double servicetime = now1 + diff;
                    hdr->servicetimestamp() = servicetime;
                    ++snoopqueuecount;
                    measure[snoopqueuecount].createPacketinfolist(p);
                  }
               }
             } 

             if(congest2_ == 0)
             { 
                if((hdr->pktegressnode() == s)&&(s < d)&&(tt == '-'))
                {
                   double now1 = hdr->arrivaltimestamp();
                   double now2 = round(Scheduler::instance().clock());
                   double diff = now2 - now1;
                   double servicetime = now1 + diff;
                   hdr->servicetimestamp() = servicetime;
                   ++snoopqueuecount;
                   measure[snoopqueuecount].createPacketinfolist(p);
                }
             }
        // end archanakrishna


#ifdef NAM_TRACE
	if (namChan_ != 0)
		sprintf(nwrk_, 
			"%c -t %g -s %d -d %d -p %s -e %d -c %d -i %d -a %d -x {%s%s %s%s %d %s %s}",
			tt,
			Scheduler::instance().clock(),
			s,
 			d,
			name,
			th->size(),
			iph->flowid(),
			th->uid(),
			iph->flowid(),
			src_nodeaddr,
			src_portaddr,
			dst_nodeaddr,
			dst_portaddr,
			seqno,flags,sname);
#endif      
	delete [] src_nodeaddr;
  	delete [] src_portaddr;
  	delete [] dst_nodeaddr;
   	delete [] dst_portaddr;
}

void Trace::dump()
{
	int n = strlen(wrk_);
	if ((n > 0) && (channel_ != 0)) {
		/*
		 * tack on a newline (temporarily) instead
		 * of doing two writes
		 */
		wrk_[n] = '\n';
		wrk_[n + 1] = 0;
		(void)Tcl_Write(channel_, wrk_, n + 1);
		wrk_[n] = 0;
	}

	if (callback_) {
		Tcl& tcl = Tcl::instance();
		tcl.evalf("%s handle { %s }", name(), wrk_);
	}
}

#ifdef NAM_TRACE
void Trace::namdump()
{
	int n = 0;

	/* Otherwise nwrk_ isn't initialized */
	if (namChan_ != 0)
		n = strlen(nwrk_);
	if ((n > 0) && (namChan_ != 0)) {
		/*
		 * tack on a newline (temporarily) instead
		 * of doing two writes
		 */
		nwrk_[n] = '\n';
		nwrk_[n + 1] = 0;
		(void)Tcl_Write(namChan_, nwrk_, n + 1);
		nwrk_[n] = 0;
	}
}
#endif

void Trace::recv(Packet* p, Handler* h)
{

	format(type_, src_, dst_, p);
	dump();
	namdump();
	/* hack: if trace object not attached to anything free packet */
	if (target_ == 0)
		Packet::free(p);
	else
		send(p, h);
}


void Trace::trace(TracedVar* var)
{
	char tmp[256] = "";
	Scheduler& s = Scheduler::instance();
	if (&s == 0)
		return;

	// format: use Mark's nam feature code without the '-' prefix
	sprintf(wrk_, "%c t%g a%s n%s v%s",
		type_,
		round(s.clock()),
		var->owner()->name(),
		var->name(),
		var->value(tmp));
	dump();
}

//
// we need a DequeTraceClass here because a 'h' event need to go together
// with the '-' event. It's possible to use a postprocessing script, but 
// seems that's inconvient.
//
static class DequeTraceClass : public TclClass {
public:
	DequeTraceClass() : TclClass("Trace/Deque") { }
	TclObject* create(int args, const char*const* argv) {
		if (args >= 5)
			return (new DequeTrace(*argv[4]));
		return NULL;
	}
} dequetrace_class;


DequeTrace::~DequeTrace()
{
}

void 
DequeTrace::recv(Packet* p, Handler* h)
{
	// write the '-' event first
	format(type_, src_, dst_, p);
	dump();
	namdump();

#ifdef NAM_TRACE
	if (namChan_ != 0) {
#ifdef OFF_HDR
		hdr_cmn *th = (hdr_cmn*)p->access(off_cmn_);
		hdr_ip *iph = (hdr_ip*)p->access(off_ip_);
		hdr_srm *sh = (hdr_srm*)p->access(off_srm_);
#else
		hdr_cmn *th = hdr_cmn::access(p);
		hdr_ip *iph = hdr_ip::access(p);
		hdr_srm *sh = hdr_srm::access(p);
#endif
		const char* sname = "null";   

		packet_t t = th->ptype();
		const char* name = packet_info.name(t);
		
		if (strcmp(name,"SRM") == 0 || strcmp(name,"cbr") == 0 || strcmp(name,"udp") == 0) {
		    if ( sh->type() < 5 && sh->type() > 0  ) {
		        sname = srm_names[sh->type()];
		    }
		}   

		char *src_nodeaddr = Address::instance().print_nodeaddr(iph->src());
		char *src_portaddr = Address::instance().print_portaddr(iph->src());
		char *dst_nodeaddr = Address::instance().print_nodeaddr(iph->dst());
		char *dst_portaddr = Address::instance().print_portaddr(iph->dst());

		char flags[NUMFLAGS+1];
		for (int i = 0; i < NUMFLAGS; i++)
			flags[i] = '-';
		flags[NUMFLAGS] = 0;

#ifdef OFF_HDR
		hdr_flags* hf = (hdr_flags*)p->access(off_flags_);
#else
		hdr_flags* hf = hdr_flags::access(p);
#endif
		flags[0] = hf->ecn_ ? 'C' : '-';          // Ecn Echo
		flags[1] = hf->pri_ ? 'P' : '-'; 
		flags[2] = '-';
		flags[3] = hf->cong_action_ ? 'A' : '-';   // Congestion Action
		flags[4] = hf->ecn_to_echo_ ? 'E' : '-';   // Congestion Experienced
		flags[5] = hf->fs_ ? 'F' : '-';
		flags[6] = hf->ecn_capable_ ? 'N' : '-';
	
#ifdef notdef
		flags[1] = (iph->flags() & PF_PRI) ? 'P' : '-';
		flags[2] = (iph->flags() & PF_USR1) ? '1' : '-';
		flags[3] = (iph->flags() & PF_USR2) ? '2' : '-';
		flags[5] = 0;
#endif
		
		sprintf(nwrk_, 
			"%c -t %g -s %d -d %d -p %s -e %d -c %d -i %d -a %d -x {%s%s %s%s %d %s %s}",
			'h',
			Scheduler::instance().clock(),
			src_,
  			dst_,
			name,
			th->size(),
			iph->flowid(),
			th->uid(),
			iph->flowid(),
			src_nodeaddr,
			src_portaddr,
			dst_nodeaddr,
			dst_portaddr,
			-1, flags, sname);
		namdump();
		delete [] src_nodeaddr;
		delete [] src_portaddr;
		delete [] dst_nodeaddr;
		delete [] dst_portaddr;
	}
#endif

	/* hack: if trace object not attached to anything free packet */
	if (target_ == 0)
		Packet::free(p);
	else
		send(p, h);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -