[ns] handoff simulation

Michael Savoric savoric@ft.ee.tu-berlin.de
Wed Aug 7 05:16:00 2002


Hi,
you can use, for example, two nodes and the commands
detach-agent, attach-agent to detach the receiver or
the sender from its current node and attach it to the
new node. To update the ns-internal table of existing
connections I have written a new procedure reconnect
(add it to ns-lib.tcl):

Simulator instproc reconnect {src_agent dst_agent old_dst_agent_node} {
  global nconn_ conn_

  $self simplex-connect $src_agent $dst_agent
  $self simplex-connect $dst_agent $src_agent

  if {[lindex [split [$src_agent info class] "/"] 1] == "TCP"} {
    set src_agent_node_id [$src_agent nodeid]

    set old_dst_agent_node_id [$old_dst_agent_node id]

    set find_tcp_con_status 0

    set list_index 0

    while {$find_tcp_con_status == 0 && $list_index < $nconn_} {
      set list [split $conn_($list_index) ":"]

      if {[lindex $list 0] == $src_agent_node_id && \
          [lindex $list 1] == $old_dst_agent_node_id} {
        set find_tcp_con_status 1
      } else {
        incr list_index
      }
    }

    if {$find_tcp_con_status == 1} {
      set conn_($list_index) $src_agent_node_id:[$dst_agent nodeid]
    } else {
      set conn_($nconn_) $src_agent_node_id:[$dst_agent nodeid]

      incr nconn_
    }
  }

  return $src_agent
}

This procedure works with ns version 2.1b8. For ns version 2.1b9 you
have to add

set nconn_ 0
set conn_(0) 0:0

to the ns-lib.tcl file.


For a handover of a TCP receiver you have to do the following:

$ns detach-agent $receiver_node_1 $tcp_receiver

% wait for the handover latency, e.g.:
% $ns at [expr [$ns now]+$ho_latency] {

$ns attach-agent $receiver_node_2 $tcp_receiver

$ns reconnect $tcp_sender $tcp_receiver $receiver_node_1

% }

Best regards,
Michael Savoric

======================================================
E-Mail:		savoric@ee.tu-berlin.de

Phone:		(+49 30) 314-23840

Fax:		(+49 30) 314-23818

Postal address:	Technical University Berlin
		Telecommunication Networks Group (TKN)
		Einsteinufer 25, 10587 Berlin
======================================================