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

📄 ns-namsupp.tcl

📁 对ns2软件进行UMTS扩展
💻 TCL
📖 第 1 页 / 共 2 页
字号:
# * Modified and extended by Pablo Martin and Paula Ballester,# * Strathclyde University, Glasgow.# * June, 2003.# *## Copyright (c) 2003 Strathclyde University of Glasgow, Scotland.# * All rights reserved.# *# * Redistribution and use in source and binary forms, with or without# * modification, are permitted provided that the following conditions# * are met:# *# * 1. Redistributions of source code and binary code must contain# * the above copyright notice, this list of conditions and the following# * disclaimer.# *# * 2. All advertising materials mentioning features or use of this software# * must display the following acknowledgement:# * This product includes software developed at Strathclyde University of# * Glasgow, Scotland.# *# * 3. The name of the University may not be used to endorse or promote# * products derived from this software without specific prior written# * permission.# * STRATHCLYDE UNIVERSITY OF GLASGOW, MAKES NO REPRESENTATIONS# * CONCERNING EITHER THE MERCHANTABILITY OF THIS SOFTWARE OR THE# * SUITABILITY OF THIS SOFTWARE FOR ANY PARTICULAR PURPOSE.  The software# * is provided "as is" without express or implied warranty of any kind.###  Copyright (c) 1997 by the University of Southern California#  All rights reserved.# #  Permission to use, copy, modify, and distribute this software and its#  documentation in source and binary forms for non-commercial purposes#  and without fee is hereby granted, provided that the above copyright#  notice appear in all copies and that both the copyright notice and#  this permission notice appear in supporting documentation. and that#  any documentation, advertising materials, and other materials related#  to such distribution and use acknowledge that the software was#  developed by the University of Southern California, Information#  Sciences Institute.  The name of the University may not be used to#  endorse or promote products derived from this software without#  specific prior written permission.# #  THE UNIVERSITY OF SOUTHERN CALIFORNIA makes no representations about#  the suitability of this software for any purpose.  THIS SOFTWARE IS#  PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,#  INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.# #  Other copyrights might apply to parts of this software and are so#  noted when applicable.# # ns trace support for nam## Author: Haobo Yu (haoboy@isi.edu)## $Header: /nfs/jade/vint/CVSROOT/ns-2/tcl/lib/ns-namsupp.tcl,v 1.39 2002/09/25 20:40:19 johnh Exp $### Support for node tracing## This will only work during initialization. Not possible to change shape # dynamicallyNode instproc shape { shape } {	$self instvar attr_ 	set attr_(SHAPE) $shape}# Returns the current shape of the nodeNode instproc get-shape {} {	$self instvar attr_	if [info exists attr_(SHAPE)] {		return $attr_(SHAPE)	} else {		return ""	}}Node instproc color { color } {	$self instvar attr_ id_	set ns [Simulator instance]	if [$ns is-started] {		# color must be initialized		$ns puts-nam-config \		[eval list "n -t [$ns now] -s $id_ -S COLOR -c $color -o $attr_(COLOR) -i $color -I $attr_(LCOLOR)"]		set attr_(COLOR) $color	        set attr_(LCOLOR) $color	} else {		set attr_(COLOR) $color	        set attr_(LCOLOR) $color	}}Node instproc label { str} {	$self instvar attr_ id_	set ns [Simulator instance]	if [info exists attr_(DLABEL)] {		$ns puts-nam-config "n -t [$ns now] -s $id_ -S DLABEL -l \"$str\" -L $attr_(DLABEL)"	} else {		$ns puts-nam-config "n -t [$ns now] -s $id_ -S DLABEL -l \"$str\" -L \"\""	}	set attr_(DLABEL) \"$str\"}Node instproc label-color { str} {        $self instvar attr_ id_        set ns [Simulator instance]        if [info exists attr_(DCOLOR)] {                $ns puts-nam-config "n -t [$ns now] -s $id_ -S DCOLOR -e \"$str\" -E $attr_(DCOLOR)"        } else {                $ns puts-nam-config "n -t [$ns now] -s $id_ -S DCOLOR -e \"$str\" -E \"\""        }        set attr_(DCOLOR) \"$str\"}Node instproc label-at { str } {        $self instvar attr_ id_        set ns [Simulator instance]        if [info exists attr_(DIRECTION)] {                $ns puts-nam-config "n -t [$ns now] -s $id_ -S DIRECTION -p \"$str\" -P $attr_(DIRECTION)"        } else {                $ns puts-nam-config "n -t [$ns now] -s $id_ -S DIRECTION -p \"$str\" -P \"\""        }        set attr_(DIRECTION) \"$str\"}Node instproc dump-namconfig {} {	$self instvar attr_ id_ address_	set ns [Simulator instance]	if ![info exists attr_(SHAPE)] {		set attr_(SHAPE) "circle"	}	if ![info exists attr_(COLOR)] {		set attr_(COLOR) "black"	        set attr_(LCOLOR) "black"	}        if ![info exists attr_(DCOLOR)] {                set attr_(DCOLOR) "black"        }	$ns puts-nam-config \		[eval list "n -t * -a $address_ -s $id_ -S UP -v $attr_(SHAPE) -c $attr_(COLOR) -i $attr_(LCOLOR)"]}# P.M. & P.B. modificationsNode instproc dump-namconfig-flat {} {	$self instvar attr_ id_ address_ X_ Y_ Z_	set ns [Simulator instance]	if ![info exists attr_(SHAPE)] {		set attr_(SHAPE) "circle"	}	if ![info exists attr_(COLOR)] {		set attr_(COLOR) "black"	        set attr_(LCOLOR) "black"	}        if ![info exists attr_(DCOLOR)] {                set attr_(DCOLOR) "black"        }	$ns puts-nam-config \		[eval list "n -t * -s $id_ -S UP -x $X_ -y $Y_ -Z $Z_ -v $attr_(SHAPE) -c $attr_(COLOR) -i $attr_(LCOLOR)"]}Node instproc change-color { color } {	puts "Warning: Node::change-color is obsolete. Use Node::color instead"	$self color $color}Node instproc get-attribute { name } {	$self instvar attr_	if [info exists attr_($name)] {		return $attr_($name)	} else {		return ""	}}Node instproc get-color {} {	puts "Warning: Node::get-color is obsolete. Please use Node::get-attribute"	return [$self get-attribute "COLOR"]}Node instproc add-mark { name color {shape "circle"} } {	$self instvar id_ markColor_ shape_	set ns [Simulator instance]	$ns puts-nam-config "m -t [$ns now] -s $id_ -n $name -c $color -h $shape"	set markColor_($name) $color	set shape_($name) $shape}Node instproc delete-mark { name } {	$self instvar id_ markColor_ shape_	# Ignore if the mark $name doesn't exist	if ![info exists markColor_($name)] {		return	}	set ns [Simulator instance]	$ns puts-nam-config \		"m -t [$ns now] -s $id_ -n $name -c $markColor_($name) -h $shape_($name) -X"}## Support for link tracing# XXX only SimpleLink (and its children) can dump nam config, because Link# doesn't have bandwidth and delay.#SimpleLink instproc dump-namconfig {} {	# make a duplex link in nam	$self instvar link_ attr_ fromNode_ toNode_	if ![info exists attr_(COLOR)] {		set attr_(COLOR) "black"	}	if ![info exists attr_(ORIENTATION)] {		set attr_(ORIENTATION) ""	}	set ns [Simulator instance]	set bw [$link_ set bandwidth_]	set delay [$link_ set delay_]	$ns puts-nam-config \		"l -t * -s [$fromNode_ id] -d [$toNode_ id] -S UP -r $bw -D $delay -c $attr_(COLOR) -o $attr_(ORIENTATION)"}Link instproc dump-nam-queueconfig {} {	$self instvar attr_ fromNode_ toNode_	if ![info exists attr_(COLOR)] {		set attr_(COLOR) "black"	}	set ns [Simulator instance]	if [info exists attr_(QUEUE_POS)] {		$ns puts-nam-config "q -t * -s [$fromNode_ id] -d [$toNode_ id] -a $attr_(QUEUE_POS)"	} else {		set attr_(QUEUE_POS) ""	}}## XXX# This function should be called ONLY ONCE during initialization. # The order in which links are created in nam is determined by the calling # order of this function.#Link instproc orient { ori } {	$self instvar attr_	set attr_(ORIENTATION) $ori	[Simulator instance] register-nam-linkconfig $self}Link instproc get-attribute { name } {	$self instvar attr_	if [info exists attr_($name)] {		return $attr_($name)	} else {		return ""	}}Link instproc queuePos { pos } {	$self instvar attr_	set attr_(QUEUE_POS) $pos}Link instproc color { color } {	$self instvar attr_ fromNode_ toNode_ trace_	set ns [Simulator instance]	if [$ns is-started] {		$ns puts-nam-config \			[eval list "l -t [$ns now] -s [$fromNode_ id] -d [$toNode_ id] -S COLOR -c $color -o $attr_(COLOR)"]		set attr_(COLOR) $color	} else {		set attr_(COLOR) $color

⌨️ 快捷键说明

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