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

📄 cmu-trace.cc

📁 MAODV代码和安装程序 hen nan找啊
💻 CC
📖 第 1 页 / 共 3 页
字号:
		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);        /*** added for multicast ***/        struct hdr_aodv_grph *gh = HDR_AODV_GRPH(p);        struct hdr_aodv_mact *mact = HDR_AODV_MACT(p);        struct hdr_aodv_warn *warn = HDR_AODV_WARN(p);        /****************************/        switch(ah->ah_type) {        case AODVTYPE_RREQ:        /*** added for prediction for unicast ***/        case AODVTYPE_LINK_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:        /*** added for prediction for unicast ***/        case AODVTYPE_LPW:        case AODVTYPE_RPE:        /****************************************/				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,                        /*** modified for prediction for unicast ***/                        rp->rp_type == AODVTYPE_RREP ? "REPLY" :                        (rp->rp_type == AODVTYPE_RERR ? "ERROR" :                        (rp->rp_type == AODVTYPE_HELLO ? "HELLO" :                        (rp->rp_type == AODVTYPE_LPW ? "LINK PREDICTION WARNING" :                        "ROUTE PREDICTION ERROR"))));        		    //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,                        /*** modified for prediction for unicast ***/                        rp->rp_type == AODVTYPE_RREP ? "REPLY" :                        (rp->rp_type == AODVTYPE_RERR ? "ERROR" :                        (rp->rp_type == AODVTYPE_HELLO ? "HELLO" :                        (rp->rp_type == AODVTYPE_LPW ? "LINK PREDICTION WARNING" :                        "ROUTE PREDICTION ERROR"))));                            //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,                        /*** modified for prediction for unicast ***/                        rp->rp_type == AODVTYPE_RREP ? "REPLY" :                        (rp->rp_type == AODVTYPE_RERR ? "ERROR" :                        (rp->rp_type == AODVTYPE_HELLO ? "HELLO" :                        (rp->rp_type == AODVTYPE_LPW ? "LINK PREDICTION WARNING" :                        "ROUTE PREDICTION ERROR"))));                            //rp->rp_type == AODVTYPE_RREP ? "REPLY" :                            //(rp->rp_type == AODVTYPE_RERR ? "ERROR" :                             //"HELLO"));                        /**********************************************/		}                break;        /*** added for multicast ***/        case AODVTYPE_GRPH:            sprintf(pt_->buffer() + offset,                "[0x%x 0x%x %d %d [%d %d]] (GROUP HELLO)",                gh->gh_type, gh->gh_flags, gh->gh_hop_count, gh->gh_grp_leader_addr,                gh->gh_multi_grp_addr, gh->gh_grp_seqno);            break;        case AODVTYPE_MACT:            sprintf(pt_->buffer() + offset,                "[0x%x 0x%x %d %d [%d %d]] (MACT)",                mact->mact_type, mact->mact_flags, mact->mact_hop_count, mact->mact_grp_dst,                mact->mact_src, mact->mact_src_seqno);            break;        case AODVTYPE_WARN:            sprintf(pt_->buffer() + offset,                "[0x%x 0x%x %f %d(WARN)",                warn->wn_type, warn->wn_flags, warn->wn_expire, warn->wn_grp);            break;		        /****************************/

⌨️ 快捷键说明

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