{"action":"created","comment":{"url":"https://api.github.com/repos/skydive-project/skydive/pulls/comments/174033746","pull_request_review_id":103316541,"id":174033746,"diff_hunk":"@@ -1,6 +1,184 @@\n+const maxClockSkewMillis = 5 * 60 * 1000; // 5 minutes\n+\n+var LinkLabelBandwidth = Vue.extend({\n+  mixins: [apiMixin],\n+\n+  methods: {\n+\n+    bandwidthFromMetrics: function(metrics) {\n+      if (!metrics) {\n+        return 0;\n+      }\n+      if (!metrics.Last) {\n+        return 0;\n+      }\n+      if (!metrics.Start) {\n+        return 0;\n+      }\n+\n+      const totalByte = (metrics.RxBytes || 0) + (metrics.TxBytes || 0);\n+      const deltaMillis = metrics.Last - metrics.Start;\n+      const elapsedMillis = Date.now() - new Date(metrics.Last);\n+\n+      if (deltaMillis === 0) {\n+        return 0;\n+      }\n+      if (elapsedMillis > maxClockSkewMillis) {\n+        return 0;\n+      }\n+\n+      return Math.floor(8 * totalByte * 1000 / deltaMillis); // bits-per-second \n+    },\n+\n+    setup: function(topology) {\n+      this.topology = topology;\n+    },\n+\n+    updateData: function(link) {\n+      if (!link.target.metadata.LastUpdateMetric) {\n+        return;\n+      }\n+\n+      const defaultBandwidthBaseline = 1024 * 1024 * 1024; // 1 gbps\n+\n+      link.bandwidthBaseline = (this.topology.bandwidth.bandwidthThreshold === 'relative') ?\n+        link.target.metadata.Speed || defaultBandwidthBaseline : 1;\n+\n+      link.bandwidthAbsolute = this.bandwidthFromMetrics(link.target.metadata.LastUpdateMetric);\n+      link.bandwidth = link.bandwidthAbsolute / link.bandwidthBaseline;\n+    },\n+ \n+    hasData: function(link) {\n+      if (!link.target.metadata.LastUpdateMetric) {\n+        return false;\n+      }\n+\n+      if (!link.bandwidth) {\n+        return false;\n+      }\n+      return link.bandwidth > this.topology.bandwidth.active;\n+    },\n+\n+    getText: function(link) {\n+      return bandwidthToString(link.bandwidthAbsolute);\n+    },\n+\n+    isActive: function(link) {\n+      return (link.bandwidth > this.topology.bandwidth.active) && (link.bandwidth < this.topology.bandwidth.warning);\n+    },\n+\n+    isWarning: function(link) {\n+      return (link.bandwidth >= this.topology.bandwidth.warning) && (link.bandwidth < this.topology.bandwidth.alert);\n+    },\n+\n+    isAlert: function(link) {\n+      return link.bandwidth >= this.topology.bandwidth.alert;\n+    },\n+  },\n+});\n+\n+var LinkLabelLatency = Vue.extend({\n+  mixins: [apiMixin],\n+\n+  methods: {\n+    setup: function(topology) {\n+      this.active = 0;\n+      this.warning = 10\n+      this.alert = 100;\n+    },\n+\n+    flowKey: function(a) {\n+      return `TrackingID:${a.TrackingID},ANodeTID:${a.ANodeTID},BNodeTID:${a.BNodeTID}`;\n+    },\n+\n+    flowCompare: function(a, b) {\n+      const keya = this.flowKey(a);\n+      const keyb = this.flowKey(b);\n+      return keya.localeCompare(keyb);\n+    },\n+\n+    updateLatency: function(link, flows) {\n+      let prev, curr;\n+      for (let i in flows) {\n+        prev = curr;\n+        curr = flows[i];\n+\n+        if (!prev) {\n+          continue;\n+        }\n+\n+        if (this.flowKey(curr) != this.flowKey(prev)) {\n+          continue;\n+        }\n+\n+        link.latencyTimestamp = Math.max(curr.Last, prev.Last);\n+        link.latency = Math.abs(curr.RTT - prev.RTT) / 1000;","path":"statics/js/components/graph-layout.js","position":115,"original_position":115,"commit_id":"b2878052fab2ea35c6559390893e190246059cdf","original_commit_id":"be62592be9b01212e55392175719431d234dfa28","user":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars0.githubusercontent.com/u/2760739?v=4","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2018-03-13T07:19:56Z","updated_at":"2018-03-13T07:19:56Z","html_url":"https://github.com/skydive-project/skydive/pull/826#discussion_r174033746","pull_request_url":"https://api.github.com/repos/skydive-project/skydive/pulls/826","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/skydive-project/skydive/pulls/comments/174033746"},"html":{"href":"https://github.com/skydive-project/skydive/pull/826#discussion_r174033746"},"pull_request":{"href":"https://api.github.com/repos/skydive-project/skydive/pulls/826"}},"in_reply_to_id":173880873},"pull_request":{"url":"https://api.github.com/repos/skydive-project/skydive/pulls/826","id":172283871,"html_url":"https://github.com/skydive-project/skydive/pull/826","diff_url":"https://github.com/skydive-project/skydive/pull/826.diff","patch_url":"https://github.com/skydive-project/skydive/pull/826.patch","issue_url":"https://api.github.com/repos/skydive-project/skydive/issues/826","number":826,"state":"open","locked":false,"title":"Ui link latency ","user":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars0.githubusercontent.com/u/2760739?v=4","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"body":"Have added option to toggle to latency on link labels.\r\n\r\nHow to use? for now this is exposed via launch context or URL parameter: `link_label_type=latency` if not specified then the default is `bandwidth` as was before.\r\n\r\nThe calculation of latency is by calculating the delta between `Math.abs(ANode.RTT-BNode.RTT)/1000`, with the underlying assumption that clocks are synchronized between nodes.\r\n\r\nSo as not to stress the system only visible nodes which has Capture enabled participate in latency calculation.\r\n\r\nA possible test setup:\r\n\r\n```\r\nsudo ./scripts/simple.sh start 10.0.0.1/24 10.0.0.2/24\r\nsudo ifconfig vm1-eth0 10.0.0.1\r\nsudo ifconfig vm2-eth0 10.0.0.2\r\nsudo ip netns exec vm1 tc qdisc add dev eth0 root netem delay 100ms\r\nsudo tc qdisc add dev vm1-eth0 root netem delay 200ms\r\nsudo tc qdisc add dev vm2-eth0 root netem delay 400ms\r\nsudo ip netns exec vm2 tc qdisc add dev eth0 root netem delay 800ms\r\n```\r\n\r\nYou can now inject traffic running:\r\n\r\n```\r\nsudo ip netns vm1 ping 10.0.0.2 -c 1\r\n```\r\n","created_at":"2018-03-01T16:19:41Z","updated_at":"2018-03-13T07:19:56Z","closed_at":null,"merged_at":null,"merge_commit_sha":"50725dd034b2c41176ffa48fb600e944133eedb1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/skydive-project/skydive/pulls/826/commits","review_comments_url":"https://api.github.com/repos/skydive-project/skydive/pulls/826/comments","review_comment_url":"https://api.github.com/repos/skydive-project/skydive/pulls/comments{/number}","comments_url":"https://api.github.com/repos/skydive-project/skydive/issues/826/comments","statuses_url":"https://api.github.com/repos/skydive-project/skydive/statuses/b2878052fab2ea35c6559390893e190246059cdf","head":{"label":"hunchback:ui-link-latency","ref":"ui-link-latency","sha":"b2878052fab2ea35c6559390893e190246059cdf","user":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars0.githubusercontent.com/u/2760739?v=4","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"repo":{"id":108723302,"name":"skydive","full_name":"hunchback/skydive","owner":{"login":"hunchback","id":2760739,"avatar_url":"https://avatars0.githubusercontent.com/u/2760739?v=4","gravatar_id":"","url":"https://api.github.com/users/hunchback","html_url":"https://github.com/hunchback","followers_url":"https://api.github.com/users/hunchback/followers","following_url":"https://api.github.com/users/hunchback/following{/other_user}","gists_url":"https://api.github.com/users/hunchback/gists{/gist_id}","starred_url":"https://api.github.com/users/hunchback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hunchback/subscriptions","organizations_url":"https://api.github.com/users/hunchback/orgs","repos_url":"https://api.github.com/users/hunchback/repos","events_url":"https://api.github.com/users/hunchback/events{/privacy}","received_events_url":"https://api.github.com/users/hunchback/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hunchback/skydive","description":"An open source real-time network topology and protocols analyzer","fork":true,"url":"https://api.github.com/repos/hunchback/skydive","forks_url":"https://api.github.com/repos/hunchback/skydive/forks","keys_url":"https://api.github.com/repos/hunchback/skydive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hunchback/skydive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hunchback/skydive/teams","hooks_url":"https://api.github.com/repos/hunchback/skydive/hooks","issue_events_url":"https://api.github.com/repos/hunchback/skydive/issues/events{/number}","events_url":"https://api.github.com/repos/hunchback/skydive/events","assignees_url":"https://api.github.com/repos/hunchback/skydive/assignees{/user}","branches_url":"https://api.github.com/repos/hunchback/skydive/branches{/branch}","tags_url":"https://api.github.com/repos/hunchback/skydive/tags","blobs_url":"https://api.github.com/repos/hunchback/skydive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hunchback/skydive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hunchback/skydive/git/refs{/sha}","trees_url":"https://api.github.com/repos/hunchback/skydive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hunchback/skydive/statuses/{sha}","languages_url":"https://api.github.com/repos/hunchback/skydive/languages","stargazers_url":"https://api.github.com/repos/hunchback/skydive/stargazers","contributors_url":"https://api.github.com/repos/hunchback/skydive/contributors","subscribers_url":"https://api.github.com/repos/hunchback/skydive/subscribers","subscription_url":"https://api.github.com/repos/hunchback/skydive/subscription","commits_url":"https://api.github.com/repos/hunchback/skydive/commits{/sha}","git_commits_url":"https://api.github.com/repos/hunchback/skydive/git/commits{/sha}","comments_url":"https://api.github.com/repos/hunchback/skydive/comments{/number}","issue_comment_url":"https://api.github.com/repos/hunchback/skydive/issues/comments{/number}","contents_url":"https://api.github.com/repos/hunchback/skydive/contents/{+path}","compare_url":"https://api.github.com/repos/hunchback/skydive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hunchback/skydive/merges","archive_url":"https://api.github.com/repos/hunchback/skydive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hunchback/skydive/downloads","issues_url":"https://api.github.com/repos/hunchback/skydive/issues{/number}","pulls_url":"https://api.github.com/repos/hunchback/skydive/pulls{/number}","milestones_url":"https://api.github.com/repos/hunchback/skydive/milestones{/number}","notifications_url":"https://api.github.com/repos/hunchback/skydive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hunchback/skydive/labels{/name}","releases_url":"https://api.github.com/repos/hunchback/skydive/releases{/id}","deployments_url":"https://api.github.com/repos/hunchback/skydive/deployments","created_at":"2017-10-29T10:07:17Z","updated_at":"2017-10-29T10:07:19Z","pushed_at":"2018-03-13T07:16:23Z","git_url":"git://github.com/hunchback/skydive.git","ssh_url":"git@github.com:hunchback/skydive.git","clone_url":"https://github.com/hunchback/skydive.git","svn_url":"https://github.com/hunchback/skydive","homepage":"","size":35708,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"skydive-project:master","ref":"master","sha":"5d2a28d198eb4bb861679e730a23c36d62355507","user":{"login":"skydive-project","id":19912486,"avatar_url":"https://avatars0.githubusercontent.com/u/19912486?v=4","gravatar_id":"","url":"https://api.github.com/users/skydive-project","html_url":"https://github.com/skydive-project","followers_url":"https://api.github.com/users/skydive-project/followers","following_url":"https://api.github.com/users/skydive-project/following{/other_user}","gists_url":"https://api.github.com/users/skydive-project/gists{/gist_id}","starred_url":"https://api.github.com/users/skydive-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skydive-project/subscriptions","organizations_url":"https://api.github.com/users/skydive-project/orgs","repos_url":"https://api.github.com/users/skydive-project/repos","events_url":"https://api.github.com/users/skydive-project/events{/privacy}","received_events_url":"https://api.github.com/users/skydive-project/received_events","type":"Organization","site_admin":false},"repo":{"id":44610195,"name":"skydive","full_name":"skydive-project/skydive","owner":{"login":"skydive-project","id":19912486,"avatar_url":"https://avatars0.githubusercontent.com/u/19912486?v=4","gravatar_id":"","url":"https://api.github.com/users/skydive-project","html_url":"https://github.com/skydive-project","followers_url":"https://api.github.com/users/skydive-project/followers","following_url":"https://api.github.com/users/skydive-project/following{/other_user}","gists_url":"https://api.github.com/users/skydive-project/gists{/gist_id}","starred_url":"https://api.github.com/users/skydive-project/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/skydive-project/subscriptions","organizations_url":"https://api.github.com/users/skydive-project/orgs","repos_url":"https://api.github.com/users/skydive-project/repos","events_url":"https://api.github.com/users/skydive-project/events{/privacy}","received_events_url":"https://api.github.com/users/skydive-project/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/skydive-project/skydive","description":"An open source real-time network topology and protocols analyzer","fork":false,"url":"https://api.github.com/repos/skydive-project/skydive","forks_url":"https://api.github.com/repos/skydive-project/skydive/forks","keys_url":"https://api.github.com/repos/skydive-project/skydive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/skydive-project/skydive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/skydive-project/skydive/teams","hooks_url":"https://api.github.com/repos/skydive-project/skydive/hooks","issue_events_url":"https://api.github.com/repos/skydive-project/skydive/issues/events{/number}","events_url":"https://api.github.com/repos/skydive-project/skydive/events","assignees_url":"https://api.github.com/repos/skydive-project/skydive/assignees{/user}","branches_url":"https://api.github.com/repos/skydive-project/skydive/branches{/branch}","tags_url":"https://api.github.com/repos/skydive-project/skydive/tags","blobs_url":"https://api.github.com/repos/skydive-project/skydive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/skydive-project/skydive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/skydive-project/skydive/git/refs{/sha}","trees_url":"https://api.github.com/repos/skydive-project/skydive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/skydive-project/skydive/statuses/{sha}","languages_url":"https://api.github.com/repos/skydive-project/skydive/languages","stargazers_url":"https://api.github.com/repos/skydive-project/skydive/stargazers","contributors_url":"https://api.github.com/repos/skydive-project/skydive/contributors","subscribers_url":"https://api.github.com/repos/skydive-project/skydive/subscribers","subscription_url":"https://api.github.com/repos/skydive-project/skydive/subscription","commits_url":"https://api.github.com/repos/skydive-project/skydive/commits{/sha}","git_commits_url":"https://api.github.com/repos/skydive-project/skydive/git/commits{/sha}","comments_url":"https://api.github.com/repos/skydive-project/skydive/comments{/number}","issue_comment_url":"https://api.github.com/repos/skydive-project/skydive/issues/comments{/number}","contents_url":"https://api.github.com/repos/skydive-project/skydive/contents/{+path}","compare_url":"https://api.github.com/repos/skydive-project/skydive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/skydive-project/skydive/merges","archive_url":"https://api.github.com/repos/skydive-project/skydive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/skydive-project/skydive/downloads","issues_url":"https://api.github.com/repos/skydive-project/skydive/issues{/number}","pulls_url":"https://api.github.com/repos/skydive-project/skydive/pulls{/number}","milestones_url":"https://api.github.com/repos/skydive-project/skydive/milestones{/number}","notifications_url":"https://api.github.com/repos/skydive-project/skydive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/skydive-project/skydive/labels{/name}","releases_url":"https://api.github.com/repos/skydive-project/skydive/releases{/id}","deployments_url":"https://api.github.com/repos/skydive-project/skydive/deployments","created_at":"2015-10-20T14:02:21Z","updated_at":"2018-03-12T19:40:20Z","pushed_at":"2018-03-13T07:16:25Z","git_url":"git://github.com/skydive-project/skydive.git","ssh_url":"git@github.com:skydive-project/skydive.git","clone_url":"https://github.com/skydive-project/skydive.git","svn_url":"https://github.com/skydive-project/skydive","homepage":"","size":35664,"stargazers_count":595,"watchers_count":595,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":140,"mirror_url":null,"archived":false,"open_issues_count":71,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":140,"open_issues":71,"watchers":595,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/skydive-project/skydive/pulls/826"},"html":{"href":"https://github.com/skydive-project/skydive/pull/826"},"issue":{"href":"https://api.github.com/repos/skydive-project/skydive/issues/826"},"comments":{"href":"https://api.github.com/repos/skydive-project/skydive/issues/826/comments"},"review_comments":{"href":"https://api.github.com/repos/skydive-project/skydive/pulls/826/comments"},"review_comment":{"href":"https://api.github.com/repos/skydive-project/skydive/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/skydive-project/skydive/pulls/826/commits"},"statuses":{"href":"https://api.github.com/repos/skydive-project/skydive/statuses/b2878052fab2ea35c6559390893e190246059cdf"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"hunchback"}}