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

📄 ns-2.28-aodv-uu-0.9.1.patch

📁 aodv2003 在linux上的实现 很好
💻 PATCH
📖 第 1 页 / 共 2 页
字号:
 	} 	return [eval new $nodeclass $args] }diff -uprN ns-2.28.orig/tcl/lib/ns-mobilenode.tcl ns-2.28/tcl/lib/ns-mobilenode.tcl--- ns-2.28.orig/tcl/lib/ns-mobilenode.tcl	2005-01-26 00:29:14.000000000 +0100+++ ns-2.28/tcl/lib/ns-mobilenode.tcl	2005-05-20 15:44:39.065876538 +0200@@ -775,7 +775,12 @@ SRNodeNew instproc init args { 		# Use the default mash and shift 		set dmux_ [new Classifier/Port] 	}-	set dsr_agent_ [new Agent/DSRAgent]++	if { [$ns set routingAgent_] == "DSRUU" } {+		set dsr_agent_ [new Agent/DSRUU]+	} else {+		set dsr_agent_ [new Agent/DSRAgent]+	}  	# setup address (supports hier-address) for dsragent 	$dsr_agent_ addr $address_@@ -856,3 +861,104 @@ SRNodeNew instproc reset args { 	eval $self next $args 	$dsr_agent_ reset }+##############################################################################+# A MobileNode Class for AODV which is modeled after the SRNode Class+# but with modifications.+##############################################################################+Class Node/MobileNode/AODVNode -superclass Node/MobileNode++Node/MobileNode/AODVNode instproc init args {+	$self instvar ragent_ dmux_ classifier_ entry_point_ address_++        set ns [Simulator instance]++	eval $self next $args	;# parent class constructor++	if {$dmux_ == "" } {+		# Use the default mash and shift+		set dmux_ [new Classifier/Port]+	}+	set ragent_ [new Agent/AODVUU [$self id ]]++	# setup address (supports hier-address) for AODV agent+	$self addr $address_+	$ragent_ addr $address_+	$ragent_ node $self++	# Add the node's own address to the port demuxer+	$self add-route $address_ $dmux_++	if { [Simulator set RouterTrace_] == "ON" } {+		# Recv Target+		set rcvT [$self mobility-trace Recv "RTR"]+		set namfp [$ns get-nam-traceall]+		if {  $namfp != "" } {+			$rcvT namattach $namfp+		}+		$rcvT target $ragent_+		set entry_point_ $rcvT	+	} else {+		# Recv Target+		set entry_point_ $ragent_+	}++	$self set ragent_ $ragent_++	# The target of the routing agent is the address classifier+	$ragent_ target $classifier_++	set nullAgent_ [$ns set nullAgent_]+	+	# The default target in the classifier is set to the+	# nullAgent, since the routing agent already handled whatever+	# needs to be handled+	$classifier_ defaulttarget $nullAgent_+	+	# Packets to the routing agent and default port should be+	# dropped, since we've already handled them in the routing+	# agent at the entry.+	$dmux_ install [Node set rtagent_port_] $nullAgent_+	$dmux_ defaulttarget $nullAgent_++	return $self+}++Node/MobileNode/AODVNode instproc start-aodv {} {+	$self instvar ragent_+	$ragent_ start+}++Node/MobileNode/AODVNode instproc entry {} {+        $self instvar entry_point_+        return $entry_point_+}++Node/MobileNode/AODVNode instproc add-interface args {+	eval $self next $args++	$self instvar ragent_ ll_ mac_ ifq_++	set ns [Simulator instance]++	if { [Simulator set RouterTrace_] == "ON" } {+		# Send Target+		set sndT [$self mobility-trace Send "RTR"]+		set namfp [$ns get-nam-traceall]+		if {$namfp != "" } {+			$sndT namattach $namfp+		}+		$sndT target $ll_(0)+		$ragent_ add-ll $sndT +	} else {+		# Send Target+		$ragent_ add-ll $ll_(0) +	}++	$ragent_ if-queue $ifq_(0)+}++Node/MobileNode/AODVNode instproc reset args {+	$self instvar ragent_+	eval $self next $args+	$ragent_ reset+}diff -uprN ns-2.28.orig/tcl/lib/ns-packet.tcl ns-2.28/tcl/lib/ns-packet.tcl--- ns-2.28.orig/tcl/lib/ns-packet.tcl	2005-01-26 00:29:15.000000000 +0100+++ ns-2.28/tcl/lib/ns-packet.tcl	2005-05-20 15:44:39.065876538 +0200@@ -158,6 +158,7 @@ foreach prot { 	SCTP 	Smac 	NV+        AODVUU } { 	add-packet-header $prot }diff -uprN ns-2.28.orig/trace/cmu-trace.cc ns-2.28/trace/cmu-trace.cc--- ns-2.28.orig/trace/cmu-trace.cc	2005-02-03 19:29:19.000000000 +0100+++ ns-2.28/trace/cmu-trace.cc	2005-05-20 15:44:39.079874465 +0200@@ -51,6 +51,9 @@ #include <tora/tora_packet.h> //TORA #include <imep/imep_spec.h>         // IMEP #include <aodv/aodv_packet.h> //AODV+#ifdef AODV_UU+#include <aodv-uu/ns/aodv-uu.h> // AODV-UU+#endif /* AODV_UU */ #include <cmu-trace.h> #include <mobilenode.h> #include <simulator.h>@@ -872,6 +875,170 @@ CMUTrace::format_aodv(Packet *p, int off                 abort();         } }+#ifdef AODV_UU+void CMUTrace::format_aodvuu(Packet *p, int offset) {++        struct hdr_ip *ih = HDR_IP(p);+        hdr_aodvuu *ah = HDR_AODVUU(p);+        AODV_msg *aodv_msg = (AODV_msg *) ah;++        RREQ *aodv_rreq = (RREQ *) aodv_msg;+        RREP *aodv_rrep = (RREP *) aodv_msg;+        RREP_ack *aodv_rrep_ack = (RREP_ack *) aodv_msg;+        RERR *aodv_rerr = (RERR *) aodv_msg;++        switch (aodv_msg->type) {++        case AODV_RREQ:++                if (pt_->tagged()) {+                        // Tagged format currently not supported+                } else if (newtrace_) {++                        sprintf(pt_->buffer() + offset,+                                "-P aodvuu -Pt 0x%x -Ph %d -Pb %d -Pd %d -Pds %d -Ps %d -Pss %d -Pc REQUEST ",+                                aodv_rreq->type,+                                aodv_rreq->hcnt,+                                aodv_rreq->rreq_id,+                                (nsaddr_t) aodv_rreq->dest_addr,+                                aodv_rreq->dest_seqno,+                                (nsaddr_t) aodv_rreq->orig_addr,+                                aodv_rreq->orig_seqno);++                } else {++                        sprintf(pt_->buffer() + offset,+                                "[0x%x %d %d [%d %d] [%d %d]] (REQUEST)",+                                aodv_rreq->type,+                                aodv_rreq->hcnt,+                                ntohl(aodv_rreq->rreq_id),+                                (nsaddr_t) aodv_rreq->dest_addr,+                                aodv_rreq->dest_seqno,+                                (nsaddr_t) aodv_rreq->orig_addr,+                                aodv_rreq->orig_seqno);+                }++                break;++        case AODV_HELLO:++                /* FALLS THROUGH (HELLO:s are sent as RREP:s) */++        case AODV_RREP:++                if (pt_->tagged()) {+                        // Tagged format currently not supported+                } else if (newtrace_) {++                        sprintf(pt_->buffer() + offset,+                                "-P aodvuu -Pt 0x%x -Ph %d -Pd %d -Pds %d -Ps %d -Pl %f -Pc %s ",+                                aodv_rrep->type,+                                aodv_rrep->hcnt,+                                (nsaddr_t) aodv_rrep->dest_addr,+                                aodv_rrep->dest_seqno,+				(nsaddr_t) aodv_rrep->orig_addr,+                                (double) aodv_rrep->lifetime,+                                (ih->daddr() == (nsaddr_t) AODV_BROADCAST &&+                                 ih->ttl() == 1) ? "HELLO" : "REPLY");+                } else {++                        sprintf(pt_->buffer() + offset,+                                "[0x%x %d [%d %d] [%d] %f] (%s)",+                                aodv_rrep->type,+                                aodv_rrep->hcnt,+                                (nsaddr_t) aodv_rrep->dest_addr,+                                aodv_rrep->dest_seqno,+				(nsaddr_t) aodv_rrep->orig_addr,+                                (double) aodv_rrep->lifetime,+                                (ih->daddr() == (nsaddr_t) AODV_BROADCAST &&+                                 ih->ttl() == 1) ? "HELLO" : "REPLY");+                }++                break;++        case AODV_RERR:++                /*+                  Note 1:++                  The "hop count" (-Ph and its corresponding field in+                  the old trace format) is actually the DestCount.++                  This is a reminiscence from the AODV trace format,+                  where RREP:s, RERR:s and HELLO:s are treated equally+                  in terms of logging.++                  Note 2:++                  Lifetime field does not exist for RERR:s.+                  Again a reminiscence from the AODV trace format+                  (where that field isn't even initialized!).+                  Therefore lifetime is set to 0.0 all the time for RERR:s.+		*/++                if (pt_->tagged()) {+                        // Tagged format currently not supported+                } else if (newtrace_) {++                        sprintf(pt_->buffer() + offset,+                                "-P aodvuu -Pt 0x%x -Ph %d -Pd %d -Pds %d -Pl %f -Pc ERROR ",+                                aodv_rerr->type,+                                aodv_rerr->dest_count,+                                (nsaddr_t) aodv_rerr->dest_addr,+                                aodv_rerr->dest_seqno,+                                0.0);+                } else {++                        sprintf(pt_->buffer() + offset,+                                "[0x%x %d [%d %d] %f] (ERROR)",+                                aodv_rerr->type,+                                aodv_rerr->dest_count,+                                (nsaddr_t) aodv_rerr->dest_addr,+                                aodv_rerr->dest_seqno,+                                0.0);+                }++                break;++        case AODV_RREP_ACK:++                /*+                  Note 3:++                  RREP-ACK logging didn't exist in the AODV trace format.+		*/++                if (pt_->tagged()) {+                        // Tagged format currently not supported+                } else if (newtrace_) {++                        sprintf(pt_->buffer() + offset,+                                "-P aodvuu -Pt 0x%x RREP-ACK ",+                                aodv_rrep_ack->type);+                } else {++                        sprintf(pt_->buffer() + offset,+                                "[%d] (RREP-ACK)",+                                aodv_rrep_ack->type);+                }++                break;++        default:++#ifdef WIN32+                fprintf(stderr,+                        "CMUTrace::format_aodvuu: invalid AODVUU packet type\n");+#else+                fprintf(stderr,+                        "%s: invalid AODVUU packet type\n", __FUNCTION__);+#endif+                abort();++                break;+        }+}+#endif /* AODV_UU */  void CMUTrace::nam_format(Packet *p, int offset)@@ -1167,6 +1334,13 @@ void CMUTrace::format(Packet* p, const c 		case PT_GAF: 		case PT_PING: 			break;+#ifdef AODV_UU+		case PT_ENCAPSULATED:+			break;+                case PT_AODVUU:+                        format_aodvuu(p, offset);+                        break;+#endif /* AODV_UU */ 		default: 		/*<zheng: del -- there are many more new packet types added, like PT_EXP (poisson traffic belongs to this type)> 			fprintf(stderr, "%s - invalid packet type (%s).\n",diff -uprN ns-2.28.orig/trace/cmu-trace.h ns-2.28/trace/cmu-trace.h--- ns-2.28.orig/trace/cmu-trace.h	2005-01-26 00:29:16.000000000 +0100+++ ns-2.28/trace/cmu-trace.h	2005-05-20 15:44:39.080874316 +0200@@ -132,6 +132,9 @@ private: 	void	format_tora(Packet *p, int offset);         void    format_imep(Packet *p, int offset);         void    format_aodv(Packet *p, int offset);+#ifdef AODV_UU+        void    format_aodvuu(Packet *p, int offset);+#endif /* AODV_UU */ };  #endif /* __cmu_trace__ */

⌨️ 快捷键说明

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