# and Technology through the research contract #IP-2003-143.
#
-
+#****h* imunes/linkcfg.tcl
+# NAME
+# linkcfg.tcl -- file used for manipultaion with links in IMUNES
+# FUNCTION
+# This module is used to define all the actions used for configuring
+# links in IMUNES.
#
+# NOTES
+#
# linkPeers { link_id }
# Returns node_ids of link endpoints
#
# they can be used for implementing tasks external to GUI, yet inside the
# GUI any updating of related Tk objects (such as text labels etc.) will
# have to be implemented by additional Tk code.
-#
-
+#****
+
+#****f* linkcfg.tcl/linkPeers
+# NAME
+# linkPeers -- get link's peer nodes
+# SYNOPSIS
+# set link_peers [linkPeers $link_id]
+# FUNCTION
+# Returns node_ids of link endpoints.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * link_peers -- returns nodes_ids of a link endpoints
+# in a list {node1_id node2_id}
+#****
proc linkPeers { link } {
global $link
return [lindex $entry 1]
}
+#****f* linkcfg.tcl/linkByPeers
+# NAME
+# linkByPeers -- get link id from peer nodes
+# SYNOPSIS
+# set link_id [linkByPeers $node1_id $node2_id]
+# FUNCTION
+# Returns link_id whose peers are node1 and node2.
+# The order of input nodes is irrelevant.
+# INPUTS
+# * node1_id -- node id of the first node
+# * node2_id -- node id of the second node
+# RESULT
+# * link_id -- returns id of a link connecting endpoints
+# node1_id node2_id.
+#****
proc linkByPeers { node1 node2 } {
global link_list
return
}
+#****f* linkcfg.tcl/removeLink
+# NAME
+# removeLink -- removes a link.
+# SYNOPSIS
+# removeLink $link_id
+# FUNCTION
+# Removes the link and related entries in peering node's configs.
+# Updates the default route for peer nodes.
+# INPUTS
+# * link_id -- link id
+#****
proc removeLink { link } {
global link_list $link
netconfClearSection $node "interface $ifc"
set i [lsearch [set $node] "interface-peer {$ifc $peer}"]
set $node [lreplace [set $node] $i $i]
+ if { [[typemodel $node].layer] == "NETWORK" } {
+ set ifcs [ifcList $node]
+ foreach ifc $ifcs {
+ autoIPv4defaultroute $node $ifc
+ }
+ }
}
set i [lsearch -exact $link_list $link]
set link_list [lreplace $link_list $i $i]
return
}
+#****f* linkcfg.tcl/getLinkBandwidth
+# NAME
+# getLinkBandwidth -- get link bandwidth
+# SYNOPSIS
+# set bandwidth [getLinkBandwidth $link_id]
+# FUNCTION
+# Returns the link bandwidth expressed in bits per second.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * bandwidth -- The value of link bandwidth in bits per second.
+#****
proc getLinkBandwidth { link } {
global $link
return [lindex $entry 1]
}
+#****f* linkcfg.tcl/getLinkBandwidthString
+# NAME
+# getLinkBandwidthString -- get link bandwidth string
+# SYNOPSIS
+# set bandwidth_str [getLinkBandwidthString $link_id]
+# FUNCTION
+# Returns the link bandwidth in form of a number an a mesure unit.
+# Measure unit is automaticaly asigned depending on the value of bandwidth.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * bandwidth_str -- The value of link bandwidth formated in a sting
+# containing a measure unit.
+#****
proc getLinkBandwidthString { link } {
global $link
return $bandstr
}
+#****f* linkcfg.tcl/setLinkBandwidth
+# NAME
+# setLinkBandwidth -- set link bandwidth
+# SYNOPSIS
+# setLinkBandwidth $link_id $value
+# FUNCTION
+# Sets the link bandwidth in a bits per second.
+# INPUTS
+# * link_id -- link id
+# * value -- link bandwidth in bits per second.
+#****
proc setLinkBandwidth { link value } {
global $link
}
}
+#****f* linkcfg.tcl/getLinkDelay
+# NAME
+# getLinkDelay -- get link delay
+# SYNOPSIS
+# set delay [getLinkDelay $link_id]
+# FUNCTION
+# Returns the link delay expressed in microseconds.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * delay -- The value of link delay in microseconds.
+#****
proc getLinkDelay { link } {
global $link
return [lindex $entry 1]
}
+#****f* linkcfg.tcl/getLinkDelayString
+# NAME
+# getLinkDelayString -- get link delay string
+# SYNOPSIS
+# set delay [getLinkDelayString $link_id]
+# FUNCTION
+# Returns the link delay as a string with avalue and measure unit.
+# Measure unit is automaticaly asigned depending on the value of delay.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * delay -- The value of link delay formated in a sting
+# containing a measure unit.
+#****
proc getLinkDelayString { link } {
global $link
return $delstr
}
+#****f* linkcfg.tcl/setLinkDelay
+# NAME
+# setLinkDelay -- set link delay
+# SYNOPSIS
+# setLinkDelay $link_id $value
+# FUNCTION
+# Sets the link delay in microseconds.
+# INPUTS
+# * link_id -- link id
+# * value -- link delay value in microseconds.
+#****
proc setLinkDelay { link value } {
global $link
return
}
+#****f* linkcfg.tcl/getLinkBER
+# NAME
+# getLinkBER -- get link BER
+# SYNOPSIS
+# set BER [getLinkBER $link_id]
+# FUNCTION
+# Returns 1/BER value of the link.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * BER -- The value of 1/BER of the link.
+#****
proc getLinkBER { link } {
global $link
return [lindex $entry 1]
}
+#****f* linkcfg.tcl/setLinkBER
+# NAME
+# setLinkBER -- set link BER
+# SYNOPSIS
+# setLinkBER $link_id value
+# FUNCTION
+# Sets the BER value of the link.
+# INPUTS
+# * link_id -- link id
+# * value -- The value of 1/BER of the link.
+#****
proc setLinkBER { link value } {
global $link
return
}
+#****f* linkcfg.tcl/getLinkDup
+# NAME
+# getLinkDup -- get link packet duplicate value
+# SYNOPSIS
+# set duplicate [getLinkDup $link_id]
+# FUNCTION
+# Returns the value of the link duplicate percentage.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * duplicate -- The percentage of the link packet duplicate value.
+#****
proc getLinkDup { link } {
global $link
return [lindex $entry 1]
}
+#****f* linkcfg.tcl/setLinkDup
+# NAME
+# setLinkDup -- set link packet duplicate value
+# SYNOPSIS
+# setLinkDup $link_id $value
+# FUNCTION
+# Set link packet duplicate percentage.
+# INPUTS
+# * link_id -- link id
+# * value -- The percentage of the link packet duplicate value.
+#****
proc setLinkDup { link value } {
global $link
return
}
+#****f* linkcfg.tcl/getLinkMirror
+# NAME
+# getLinkMirror -- get link's mirror link
+# SYNOPSIS
+# set mirror_link_id [getLinkMirror $link_id]
+# FUNCTION
+# Returns the value of the link's mirror link. Mirror link is the other
+# part of the link connecting node to a pseudo node. Two mirror links
+# present only one physical link.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * mirror_link_id -- Mirror link id
+#****
proc getLinkMirror { link } {
global $link
return [lindex $entry 1]
}
+#****f* linkcfg.tcl/setLinkMirror
+# NAME
+# setLinkMirror -- set link's mirror link
+# SYNOPSIS
+# setLinkMirror $link_id $mirror_link_id
+# FUNCTION
+# Sets the value of the link's mirror link. Mirror link is the other
+# part of the link connecting node to a pseudo node. Two mirror links
+# present only one physical link.
+# INPUTS
+# * link_id -- link id
+# RESULT
+# * mirror_link_id -- Mirror link id
+#****
proc setLinkMirror { link value } {
global $link
return
}
+#****f* linkcfg.tcl/splitLink
+# NAME
+# splitLink -- slit the link
+# SYNOPSIS
+# set nodes [splitLink $link_id $nodetype]
+# FUNCTION
+# Splits the link in two parts. Each part of the split link is one
+# pseudo link.
+# INPUTS
+# * link_id -- link id
+# * nodetype -- type of the new nodes connecting slit links.
+# Usual value is pseudo.
+# RESULT
+# * nodes -- list of node ids of new nodes.
+#****
proc splitLink { link nodetype } {
global link_list $link
set orig_node1 [lindex $orig_nodes 0]
set orig_node2 [lindex $orig_nodes 1]
set new_node1 [newNode $nodetype]
- set new_node2 [newNode $nodetype]
+ set new_node2 [newNode $nodeSplits the link in two parts.type]
set new_link1 [newObjectId link]
lappend link_list $new_link1
set new_link2 [newObjectId link]
return "$new_node1 $new_node2"
}
+#****f* linkcfg.tcl/mergeLink
+# NAME
+# mergeLink -- merge the link
+# SYNOPSIS
+# set new_link_id [mergeLink $link_id]
+# FUNCTION
+# Rebuilts a link from two pseudo link.
+# INPUTS
+# * link_id -- pseudo link id
+# RESULT
+# * new_link_id -- rebuilt link id.
+#****
proc mergeLink { link } {
global link_list node_list
return $new_link
}
+#****f* linkcfg.tcl/newLink
+# NAME
+# newLink -- create new link
+# SYNOPSIS
+# set new_link_id [newLink $node1_id $node2_id]
+# FUNCTION
+# Creates a new link between nodes node1_id and node2_id. The order of
+# nodes is irrelevant.
+# INPUTS
+# * node1_id -- node id of the peer node
+# * node2_id -- node id of the second peer node
+# RESULT
+# * new_link_id -- new link id.
+#****
proc newLink { lnode1 lnode2 } {
global link_list
return $link
}
+#****f* linkcfg.tcl/linkByIfc
+# NAME
+# linkByIfg -- get link by interface
+# SYNOPSIS
+# set link_id [linkByIfc $node_id $fc]
+# FUNCTION
+# Returns the link id of the link connecting the node's interface
+# INPUTS
+# * node_id -- node id
+# * ifc -- interface
+# RESULT
+# * link_id -- link id.
+#****
proc linkByIfc { node ifc } {
global link_list