{"action":"created","comment":{"url":"https://api.github.com/repos/AutoRoute/l2/pulls/comments/52973248","id":52973248,"diff_hunk":"@@ -0,0 +1,93 @@\n+package l2\n+\n+import (\n+\t\"log\"\n+\t\"time\"\n+)\n+\n+// This is a wrapper that can take a device and limit the bandwidth that can\n+// go through it.\n+type deviceWithLatency struct {\n+\tdev FrameReadWriteCloser\n+\n+\t// Maximum number of outgoing bytes per second.\n+\tsend_bandwidth int\n+\t// Maximum number of incoming bytes per second.\n+\treceive_bandwidth int\n+\t// How much data we wrote the last time we called WriteFrame().\n+\tlast_write_size int\n+\t// How much data we read the last time we called ReadFrame().\n+\tlast_read_size int\n+}\n+\n+// Basically initializes latency and then delegates to the tapDevice version of\n+// NewTapDevice.\n+// Args:\n+//\tmac: MAC address of the device.\n+//  dev: A name for the device.\n+//\tsend_bandwidth: Maximum number of outgoing bytes per second.\n+//  receive_bandwidth: Maximum number of incoming bytes per second.\n+// Returns:\n+//\tThe new tap device, error.\n+func NewTapDeviceWithLatency(mac, dev string, send_bandwidth,\n+\treceive_bandwidth int) (FrameReadWriteCloser, error) {\n+\ttap, err := NewTapDevice(mac, dev)\n+\tif err != nil {\n+\t\treturn nil, err\n+\t}\n+\n+\tvar wrapped_tap deviceWithLatency\n+\twrapped_tap.dev = tap\n+\twrapped_tap.send_bandwidth = send_bandwidth\n+\twrapped_tap.receive_bandwidth = receive_bandwidth\n+\twrapped_tap.last_read_size = 0","path":"latency.go","position":43,"original_position":43,"commit_id":"ab6cb8b11c3437acad42ce2c0246a79fdcad2d96","original_commit_id":"ab6cb8b11c3437acad42ce2c0246a79fdcad2d96","user":{"login":"c00w","id":486199,"avatar_url":"https://avatars.githubusercontent.com/u/486199?v=3","gravatar_id":"","url":"https://api.github.com/users/c00w","html_url":"https://github.com/c00w","followers_url":"https://api.github.com/users/c00w/followers","following_url":"https://api.github.com/users/c00w/following{/other_user}","gists_url":"https://api.github.com/users/c00w/gists{/gist_id}","starred_url":"https://api.github.com/users/c00w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c00w/subscriptions","organizations_url":"https://api.github.com/users/c00w/orgs","repos_url":"https://api.github.com/users/c00w/repos","events_url":"https://api.github.com/users/c00w/events{/privacy}","received_events_url":"https://api.github.com/users/c00w/received_events","type":"User","site_admin":false},"body":"These two lines are unneeded.","created_at":"2016-02-16T06:41:52Z","updated_at":"2016-02-16T06:41:52Z","html_url":"https://github.com/AutoRoute/l2/pull/4#discussion_r52973248","pull_request_url":"https://api.github.com/repos/AutoRoute/l2/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/AutoRoute/l2/pulls/comments/52973248"},"html":{"href":"https://github.com/AutoRoute/l2/pull/4#discussion_r52973248"},"pull_request":{"href":"https://api.github.com/repos/AutoRoute/l2/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/AutoRoute/l2/pulls/4","id":59302043,"html_url":"https://github.com/AutoRoute/l2/pull/4","diff_url":"https://github.com/AutoRoute/l2/pull/4.diff","patch_url":"https://github.com/AutoRoute/l2/pull/4.patch","issue_url":"https://api.github.com/repos/AutoRoute/l2/issues/4","number":4,"state":"open","locked":false,"title":"Add means for limiting bandwidth under testing conditions.","user":{"login":"djpetti","id":7475340,"avatar_url":"https://avatars.githubusercontent.com/u/7475340?v=3","gravatar_id":"","url":"https://api.github.com/users/djpetti","html_url":"https://github.com/djpetti","followers_url":"https://api.github.com/users/djpetti/followers","following_url":"https://api.github.com/users/djpetti/following{/other_user}","gists_url":"https://api.github.com/users/djpetti/gists{/gist_id}","starred_url":"https://api.github.com/users/djpetti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/djpetti/subscriptions","organizations_url":"https://api.github.com/users/djpetti/orgs","repos_url":"https://api.github.com/users/djpetti/repos","events_url":"https://api.github.com/users/djpetti/events{/privacy}","received_events_url":"https://api.github.com/users/djpetti/received_events","type":"User","site_admin":false},"body":"This needs integration with the loopback stuff to be actually useful, but I thought I'd get it merged here first.","created_at":"2016-02-14T18:29:49Z","updated_at":"2016-02-16T06:41:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"002bfa5ded8d0b6ed52ec232801b4a0e6d44fa92","assignee":{"login":"c00w","id":486199,"avatar_url":"https://avatars.githubusercontent.com/u/486199?v=3","gravatar_id":"","url":"https://api.github.com/users/c00w","html_url":"https://github.com/c00w","followers_url":"https://api.github.com/users/c00w/followers","following_url":"https://api.github.com/users/c00w/following{/other_user}","gists_url":"https://api.github.com/users/c00w/gists{/gist_id}","starred_url":"https://api.github.com/users/c00w/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/c00w/subscriptions","organizations_url":"https://api.github.com/users/c00w/orgs","repos_url":"https://api.github.com/users/c00w/repos","events_url":"https://api.github.com/users/c00w/events{/privacy}","received_events_url":"https://api.github.com/users/c00w/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/AutoRoute/l2/pulls/4/commits","review_comments_url":"https://api.github.com/repos/AutoRoute/l2/pulls/4/comments","review_comment_url":"https://api.github.com/repos/AutoRoute/l2/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AutoRoute/l2/issues/4/comments","statuses_url":"https://api.github.com/repos/AutoRoute/l2/statuses/ab6cb8b11c3437acad42ce2c0246a79fdcad2d96","head":{"label":"AutoRoute:artificial_latency","ref":"artificial_latency","sha":"ab6cb8b11c3437acad42ce2c0246a79fdcad2d96","user":{"login":"AutoRoute","id":10801321,"avatar_url":"https://avatars.githubusercontent.com/u/10801321?v=3","gravatar_id":"","url":"https://api.github.com/users/AutoRoute","html_url":"https://github.com/AutoRoute","followers_url":"https://api.github.com/users/AutoRoute/followers","following_url":"https://api.github.com/users/AutoRoute/following{/other_user}","gists_url":"https://api.github.com/users/AutoRoute/gists{/gist_id}","starred_url":"https://api.github.com/users/AutoRoute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AutoRoute/subscriptions","organizations_url":"https://api.github.com/users/AutoRoute/orgs","repos_url":"https://api.github.com/users/AutoRoute/repos","events_url":"https://api.github.com/users/AutoRoute/events{/privacy}","received_events_url":"https://api.github.com/users/AutoRoute/received_events","type":"Organization","site_admin":false},"repo":{"id":30163299,"name":"l2","full_name":"AutoRoute/l2","owner":{"login":"AutoRoute","id":10801321,"avatar_url":"https://avatars.githubusercontent.com/u/10801321?v=3","gravatar_id":"","url":"https://api.github.com/users/AutoRoute","html_url":"https://github.com/AutoRoute","followers_url":"https://api.github.com/users/AutoRoute/followers","following_url":"https://api.github.com/users/AutoRoute/following{/other_user}","gists_url":"https://api.github.com/users/AutoRoute/gists{/gist_id}","starred_url":"https://api.github.com/users/AutoRoute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AutoRoute/subscriptions","organizations_url":"https://api.github.com/users/AutoRoute/orgs","repos_url":"https://api.github.com/users/AutoRoute/repos","events_url":"https://api.github.com/users/AutoRoute/events{/privacy}","received_events_url":"https://api.github.com/users/AutoRoute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AutoRoute/l2","description":"Layer 2 Manipulation Libraries","fork":false,"url":"https://api.github.com/repos/AutoRoute/l2","forks_url":"https://api.github.com/repos/AutoRoute/l2/forks","keys_url":"https://api.github.com/repos/AutoRoute/l2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AutoRoute/l2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AutoRoute/l2/teams","hooks_url":"https://api.github.com/repos/AutoRoute/l2/hooks","issue_events_url":"https://api.github.com/repos/AutoRoute/l2/issues/events{/number}","events_url":"https://api.github.com/repos/AutoRoute/l2/events","assignees_url":"https://api.github.com/repos/AutoRoute/l2/assignees{/user}","branches_url":"https://api.github.com/repos/AutoRoute/l2/branches{/branch}","tags_url":"https://api.github.com/repos/AutoRoute/l2/tags","blobs_url":"https://api.github.com/repos/AutoRoute/l2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AutoRoute/l2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AutoRoute/l2/git/refs{/sha}","trees_url":"https://api.github.com/repos/AutoRoute/l2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AutoRoute/l2/statuses/{sha}","languages_url":"https://api.github.com/repos/AutoRoute/l2/languages","stargazers_url":"https://api.github.com/repos/AutoRoute/l2/stargazers","contributors_url":"https://api.github.com/repos/AutoRoute/l2/contributors","subscribers_url":"https://api.github.com/repos/AutoRoute/l2/subscribers","subscription_url":"https://api.github.com/repos/AutoRoute/l2/subscription","commits_url":"https://api.github.com/repos/AutoRoute/l2/commits{/sha}","git_commits_url":"https://api.github.com/repos/AutoRoute/l2/git/commits{/sha}","comments_url":"https://api.github.com/repos/AutoRoute/l2/comments{/number}","issue_comment_url":"https://api.github.com/repos/AutoRoute/l2/issues/comments{/number}","contents_url":"https://api.github.com/repos/AutoRoute/l2/contents/{+path}","compare_url":"https://api.github.com/repos/AutoRoute/l2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AutoRoute/l2/merges","archive_url":"https://api.github.com/repos/AutoRoute/l2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AutoRoute/l2/downloads","issues_url":"https://api.github.com/repos/AutoRoute/l2/issues{/number}","pulls_url":"https://api.github.com/repos/AutoRoute/l2/pulls{/number}","milestones_url":"https://api.github.com/repos/AutoRoute/l2/milestones{/number}","notifications_url":"https://api.github.com/repos/AutoRoute/l2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AutoRoute/l2/labels{/name}","releases_url":"https://api.github.com/repos/AutoRoute/l2/releases{/id}","deployments_url":"https://api.github.com/repos/AutoRoute/l2/deployments","created_at":"2015-02-01T23:11:14Z","updated_at":"2015-03-01T05:06:31Z","pushed_at":"2016-02-16T01:32:59Z","git_url":"git://github.com/AutoRoute/l2.git","ssh_url":"git@github.com:AutoRoute/l2.git","clone_url":"https://github.com/AutoRoute/l2.git","svn_url":"https://github.com/AutoRoute/l2","homepage":null,"size":47,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"AutoRoute:master","ref":"master","sha":"abbc21d9ed8875657b8b34039834cbe8d03a9161","user":{"login":"AutoRoute","id":10801321,"avatar_url":"https://avatars.githubusercontent.com/u/10801321?v=3","gravatar_id":"","url":"https://api.github.com/users/AutoRoute","html_url":"https://github.com/AutoRoute","followers_url":"https://api.github.com/users/AutoRoute/followers","following_url":"https://api.github.com/users/AutoRoute/following{/other_user}","gists_url":"https://api.github.com/users/AutoRoute/gists{/gist_id}","starred_url":"https://api.github.com/users/AutoRoute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AutoRoute/subscriptions","organizations_url":"https://api.github.com/users/AutoRoute/orgs","repos_url":"https://api.github.com/users/AutoRoute/repos","events_url":"https://api.github.com/users/AutoRoute/events{/privacy}","received_events_url":"https://api.github.com/users/AutoRoute/received_events","type":"Organization","site_admin":false},"repo":{"id":30163299,"name":"l2","full_name":"AutoRoute/l2","owner":{"login":"AutoRoute","id":10801321,"avatar_url":"https://avatars.githubusercontent.com/u/10801321?v=3","gravatar_id":"","url":"https://api.github.com/users/AutoRoute","html_url":"https://github.com/AutoRoute","followers_url":"https://api.github.com/users/AutoRoute/followers","following_url":"https://api.github.com/users/AutoRoute/following{/other_user}","gists_url":"https://api.github.com/users/AutoRoute/gists{/gist_id}","starred_url":"https://api.github.com/users/AutoRoute/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AutoRoute/subscriptions","organizations_url":"https://api.github.com/users/AutoRoute/orgs","repos_url":"https://api.github.com/users/AutoRoute/repos","events_url":"https://api.github.com/users/AutoRoute/events{/privacy}","received_events_url":"https://api.github.com/users/AutoRoute/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/AutoRoute/l2","description":"Layer 2 Manipulation Libraries","fork":false,"url":"https://api.github.com/repos/AutoRoute/l2","forks_url":"https://api.github.com/repos/AutoRoute/l2/forks","keys_url":"https://api.github.com/repos/AutoRoute/l2/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AutoRoute/l2/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AutoRoute/l2/teams","hooks_url":"https://api.github.com/repos/AutoRoute/l2/hooks","issue_events_url":"https://api.github.com/repos/AutoRoute/l2/issues/events{/number}","events_url":"https://api.github.com/repos/AutoRoute/l2/events","assignees_url":"https://api.github.com/repos/AutoRoute/l2/assignees{/user}","branches_url":"https://api.github.com/repos/AutoRoute/l2/branches{/branch}","tags_url":"https://api.github.com/repos/AutoRoute/l2/tags","blobs_url":"https://api.github.com/repos/AutoRoute/l2/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AutoRoute/l2/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AutoRoute/l2/git/refs{/sha}","trees_url":"https://api.github.com/repos/AutoRoute/l2/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AutoRoute/l2/statuses/{sha}","languages_url":"https://api.github.com/repos/AutoRoute/l2/languages","stargazers_url":"https://api.github.com/repos/AutoRoute/l2/stargazers","contributors_url":"https://api.github.com/repos/AutoRoute/l2/contributors","subscribers_url":"https://api.github.com/repos/AutoRoute/l2/subscribers","subscription_url":"https://api.github.com/repos/AutoRoute/l2/subscription","commits_url":"https://api.github.com/repos/AutoRoute/l2/commits{/sha}","git_commits_url":"https://api.github.com/repos/AutoRoute/l2/git/commits{/sha}","comments_url":"https://api.github.com/repos/AutoRoute/l2/comments{/number}","issue_comment_url":"https://api.github.com/repos/AutoRoute/l2/issues/comments{/number}","contents_url":"https://api.github.com/repos/AutoRoute/l2/contents/{+path}","compare_url":"https://api.github.com/repos/AutoRoute/l2/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AutoRoute/l2/merges","archive_url":"https://api.github.com/repos/AutoRoute/l2/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AutoRoute/l2/downloads","issues_url":"https://api.github.com/repos/AutoRoute/l2/issues{/number}","pulls_url":"https://api.github.com/repos/AutoRoute/l2/pulls{/number}","milestones_url":"https://api.github.com/repos/AutoRoute/l2/milestones{/number}","notifications_url":"https://api.github.com/repos/AutoRoute/l2/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AutoRoute/l2/labels{/name}","releases_url":"https://api.github.com/repos/AutoRoute/l2/releases{/id}","deployments_url":"https://api.github.com/repos/AutoRoute/l2/deployments","created_at":"2015-02-01T23:11:14Z","updated_at":"2015-03-01T05:06:31Z","pushed_at":"2016-02-16T01:32:59Z","git_url":"git://github.com/AutoRoute/l2.git","ssh_url":"git@github.com:AutoRoute/l2.git","clone_url":"https://github.com/AutoRoute/l2.git","svn_url":"https://github.com/AutoRoute/l2","homepage":null,"size":47,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AutoRoute/l2/pulls/4"},"html":{"href":"https://github.com/AutoRoute/l2/pull/4"},"issue":{"href":"https://api.github.com/repos/AutoRoute/l2/issues/4"},"comments":{"href":"https://api.github.com/repos/AutoRoute/l2/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/AutoRoute/l2/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/AutoRoute/l2/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AutoRoute/l2/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/AutoRoute/l2/statuses/ab6cb8b11c3437acad42ce2c0246a79fdcad2d96"}}}}