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

📄 cmu-trace.cc

📁 Low Rate Wireless Personal Area Networks (LR-WPANs)in C
💻 CC
📖 第 1 页 / 共 3 页
字号:
		srh->reply_addrs()[0].addr,		srh->reply_addrs()[srh->route_reply_len()-1].addr,		srh->route_error(),		srh->num_route_errors(),		srh->down_links()[srh->num_route_errors() - 1].tell_addr,		srh->down_links()[srh->num_route_errors() - 1].from_addr,		srh->down_links()[srh->num_route_errors() - 1].to_addr);	   return;	}	sprintf(pt_->buffer() + offset, 		"%d [%d %d] [%d %d %d %d->%d] [%d %d %d %d->%d]",		srh->num_addrs(),		srh->route_request(),		srh->rtreq_seq(),		srh->route_reply(),		srh->rtreq_seq(),		srh->route_reply_len(),		// the dest of the src route		srh->reply_addrs()[0].addr,		srh->reply_addrs()[srh->route_reply_len()-1].addr,		srh->route_error(),		srh->num_route_errors(),		srh->down_links()[srh->num_route_errors() - 1].tell_addr,		srh->down_links()[srh->num_route_errors() - 1].from_addr,		srh->down_links()[srh->num_route_errors() - 1].to_addr);}voidCMUTrace::format_msg(Packet *, int){}voidCMUTrace::format_tcp(Packet *p, int offset){	struct hdr_cmn *ch = HDR_CMN(p);	struct hdr_tcp *th = HDR_TCP(p);		if (pt_->tagged()) {	    sprintf(pt_->buffer() + offset,		    "-tcp:s %d -tcp:a %d -tcp:f %d -tcp:o %d ",		    th->seqno_,		    th->ackno_,		    ch->num_forwards(),		    ch->opt_num_forwards());	} else if (newtrace_) {	    sprintf(pt_->buffer() + offset,		"-Pn tcp -Ps %d -Pa %d -Pf %d -Po %d ",		th->seqno_,		th->ackno_,		ch->num_forwards(),		ch->opt_num_forwards());	} else {	    sprintf(pt_->buffer() + offset,		"[%d %d] %d %d",		th->seqno_,		th->ackno_,		ch->num_forwards(),		ch->opt_num_forwards());	}}voidCMUTrace::format_rtp(Packet *p, int offset){	struct hdr_cmn *ch = HDR_CMN(p);	struct hdr_rtp *rh = HDR_RTP(p);	struct hdr_ip *ih = HDR_IP(p);        Node* thisnode = Node::get_node_by_address(src_);	//hacking, needs to change later,         int dst = Address::instance().get_nodeaddr(ih->daddr());		if (dst == src_){		// I just received a cbr data packet		if (thisnode->energy_model() && 		    thisnode->energy_model()->powersavingflag()) {			thisnode->energy_model()->set_node_state(EnergyModel::INROUTE);		}        }	if (pt_->tagged()) {		sprintf(pt_->buffer() + offset,			"-cbr:s %d -cbr:f %d -cbr:o %d ",			rh->seqno_,			ch->num_forwards(),			ch->opt_num_forwards());	} else if (newtrace_) {		sprintf(pt_->buffer() + offset,			"-Pn cbr -Pi %d -Pf %d -Po %d ",			rh->seqno_,			ch->num_forwards(),			ch->opt_num_forwards());	} else {		sprintf(pt_->buffer() + offset,			"[%d] %d %d",			rh->seqno_,			ch->num_forwards(),			ch->opt_num_forwards());	}}voidCMUTrace::format_imep(Packet *p, int offset){        struct hdr_imep *im = HDR_IMEP(p);#define U_INT16_T(x)    *((u_int16_t*) &(x))	if (pt_->tagged()) {	    sprintf(pt_->buffer() + offset,		    "-imep:a %c -imep:h %c -imep:o %c -imep:l %04x ",		    (im->imep_block_flags & BLOCK_FLAG_ACK) ? 'A' : '-',                    (im->imep_block_flags & BLOCK_FLAG_HELLO) ? 'H' : '-',                    (im->imep_block_flags & BLOCK_FLAG_OBJECT) ? 'O' : '-',                    U_INT16_T(im->imep_length));	} else if (newtrace_) {	    sprintf(pt_->buffer() + offset,                "-P imep -Pa %c -Ph %c -Po %c -Pl 0x%04x ] ",                (im->imep_block_flags & BLOCK_FLAG_ACK) ? 'A' : '-',                (im->imep_block_flags & BLOCK_FLAG_HELLO) ? 'H' : '-',                (im->imep_block_flags & BLOCK_FLAG_OBJECT) ? 'O' : '-',                U_INT16_T(im->imep_length));	} else {            sprintf(pt_->buffer() + offset,                "[%c %c %c 0x%04x] ",                (im->imep_block_flags & BLOCK_FLAG_ACK) ? 'A' : '-',                (im->imep_block_flags & BLOCK_FLAG_HELLO) ? 'H' : '-',                (im->imep_block_flags & BLOCK_FLAG_OBJECT) ? 'O' : '-',                U_INT16_T(im->imep_length));	}#undef U_INT16_T}voidCMUTrace::format_tora(Packet *p, int offset){        struct hdr_tora *th = HDR_TORA(p);        struct hdr_tora_qry *qh = HDR_TORA_QRY(p);        struct hdr_tora_upd *uh = HDR_TORA_UPD(p);        struct hdr_tora_clr *ch = HDR_TORA_CLR(p);        switch(th->th_type) {        case TORATYPE_QRY:		if (pt_->tagged()) {		    sprintf(pt_->buffer() + offset,			    "-tora:t %x -tora:d %d -tora:c QUERY",			    qh->tq_type, qh->tq_dst);		} else if (newtrace_) {		    sprintf(pt_->buffer() + offset,			"-P tora -Pt 0x%x -Pd %d -Pc QUERY ",                        qh->tq_type, qh->tq_dst);			                } else {                    sprintf(pt_->buffer() + offset, "[0x%x %d] (QUERY)",                        qh->tq_type, qh->tq_dst);		}                break;        case TORATYPE_UPD:		if (pt_->tagged()) {		    sprintf(pt_->buffer() + offset,			    "-tora:t %x -tora:d %d -tora:a %f -tora:o %d "			    "-tora:r %d -tora:e %d -tora:i %d -tora:c UPDATE",			    uh->tu_type,                            uh->tu_dst,                            uh->tu_tau,                            uh->tu_oid,                            uh->tu_r,                            uh->tu_delta,                            uh->tu_id);		} else if (newtrace_) {		    sprintf(pt_->buffer() + offset,                        "-P tora -Pt 0x%x -Pd %d (%f %d %d %d %d) -Pc UPDATE ",                        uh->tu_type,                        uh->tu_dst,                        uh->tu_tau,                        uh->tu_oid,                        uh->tu_r,                        uh->tu_delta,                        uh->tu_id);		} else {                    sprintf(pt_->buffer() + offset,                        "-Pt 0x%x -Pd %d -Pa %f -Po %d -Pr %d -Pe %d -Pi %d -Pc UPDATE ",                        uh->tu_type,                        uh->tu_dst,                        uh->tu_tau,                        uh->tu_oid,                        uh->tu_r,                        uh->tu_delta,                        uh->tu_id);		}                break;        case TORATYPE_CLR:		if (pt_->tagged()) {		    sprintf(pt_->buffer() + offset,			    "-tora:t %x -tora:d %d -tora:a %f -tora:o %d "			    "-tora:c CLEAR ",			    ch->tc_type,                            ch->tc_dst,                            ch->tc_tau,                            ch->tc_oid);		} else if (newtrace_) {		    sprintf(pt_->buffer() + offset, 			"-P tora -Pt 0x%x -Pd %d -Pa %f -Po %d -Pc CLEAR ",                        ch->tc_type,                        ch->tc_dst,                        ch->tc_tau,                        ch->tc_oid);		} else {                    sprintf(pt_->buffer() + offset, "[0x%x %d %f %d] (CLEAR)",                        ch->tc_type,                        ch->tc_dst,                        ch->tc_tau,                        ch->tc_oid);		}                break;        }}voidCMUTrace::format_aodv(Packet *p, int offset){        struct hdr_aodv *ah = HDR_AODV(p);        struct hdr_aodv_request *rq = HDR_AODV_REQUEST(p);        struct hdr_aodv_reply *rp = HDR_AODV_REPLY(p);        switch(ah->ah_type) {        case AODVTYPE_RREQ:		if (pt_->tagged()) {		    sprintf(pt_->buffer() + offset,			    "-aodv:t %x -aodv:h %d -aodv:b %d -aodv:d %d "			    "-aodv:ds %d -aodv:s %d -aodv:ss %d "			    "-aodv:c REQUEST ",			    rq->rq_type,                            rq->rq_hop_count,                            rq->rq_bcast_id,                            rq->rq_dst,                            rq->rq_dst_seqno,                            rq->rq_src,                            rq->rq_src_seqno);		} else if (newtrace_) {		    sprintf(pt_->buffer() + offset,			"-P aodv -Pt 0x%x -Ph %d -Pb %d -Pd %d -Pds %d -Ps %d -Pss %d -Pc REQUEST ",			rq->rq_type,                        rq->rq_hop_count,                        rq->rq_bcast_id,                        rq->rq_dst,                        rq->rq_dst_seqno,                        rq->rq_src,                        rq->rq_src_seqno);		} else {		    sprintf(pt_->buffer() + offset,			"[0x%x %d %d [%d %d] [%d %d]] (REQUEST)",			rq->rq_type,                        rq->rq_hop_count,                        rq->rq_bcast_id,                        rq->rq_dst,                        rq->rq_dst_seqno,                        rq->rq_src,                        rq->rq_src_seqno);		}                break;        case AODVTYPE_RREP:        case AODVTYPE_HELLO:	case AODVTYPE_RERR:				if (pt_->tagged()) {		    sprintf(pt_->buffer() + offset,			    "-aodv:t %x -aodv:h %d -aodv:d %d -adov:ds %d "			    "-aodv:l %f -aodv:c %s ",			    rp->rp_type,			    rp->rp_hop_count,			    rp->rp_dst,			    rp->rp_dst_seqno,			    rp->rp_lifetime,			    rp->rp_type == AODVTYPE_RREP ? "REPLY" :			    (rp->rp_type == AODVTYPE_RERR ? "ERROR" :			     "HELLO"));		} else if (newtrace_) {						sprintf(pt_->buffer() + offset,			    "-P aodv -Pt 0x%x -Ph %d -Pd %d -Pds %d -Pl %f -Pc %s ",				rp->rp_type,				rp->rp_hop_count,				rp->rp_dst,				rp->rp_dst_seqno,				rp->rp_lifetime,				rp->rp_type == AODVTYPE_RREP ? "REPLY" :				(rp->rp_type == AODVTYPE_RERR ? "ERROR" :				 "HELLO"));	        } else {						sprintf(pt_->buffer() + offset,				"[0x%x %d [%d %d] %f] (%s)",				rp->rp_type,				rp->rp_hop_count,				rp->rp_dst,				rp->rp_dst_seqno,				rp->rp_lifetime,				rp->rp_type == AODVTYPE_RREP ? "REPLY" :				(rp->rp_type == AODVTYPE_RERR ? "ERROR" :				 "HELLO"));		}                break;		        default:#ifdef WIN32                fprintf(stderr,		        "CMUTrace::format_aodv: invalid AODV packet type\n");#else		fprintf(stderr,		        "%s: invalid AODV packet type\n", __FUNCTION__);#endif                abort();        }}voidCMUTrace::nam_format(Packet *p, int offset){	Node* srcnode = 0 ;	Node* dstnode = 0 ;	Node* nextnode = 0 ;        struct hdr_cmn *ch = HDR_CMN(p);	struct hdr_ip *ih = HDR_IP(p);	char op = (char) type_;	char colors[32];	int next_hop = -1 ;	//<zheng: add for 802.15.4>	//Actually we only need to handle MAC layer for nam (but should display dropping for other layers)	//if (strcmp(tracename,"MAC") != 0)	//if ((op != 'D')&&(op != 'd'))	//	return;	struct hdr_mac802_11 *mh = HDR_MAC802_11(p);	char ptype[11];	strcpy(ptype,	((ch->ptype() == PT_MAC) ? (	  (mh->dh_fc.fc_subtype == MAC_Subtype_RTS) ? "RTS"  :	  (mh->dh_fc.fc_subtype == MAC_Subtype_CTS) ? "CTS"  :	  (mh->dh_fc.fc_subtype == MAC_Subtype_ACK) ? "ACK"  :	  (mh->dh_fc.fc_subtype == MAC_Subtype_Beacon) ? "BCN"  :		//Beacon	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_AssoReq) ? "CM1"  :	//CMD: Association request	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_AssoRsp) ? "CM2"  :	//CMD: Association response	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_DAssNtf) ? "CM3"  :	//CMD: Disassociation notification	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_DataReq) ? "CM4"  :	//CMD: Data request	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_PIDCNtf) ? "CM5"  :	//CMD: PAN ID conflict notification	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_OrphNtf) ? "CM6"  :	//CMD: Orphan notification	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_BconReq) ? "CM7"  :	//CMD: Beacon request	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_CoorRea) ? "CM8"  :	//CMD: Coordinator realignment	  (mh->dh_fc.fc_subtype == MAC_Subtype_Command_GTSReq) ? "CM9"  :	//CMD: GTS request	  "UNKN"	  ) : packet_info.name(ch->ptype())));	//</zheng: add for 802.15.4>        int dst = Address::instance().get_nodeaddr(ih->daddr());	nextnode = Node::get_node_by_address(ch->next_hop_);        if (nextnode) next_hop = nextnode->nodeid(); 	srcnode = Node::get_node_by_address(src_);	dstnode = Node::get_node_by_address(ch->next_hop_);	double distance = 0;        if ((srcnode) && (dstnode)) {	   MobileNode* tmnode = (MobileNode*)srcnode;	   MobileNode* rmnode = (MobileNode*)dstnode;

⌨️ 快捷键说明

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