[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ns] Specifying arbitrary node addresses
> > I had a look at hierarchical addressing, but I'm quite sure that this
> > carries hierarchical routing baggage with it. Can someone confirm
> > this? Afaik, this then imposes constraints on the addresses chosen for the
> > nodes. This is not what I want. Is it possible to decouple hierarchical
> > addressing from hierarchical routing?
>
> This would be ideal if done - the existing flat address space can (and
> IMO should) be thought of as hierarchical addressing with one level of
> hierarchy.
I had a look at the way that hierarchical addressing and routing are
implemented, but it seemed like a bit of a nightmare to start changing. I
didn't like the fact that the address was stored in a tcl variable as a
string of dotted quads, and seemed to be manipulated in this format. I
still haven't figured out how packets are assigned a 32-bit address.
I did hack together some (rather unsubstantial) changes to the way that
flat routing is implemented. I added code to enable a node address to be
specified (either in dotted quad format or as some abstract number) and I
modified the routing tables in each node so that node address is used to
index the table rather than the node id.
If these changes are made to the code a node can now be added as follows:
set n(0) [$ns node 1.0.0.1]
or
set some_arbitrary_node_number 89753
set n(0) [$ns node $some_arbitrary_node_number]
I only wrote it to work with generic nodes, so I don't know if it will
cause other things to break.
I made the changes to a bastardised version of ns-2.1b6 - I think that the
files I changed are the same as those in ns-2.1b6, but I've provided
context diffs in any case.
One rather obvious caveat - allowing such control over the node addresses
has the potential to go pear-shaped: multiple nodes having the same
address can now exist in the network.
Sean.
-----
Sean Murphy, Email: [email protected]
Teltec Ireland, Phone: +353-1-7045080
DCU, Dublin 9, Fax: +353-1-7045092
Ireland.
*** ns-address.tcl Wed Jun 21 16:17:42 2000
--- ns-address.tcl.old Wed Jun 21 15:31:09 2000
***************
*** 432,467 ****
}
error "get-node-id-by-addr:Cannot find node with given address"
}
-
- proc convert-dotted-ip-to-number {dottedipaddr} {
- if { [string first "." $dottedipaddr] == -1 } {
- return $dottedipaddr
- }
- set fields [split $dottedipaddr .]
- if { [llength $fields] > 4 } {
- puts "IP Address contains more than 4 fields"
- exit 1
- }
-
- set addr(0) [check-field-value [lindex $fields 0]]
- set addr(1) [check-field-value [lindex $fields 1]]
- set addr(2) [check-field-value [lindex $fields 2]]
- set addr(3) [check-field-value [lindex $fields 3]]
-
- # puts "0 = $addr(0), 1 = $addr(1), 2 = $addr(2), 3 = $addr(3)"
- set addressnumber [expr "$addr(3) + ($addr(2) << 8) + \
- ($addr(1) << 16) + ($addr(0) << 24)"]
-
- return $addressnumber
- }
-
- proc check-field-value {fieldvalue} {
- if {$fieldvalue == "" } {
- return 0
- }
- if { $fieldvalue > 255 } {
- puts "dotted IP address must contain fields in range (0-255)"
- exit 1
- }
- return $fieldvalue
- }
--- 432,434 ----
*** ns-node.tcl Wed Jun 21 16:19:35 2000
--- ns-node.tcl.old Wed Jun 21 14:26:57 2000
***************
*** 73,89 ****
}
Node instproc set-node-address { args } {
- $self instvar address_
- # this assumes that args contains a single address (either dotted IP, or
- # abstract number)
-
- if { $args != "{{}}" } {
- if { [string first "." $args] != -1 } {
- set address_ [convert-dotted-ip-to-number $args]
- } else {
- set address_ $args
- }
- }
}
Node instproc set-node-addressMIPBS { args } {
--- 73,78 ----
*** ns-route.tcl Wed Jun 21 15:23:25 2000
--- ns-route.tcl.old Wed Jun 21 15:20:23 2000
***************
*** 206,213 ****
# a single line
set nh [$r lookup $i $j]
if { $nh >= 0 } {
! set nj $Node_($j)
! $n1 add-route [$nj node-addr] [$link_($i:$nh) head]
###$n1 incr-rtgtable-size
}
}
--- 206,212 ----
# a single line
set nh [$r lookup $i $j]
if { $nh >= 0 } {
! $n1 add-route $j [$link_($i:$nh) head]
###$n1 incr-rtgtable-size
}
}