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

📄 rca.tcl

📁 可以在ns-2中进行仿真的SPIN路由协议的源码
💻 TCL
字号:
source $env(RCA_LIBRARY)/timer.tclsource $env(RCA_LIBRARY)/meta/new-key-set.tclsource $env(RCA_LIBRARY)/meta/ns-key-meta.tclsource $env(RCA_LIBRARY)/meta/ns-advlist.tclsource $env(RCA_LIBRARY)/resources/ns-neighbor-resource.tclsource $env(RCA_LIBRARY)/resources/ns-energy-resource.tclsource $env(RCA_LIBRARY)/resources/ns-resource-manager.tclsource $env(RCA_LIBRARY)/misc/overlappingkey.tcl#source $env(RCA_LIBRARY)/misc/simplekey.tclsource $env(RCA_LIBRARY)/misc/ns-rca-stats.tclsource $env(RCA_LIBRARY)/misc/rca-sim-utils.tclsource $env(RCA_LIBRARY)/ns-rca.tclsource $env(RCA_LIBRARY)/ns-rca-flooding.tclsource $env(RCA_LIBRARY)/ns-ranode.tcl# ======================================================================# Default Script Options# ======================================================================set opt(rcapp)         "Application/RCApp"  ;# Agent typeset opt(interval)      .01		            ;# Checking intervalset opt(statsfile)     "rca" 		        ;# name of statistics trace fileset opt(tr)     			 "rca" 		        ;# name of trace fileset opt(mtype)         "KeyMetaData"        ;# Meta-data typeset opt(overlap)       1 		            ;# Amount of data overlapset opt(bw)            1e6                  ;# bits/secset opt(prop_speed)    3e8                  ;# meters/sec (speed of light)set opt(xcvr_power)    200e-3               ;# Transceiver-- 200mWset opt(amp_power)     400e-3               ;# Power Amp-- 400mWset opt(comp_power)    600e-3               ;# Processor-- 600mWset opt(proc_speed)    1e9                  ;# Processor speed-- 1G ops/secset opt(xcvr_cost)     [expr [expr $opt(xcvr_power) / $opt(bw) ] * 8]set opt(amp_cost)      [expr [expr $opt(amp_power)  / $opt(bw) ] * 8]set opt(comp_cost)     [expr $opt(comp_power) / $opt(proc_speed)]set opt(init_energy)   8000                 ;# initial energy levelset opt(thresh_energy) 100		            ;# threshold for power adaptationset opt(ll)            RCALinkLayer         ;# our arpless link-layerset opt(mac)		   		 Mac/802_11           ;# we assume 802.11# ===== Get rid of the warnings in bind ================================Resource/Energy set energyLevel_ $opt(init_energy)Resource/Energy set alarmLevel_ $opt(thresh_energy)Resource/Energy set expended_ 0Agent/RCAgent set sport_        0Agent/RCAgent set dport_        0Agent/RCAgent set packetMsg_    0Agent/RCAgent set packetSize_   0RCALinkLayer set mindelay_		  50usRCALinkLayer set delay_			    25usRCALinkLayer set bandwidth_		  0	  ;# not usedRCALinkLayer set off_prune_		  0	  ;# not usedRCALinkLayer set off_CtrMcast_	0	  ;# not usedRCALinkLayer set macDA_	        0	  ;# not usedset MacTrace			OFFPhy/WirelessPhy set PXcvr_ 0# This is an unfortunate hack that we do to get# our own, one-time only initializations into the simulation. set rca_initialized 0proc rca-create-mobile-node { id } {    global ns_ chan prop topo tracefd opt node_ ns    global chan prop tracefd topo opt rca rcagent    global rca_initialized    if {$rca_initialized == 0} {			rca_init			set rca_initialized 1    }    puts "Creating mobile node $id"    set node_($id) [new MobileNode/ResourceAwareNode]    set node $node_($id)    $node set-energy $opt(init_energy) $opt(thresh_energy)    $node random-motion 0		;# disable random motion    $node topography $topo    # connect up the channel    $node add-interface $chan $prop $opt(ll) $opt(mac)	\				$opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant)    #    # This Trace Target is used to log changes in direction    # and velocity for the mobile node and log actions of the DSR agent    #    set T [new Trace/Generic]    $T target [$ns_ set nullAgent_]    $T attach $tracefd    $T set src_ $id    $node log-target $T    $ns_ at 0.0 "$node_($id) start-app"}proc rca_init {} {    global ns_ opt ns    # Disgusting hack required because the timer    # code has hard-coded the global variable ns to    # be the simulator.    set ns $ns_    # RCA Specific Initialization Commands    set fc [new FinishCheck]    $fc set finish_command_ "rca_finish"    $fc set check_command_ "rca_check_wants_empty"    $fc set interval_ $opt(interval)    $ns_ at 0.0 "[$fc set check_command_]"    $ns_ at 0.0 "$fc sched $opt(interval)"    rca_init_stats $opt(statsfile)    $ns_ at $opt(stop) "[$fc set finish_command_]"}

⌨️ 快捷键说明

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