From 45e5e3c7478f8f15a7831703f7769b248739f1e4 Mon Sep 17 00:00:00 2001 From: "Leigh B. Stoller" Date: Fri, 30 Apr 2004 21:18:55 +0000 Subject: [PATCH] Small hack requested by Jay to aid in creating wireless nodes; added new directive for your NS file: tb-use-physnaming(1) which means that if you have a line like this: set pc6 [$ns node] and pc6 is an actual name of a physical node, then do an implicit "fixnode" to pc6. In other words, pc6 is the name of the node in your NS file (virtual topo) *and* will be fixed to the real pc6. Needless to say, if pc6 is allocated when you go to swapin, you lose. --- tbsetup/ns2ir/node.tcl | 9 +++++++++ tbsetup/ns2ir/parse-ns.in | 11 +++++++++++ tbsetup/ns2ir/parse.tcl.in | 3 +++ tbsetup/ns2ir/sim.tcl.in | 2 +- tbsetup/ns2ir/tb_compat.tcl.in | 14 ++++++++++++++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/tbsetup/ns2ir/node.tcl b/tbsetup/ns2ir/node.tcl index 496d4121a..f5d601b6b 100644 --- a/tbsetup/ns2ir/node.tcl +++ b/tbsetup/ns2ir/node.tcl @@ -132,6 +132,8 @@ Node instproc updatedb {DB} { $self instvar nseconfig $self instvar simulated var_import ::TBCOMPAT::default_osids + var_import ::GLOBALS::use_physnaming + var_import ::TBCOMPAT::physnodes var_import ::GLOBALS::pid var_import ::GLOBALS::eid var_import ::GLOBALS::default_ip_routing_type @@ -168,6 +170,13 @@ Node instproc updatedb {DB} { set fixed "host-$self" } + # Implicitly fix node if not already fixed. + if { $issubnode == 0 && $use_physnaming == 1 && $fixed == "" } { + if {[info exists physnodes($self)]} { + set fixed $self + } + } + # We need to generate the IP column from our iplist. set ipraw {} set i 0 diff --git a/tbsetup/ns2ir/parse-ns.in b/tbsetup/ns2ir/parse-ns.in index b06dd48cb..2ce01eac9 100644 --- a/tbsetup/ns2ir/parse-ns.in +++ b/tbsetup/ns2ir/parse-ns.in @@ -451,6 +451,17 @@ sub GenDefsFile($) } } + print TCL "# Physical Node Names\n"; + $query_result = + DBQueryFatal("select n.node_id,nt.type from nodes as n ". + "left join node_types as nt on n.type=nt.type ". + "where n.node_id=n.phys_nodeid and nt.isremotenode=0 ". + "and n.role='testnode' and nt.type!='dnard'"); + + while (($node_id,$type) = $query_result->fetchrow_array()) { + print TCL "set physnodes($node_id) \"$type\"\n"; + } + print TCL "}\n"; close(TCL); } diff --git a/tbsetup/ns2ir/parse.tcl.in b/tbsetup/ns2ir/parse.tcl.in index ddd8c1ca7..2ebf620db 100644 --- a/tbsetup/ns2ir/parse.tcl.in +++ b/tbsetup/ns2ir/parse.tcl.in @@ -245,6 +245,9 @@ namespace eval GLOBALS { # Allow override of jail and delay osids. variable jail_osname {} variable delay_osname {} + + # Use phys naming + variable use_physnaming 0 } # Load all our classes diff --git a/tbsetup/ns2ir/sim.tcl.in b/tbsetup/ns2ir/sim.tcl.in index 0dbdc2e77..7666de1c2 100644 --- a/tbsetup/ns2ir/sim.tcl.in +++ b/tbsetup/ns2ir/sim.tcl.in @@ -95,7 +95,7 @@ Simulator instproc node {args} { # that already have FBSD-NSE as the default # boot osid over others $curnode add-desire "FBSD-NSE" 0.9 - } + } set node_list($curnode) {} set last_class $curnode diff --git a/tbsetup/ns2ir/tb_compat.tcl.in b/tbsetup/ns2ir/tb_compat.tcl.in index cdc0fd6f4..0ef9aa1e4 100644 --- a/tbsetup/ns2ir/tb_compat.tcl.in +++ b/tbsetup/ns2ir/tb_compat.tcl.in @@ -87,6 +87,9 @@ namespace eval TBCOMPAT { variable reserved_type variable reserved_node set reserved_list {} + + # Physical node names + variable physnodes } # IP addresses routines. These all do some checks and convert into set-ip @@ -818,3 +821,14 @@ proc tb-set-node-lan-setting {lanlink node capkey capval} { } $lanlink set_member_setting $node $capkey $capval } + +# +# Turn on or of the use of phys naming; if the user name for the node +# matches a real node in the testbed, do an implicit fix-node to it. +# +proc tb-use-physnaming {onoff} { + var_import ::GLOBALS::use_physnaming + + set use_physnaming $onoff +} + -- GitLab