@@ -333,7 +333,9 @@ function update() {
333
333
"middle" ) . style ( "font-size" , "12px" ) . style ( "fill" , "purple" ) . attr (
334
334
"class" , function ( d ) {
335
335
return "latency " + d . type ;
336
- } ) . text ( function ( d ) {
336
+ } ) . attr ( "id" , function ( d ) {
337
+ return d . id ;
338
+ } ) . text ( function ( d ) {
337
339
return d . latency ? parseFloat ( d . latency ) . toFixed ( 1 ) : '' ;
338
340
} ) ;
339
341
markerText . exit ( ) . remove ( ) ;
@@ -609,7 +611,7 @@ function addFixedLabel(label, x, y, lastLabel) {
609
611
/*
610
612
* Post-rendering method to draw path arcs for the given path and color.
611
613
*/
612
- function drawPath ( res , path , color , latencies ) {
614
+ function drawPath ( res , path , color , lats ) {
613
615
// get the index of the routes to render
614
616
var routes = [ ] ;
615
617
if ( path < 0 ) {
@@ -642,25 +644,44 @@ function drawPath(res, path, color, latencies) {
642
644
graphPath . links = graphPath . links . filter ( function ( link ) {
643
645
return ! link . path ;
644
646
} ) ;
647
+ var fullLat = fullPathLatencies ( lats ) ;
645
648
for ( var i = 0 ; i < path_ids . length - 1 ; i ++ ) {
646
649
// prevent src == dst links from being formed
647
650
if ( path_ids [ i ] != path_ids [ i + 1 ] ) {
648
- console . warn ( latencies )
649
- var latInterIntra = latencies ? ( latencies [ ( i * 2 ) + 1 ] + latencies [ ( i * 2 ) + 2 ] )
650
- : undefined ;
651
+ var linkLat = undefined ;
652
+ if ( fullLat ) {
653
+ // report latency from target AS
654
+ linkLat = lats ? ( lats [ i + 2 ] ) : undefined ;
655
+ }
651
656
graphPath . links . push ( {
652
657
"color" : color ,
653
658
"path" : true ,
654
659
"source" : graphPath [ "ids" ] [ path_ids [ i ] ] ,
655
660
"target" : graphPath [ "ids" ] [ path_ids [ i + 1 ] ] ,
656
661
"type" : "PARENT" ,
657
- "latency" : latInterIntra ,
662
+ "latency" : linkLat ,
663
+ "id" : "path-lat-" + path + "-" + i , // TODO
658
664
} ) ;
659
665
}
660
666
}
661
667
update ( ) ;
662
668
}
663
669
670
+ /**
671
+ * Interrogate latencies for missing values.
672
+ */
673
+ function fullPathLatencies ( lats ) {
674
+ if ( ! lats ) {
675
+ return false ;
676
+ }
677
+ for ( var i = 0 ; i < lats . length ; i ++ ) {
678
+ if ( ! lats [ i ] ) {
679
+ return false ;
680
+ }
681
+ }
682
+ return true ;
683
+ }
684
+
664
685
/*
665
686
* Removes all path arcs from the graph.
666
687
*/
0 commit comments