GUI support for unidirectional link effects; GUI support for link jitter

(Boeing r1796,1797)
This commit is contained in:
ahrenholz 2013-12-02 21:14:14 +00:00
parent 536ff20fff
commit f01ddd7c16
4 changed files with 533 additions and 145 deletions

View file

@ -547,15 +547,15 @@ proc parseLinkMessage { data len flags } {
array set typenames { 1 node1num 2 node2num 3 delay 4 bw 5 per \
6 dup 7 jitter 8 mer 9 burst 10 session \
16 mburst 32 ltype 33 guiattr \
16 mburst 32 ltype 33 guiattr 34 uni \
35 emuid1 36 netid 37 key \
48 if1num 49 if1ipv4 50 if1ipv4mask 51 if1mac \
52 if1ipv6 53 if1ipv6mask \
54 if2num 55 if2ipv4 56 if2ipv4mask 57 if2mac \
64 if2ipv6 65 if2ipv6mask }
array set typesizes { node1num 4 node2num 4 delay 8 bw 8 per -1 \
dup -1 jitter 2 mer 2 burst 2 session -1 \
mburst 2 ltype 4 guiattr -1 \
dup -1 jitter 8 mer 2 burst 2 session -1 \
mburst 2 ltype 4 guiattr -1 uni 2 \
emuid1 4 netid 4 key 4 \
if1num 2 if1ipv4 4 if1ipv4mask 2 if1mac 8 \
if1ipv6 16 if1ipv6mask 2 \
@ -563,7 +563,7 @@ proc parseLinkMessage { data len flags } {
if2ipv6 16 if2ipv6mask 2 }
array set vals { node1num -1 node2num -1 delay 0 bw 0 per "" \
dup "" jitter 0 mer 0 burst 0 session "" \
mburst 0 ltype 0 guiattr "" \
mburst 0 ltype 0 guiattr "" uni 0 \
emuid1 -1 netid -1 key -1 \
if1num -1 if1ipv4 -1 if1ipv4mask 24 if1mac -1 \
if1ipv6 -1 if1ipv6mask 64 \
@ -726,20 +726,6 @@ proc apiLinkAddModify { node1 node2 vals_ref add } {
set c .c
upvar $vals_ref vals
set labelstr ""; # build a label string
if {$vals(bw) > 0} { set labelstr "$labelstr$vals(bw) " }
if {$vals(delay) > 0} { set labelstr \
"$labelstr[expr $vals(delay)/1000] ms " }
if {$vals(per) > 0} { set labelstr "${labelstr}E=$vals(per)% " }
if {$vals(dup) > 0} { set labelstr "${labelstr}D=$vals(dup)% " }
if {$vals(jitter) > 0} {
set labelstr "${labelstr}J=[expr $vals(jitter)/1000] ms " }
set params ""; # parameters to send to ng_wlan netgraph node
if { $labelstr != "" } {
set params "delay=$vals(delay) bandwidth=$vals(bw) per=$vals(per)"
set params "$params duplicate=$vals(dup) jitter=$vals(jitter)"
}
if {$vals(key) > -1} {
if { [nodeType $node1] == "tunnel" } {
netconfInsertSection $node1 [list "tunnel-key" $vals(key)]
@ -753,11 +739,33 @@ proc apiLinkAddModify { node1 node2 vals_ref add } {
set wired_link [linkByPeers $node1 $node2]
if { $wired_link != "" && $add == 0 } { ;# wired link exists, modify it
#puts "modify wired link"
setLinkBandwidth $wired_link $vals(bw)
setLinkDelay $wired_link $vals(delay)
setLinkBER $wired_link $vals(per)
setLinkDup $wired_link $vals(dup)
setLinkJitter $wired_link $vals(jitter)
if { $vals(uni) == 1 } { ;# unidirectional link effects message
set peers [linkPeers $wired_link]
if { $node1 == [lindex $peers 0] } { ;# downstream n1 <-- n2
set bw [list $vals(bw) [getLinkBandwidth $wired_link up]]
set delay [list $vals(delay) [getLinkDelay $wired_link up]]
set per [list $vals(per) [getLinkBER $wired_link up]]
set dup [list $vals(dup) [getLinkBER $wired_link up]]
set jitter [list $vals(jitter) [getLinkJitter $wired_link up]]
} else { ;# upstream n1 --> n2
set bw [list [getLinkBandwidth $wired_link] $vals(bw)]
set delay [list [getLinkDelay $wired_link] $vals(delay)]
set per [list [getLinkBER $wired_link] $vals(per)]
set dup [list [getLinkBER $wired_link] $vals(dup)]
set jitter [list $vals(jitter) [getLinkJitter $wired_link]]
}
setLinkBandwidth $wired_link $bw
setLinkDelay $wired_link $delay
setLinkBER $wired_link $per
setLinkDup $wired_link $dup
setLinkJitter $wired_link $jitter
} else {
setLinkBandwidth $wired_link $vals(bw)
setLinkDelay $wired_link $vals(delay)
setLinkBER $wired_link $vals(per)
setLinkDup $wired_link $vals(dup)
setLinkJitter $wired_link $vals(jitter)
}
updateLinkLabel $wired_link
updateLinkGuiAttr $wired_link $vals(guiattr)
return
@ -1896,7 +1904,7 @@ proc sendNodeDelMessage { channel node } {
# send a message to build, modify, or delete a link
# type should indicate add/delete/link/unlink
proc sendLinkMessage { channel link type } {
proc sendLinkMessage { channel link type {sendboth true} } {
global showAPI
set prmsg $showAPI
@ -1915,6 +1923,12 @@ proc sendLinkMessage { channel link type } {
set node1_num [string range $node1 1 end]
set node2_num [string range $node2 1 end]
# flag for sending unidirectional link messages
set uni 0
if { $sendboth && [isLinkUni $link] } {
set uni 1
}
# set flags and link message type from supplied type parameter
set flags 0
set ltype 1 ;# add/delete a link (not wireless link/unlink)
@ -1948,6 +1962,8 @@ proc sendLinkMessage { channel link type } {
set len [expr {8+8+8}]
set delay [getLinkDelay $link]
if { $delay == "" } { set delay 0 }
set jitter [getLinkJitter $link]
if { $jitter == "" } { set jitter 0 }
set bw [getLinkBandwidth $link]
if { $bw == "" } { set bw 0 }
set per [getLinkBER $link]; # PER and BER
@ -1959,16 +1975,20 @@ proc sendLinkMessage { channel link type } {
set dup_len 0
set dup_msg [buildStringTLV 0x6 $dup dup_len]
if { $type != "delete" } {
incr len [expr {12+12+$per_len+$dup_len}] ;# delay,bw,per,dup
incr len [expr {12+12+$per_len+$dup_len+12}] ;# delay,bw,per,dup,jitter
if {$prmsg==1 } {
puts -nonewline "$delay,$bw,$per,$dup,"
puts -nonewline "$delay,$bw,$per,$dup,$jitter,"
}
}
# TODO: jitter, mer, burst, mburst
# TODO: mer, burst, mburst
if { $prmsg == 1 } { puts -nonewline "type=$ltype," }
if { $uni } {
incr len 4
if { $prmsg == 1 } { puts -nonewline "uni=$uni," }
}
if { $netid > -1 } {
incr len 8
if { $prmsg == 1 } { puts -nonewline ",netid=$netid" }
if { $prmsg == 1 } { puts -nonewline "netid=$netid," }
}
if { $key != "" } {
incr len 8
@ -2012,12 +2032,18 @@ proc sendLinkMessage { channel link type } {
puts -nonewline $channel [binary format c2sW {0x4 8} 0 $bw]
puts -nonewline $channel $per_msg
puts -nonewline $channel $dup_msg
puts -nonewline $channel [binary format c2sW {0x7 8} 0 $jitter]
}
# TODO: jitter, mer, burst, mburst
# TODO: mer, burst, mburst
# link type
puts -nonewline $channel [binary format c2sI {0x20 4} 0 $ltype]
# unidirectional flag
if { $uni } {
puts -nonewline $channel [binary format c2S {0x22 2} $uni]
}
# network ID
if { $netid > -1 } {
puts -nonewline $channel [binary format c2sI {0x24 4} 0 $netid]
@ -2061,6 +2087,73 @@ proc sendLinkMessage { channel link type } {
if { $prmsg==1 } { puts ")" }
flushChannel channel "Error sending link message"
##########################################################
# send a second Link Message for unidirectional link effects
if { $uni < 1 } {
return
}
# first calculate length and possibly print the message
set flags 0
if { $prmsg == 1 } {
puts -nonewline ">LINK(flags=$flags,$node2_num-$node1_num,"
}
set len [expr {8+8+8}] ;# len = node2num, node1num (swapped), type
set delay [getLinkDelay $link up]
if { $delay == "" } { set delay 0 }
set jitter [getLinkJitter $link up]
if { $jitter == "" } { set jitter 0 }
set bw [getLinkBandwidth $link up]
if { $bw == "" } { set bw 0 }
set per [getLinkBER $link up]; # PER and BER
if { $per == "" } { set per 0 }
set per_len 0
set per_msg [buildStringTLV 0x5 $per per_len]
set dup [getLinkDup $link up]
if { $dup == "" } { set dup 0 }
set dup_len 0
set dup_msg [buildStringTLV 0x6 $dup dup_len]
incr len [expr {12+12+$per_len+$dup_len+12}] ;# delay,bw,per,dup,jitter
if {$prmsg==1 } {
puts -nonewline "$delay,$bw,$per,$dup,$jitter,"
}
if { $prmsg == 1 } { puts -nonewline "type=$ltype," }
incr len 4 ;# unidirectional flag
if { $prmsg == 1 } { puts -nonewline "uni=$uni," }
# note that if1num / if2num are reversed here due to reversed node nums
if { $if2num >= 0 && ([[typemodel $node2].layer] == "NETWORK" || \
[nodeType $node2] == "tunnel") } {
incr len 4
if { $prmsg == 1 } { puts -nonewline "if1n=$if2num," }
}
if { $if1num >= 0 && ([[typemodel $node1].layer] == "NETWORK" || \
[nodeType $node1] == "tunnel") } {
incr len 4
if { $prmsg == 1 } { puts -nonewline "if2n=$if1num," }
}
# build and send the link message
set msg [binary format ccSc2sIc2sI \
{0x2} $flags $len \
{0x1 4} 0 $node2_num \
{0x2 4} 0 $node1_num ]
puts -nonewline $channel $msg
puts -nonewline $channel [binary format c2sW {0x3 8} 0 $delay]
puts -nonewline $channel [binary format c2sW {0x4 8} 0 $bw]
puts -nonewline $channel $per_msg
puts -nonewline $channel $dup_msg
puts -nonewline $channel [binary format c2sW {0x7 8} 0 $jitter]
puts -nonewline $channel [binary format c2sI {0x20 4} 0 $ltype]
puts -nonewline $channel [binary format c2S {0x22 2} $uni]
if { $if2num >= 0 && ([[typemodel $node2].layer] == "NETWORK" || \
[nodeType $node2] == "tunnel") } {
puts -nonewline $channel [ binary format c2S {0x30 2} $if2num ]
}
if { $if1num >= 0 && ([[typemodel $node1].layer] == "NETWORK" || \
[nodeType $node1] == "tunnel") } {
puts -nonewline $channel [ binary format c2S {0x36 2} $if1num ]
}
if { $prmsg==1 } { puts ")" }
flushChannel channel "Error sending link message"
}
# helper to get IPv4, IPv6, MAC address and increment length
@ -2539,7 +2632,7 @@ proc shutdownSession {} {
continue; # remote routers are ctrl. by GUI; TODO: move to daemon
}
sendLinkMessage $sock $link delete
sendLinkMessage $sock $link delete false
}
# shut down all nodes
foreach node $node_list {