Tcl 如何在NS2中设置节点的下一跳?

Tcl 如何在NS2中设置节点的下一跳?,tcl,ns2,Tcl,Ns2,我有一个尺寸为200*200的传感器字段。 我选择离场中心最近的节点作为簇头。 我的目标是传感器的数据转发到簇头,簇头的数据转发到汇聚节点。 我希望簇头成为现场任何传感器节点(除了汇聚节点)的下一跳。 我该怎么做? 谢谢我不知道ns2,但是如果有转发命令,那么应该只是循环节点并运行转发命令。这里有一些伪代码 set head_x 7 set head_y 8 # get node at head_y head_x as head_node # tell head to forward to s

我有一个尺寸为200*200的传感器字段。 我选择离场中心最近的节点作为簇头。 我的目标是传感器的数据转发到簇头,簇头的数据转发到汇聚节点。 我希望簇头成为现场任何传感器节点(除了汇聚节点)的下一跳。 我该怎么做?
谢谢

我不知道ns2,但是如果有转发命令,那么应该只是循环节点并运行转发命令。这里有一些伪代码

set head_x 7
set head_y 8

# get node at head_y head_x as head_node
# tell head to forward to sinc node

for {set y 0} {$y < 200} {incr y} {

    for {set x 0} {$x < 200} {incr x} {

        if {$x != $head_x && $y != $head_y} {
            # tell node $y $x to forward to $head_node
        }

    }
}
set head_x 7
设置头8
#获取头上的节点y头上的节点作为头上的节点
#告诉头部转发到sinc节点
对于{set y 0}{$y<200}{incr y}{
对于{set x 0}{$x<200}{incr x}{
如果{$x!=$head\u x&&$y!=$head\u y}{
#告诉节点$y$x转发到$head\U节点
}
}
}

我不知道ns2,但是如果有转发命令,那么应该只是循环节点并运行转发命令。这里有一些伪代码

set head_x 7
set head_y 8

# get node at head_y head_x as head_node
# tell head to forward to sinc node

for {set y 0} {$y < 200} {incr y} {

    for {set x 0} {$x < 200} {incr x} {

        if {$x != $head_x && $y != $head_y} {
            # tell node $y $x to forward to $head_node
        }

    }
}
set head_x 7
设置头8
#获取头上的节点y头上的节点作为头上的节点
#告诉头部转发到sinc节点
对于{set y 0}{$y<200}{incr y}{
对于{set x 0}{$x<200}{incr x}{
如果{$x!=$head\u x&&$y!=$head\u y}{
#告诉节点$y$x转发到$head\U节点
}
}
}