{"action":"created","comment":{"url":"https://api.github.com/repos/birarda/hifi/pulls/comments/37295097","id":37295097,"diff_hunk":"@@ -0,0 +1,205 @@\n+//\n+//  CongestionControl.cpp\n+//  libraries/networking/src/udt\n+//\n+//  Created by Clement on 7/23/15.\n+//  Copyright 2015 High Fidelity, Inc.\n+//\n+//  Distributed under the Apache License, Version 2.0.\n+//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html\n+//\n+\n+#include \"CongestionControl.h\"\n+#include \"Packet.h\"\n+\n+using namespace udt;\n+using namespace std::chrono;\n+\n+static const double USECS_PER_SECOND = 1000000.0;\n+\n+void CongestionControl::setPacketSendPeriod(double newSendPeriod) {\n+    Q_ASSERT_X(newSendPeriod >= 0, \"CongestionControl::setPacketPeriod\", \"Can not set a negative packet send period\");\n+    \n+    if (_maxBandwidth > 0) {\n+        // anytime the packet send period is about to be increased, make sure it stays below the minimum period,\n+        // calculated based on the maximum desired bandwidth\n+        double minPacketSendPeriod = USECS_PER_SECOND / (((double) _maxBandwidth) / _mss);\n+        _packetSendPeriod = std::max(newSendPeriod, minPacketSendPeriod);\n+    } else {\n+        _packetSendPeriod = newSendPeriod;\n+    }\n+}\n+\n+void DefaultCC::init() {","path":"libraries/networking/src/udt/CongestionControl.cpp","position":null,"original_position":33,"commit_id":"f039851f13546d877d4179e386282419d6a3b452","original_commit_id":"cf277dca332cc4c7d1b93ff208bf00d222024a0b","user":{"login":"Atlante45","id":4036492,"avatar_url":"https://avatars.githubusercontent.com/u/4036492?v=3","gravatar_id":"","url":"https://api.github.com/users/Atlante45","html_url":"https://github.com/Atlante45","followers_url":"https://api.github.com/users/Atlante45/followers","following_url":"https://api.github.com/users/Atlante45/following{/other_user}","gists_url":"https://api.github.com/users/Atlante45/gists{/gist_id}","starred_url":"https://api.github.com/users/Atlante45/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Atlante45/subscriptions","organizations_url":"https://api.github.com/users/Atlante45/orgs","repos_url":"https://api.github.com/users/Atlante45/repos","events_url":"https://api.github.com/users/Atlante45/events{/privacy}","received_events_url":"https://api.github.com/users/Atlante45/received_events","type":"User","site_admin":false},"body":"Do we do the init right after construction?\r\nOtherwise, we might want to keep `_lastRCTime = high_resolution_clock::now();` in `init()`","created_at":"2015-08-18T13:08:01Z","updated_at":"2015-08-18T13:08:01Z","html_url":"https://github.com/birarda/hifi/pull/12#discussion_r37295097","pull_request_url":"https://api.github.com/repos/birarda/hifi/pulls/12","_links":{"self":{"href":"https://api.github.com/repos/birarda/hifi/pulls/comments/37295097"},"html":{"href":"https://github.com/birarda/hifi/pull/12#discussion_r37295097"},"pull_request":{"href":"https://api.github.com/repos/birarda/hifi/pulls/12"}}},"pull_request":{"url":"https://api.github.com/repos/birarda/hifi/pulls/12","id":40960163,"html_url":"https://github.com/birarda/hifi/pull/12","diff_url":"https://github.com/birarda/hifi/pull/12.diff","patch_url":"https://github.com/birarda/hifi/pull/12.patch","issue_url":"https://api.github.com/repos/birarda/hifi/issues/12","number":12,"state":"open","locked":false,"title":"groundwork for UDT reliable sending","user":{"login":"birarda","id":724069,"avatar_url":"https://avatars.githubusercontent.com/u/724069?v=3","gravatar_id":"","url":"https://api.github.com/users/birarda","html_url":"https://github.com/birarda","followers_url":"https://api.github.com/users/birarda/followers","following_url":"https://api.github.com/users/birarda/following{/other_user}","gists_url":"https://api.github.com/users/birarda/gists{/gist_id}","starred_url":"https://api.github.com/users/birarda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birarda/subscriptions","organizations_url":"https://api.github.com/users/birarda/orgs","repos_url":"https://api.github.com/users/birarda/repos","events_url":"https://api.github.com/users/birarda/events{/privacy}","received_events_url":"https://api.github.com/users/birarda/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-07-27T23:13:08Z","updated_at":"2015-08-18T13:08:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"997b80d23e4537c230c4a7c47ed298839a6fd7c0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/birarda/hifi/pulls/12/commits","review_comments_url":"https://api.github.com/repos/birarda/hifi/pulls/12/comments","review_comment_url":"https://api.github.com/repos/birarda/hifi/pulls/comments{/number}","comments_url":"https://api.github.com/repos/birarda/hifi/issues/12/comments","statuses_url":"https://api.github.com/repos/birarda/hifi/statuses/f039851f13546d877d4179e386282419d6a3b452","head":{"label":"birarda:atp","ref":"atp","sha":"f039851f13546d877d4179e386282419d6a3b452","user":{"login":"birarda","id":724069,"avatar_url":"https://avatars.githubusercontent.com/u/724069?v=3","gravatar_id":"","url":"https://api.github.com/users/birarda","html_url":"https://github.com/birarda","followers_url":"https://api.github.com/users/birarda/followers","following_url":"https://api.github.com/users/birarda/following{/other_user}","gists_url":"https://api.github.com/users/birarda/gists{/gist_id}","starred_url":"https://api.github.com/users/birarda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birarda/subscriptions","organizations_url":"https://api.github.com/users/birarda/orgs","repos_url":"https://api.github.com/users/birarda/repos","events_url":"https://api.github.com/users/birarda/events{/privacy}","received_events_url":"https://api.github.com/users/birarda/received_events","type":"User","site_admin":false},"repo":{"id":9376753,"name":"hifi","full_name":"birarda/hifi","owner":{"login":"birarda","id":724069,"avatar_url":"https://avatars.githubusercontent.com/u/724069?v=3","gravatar_id":"","url":"https://api.github.com/users/birarda","html_url":"https://github.com/birarda","followers_url":"https://api.github.com/users/birarda/followers","following_url":"https://api.github.com/users/birarda/following{/other_user}","gists_url":"https://api.github.com/users/birarda/gists{/gist_id}","starred_url":"https://api.github.com/users/birarda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birarda/subscriptions","organizations_url":"https://api.github.com/users/birarda/orgs","repos_url":"https://api.github.com/users/birarda/repos","events_url":"https://api.github.com/users/birarda/events{/privacy}","received_events_url":"https://api.github.com/users/birarda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/birarda/hifi","description":"Test platform for various render and interface tests for next-gen VR system","fork":true,"url":"https://api.github.com/repos/birarda/hifi","forks_url":"https://api.github.com/repos/birarda/hifi/forks","keys_url":"https://api.github.com/repos/birarda/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/birarda/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/birarda/hifi/teams","hooks_url":"https://api.github.com/repos/birarda/hifi/hooks","issue_events_url":"https://api.github.com/repos/birarda/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/birarda/hifi/events","assignees_url":"https://api.github.com/repos/birarda/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/birarda/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/birarda/hifi/tags","blobs_url":"https://api.github.com/repos/birarda/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/birarda/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/birarda/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/birarda/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/birarda/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/birarda/hifi/languages","stargazers_url":"https://api.github.com/repos/birarda/hifi/stargazers","contributors_url":"https://api.github.com/repos/birarda/hifi/contributors","subscribers_url":"https://api.github.com/repos/birarda/hifi/subscribers","subscription_url":"https://api.github.com/repos/birarda/hifi/subscription","commits_url":"https://api.github.com/repos/birarda/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/birarda/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/birarda/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/birarda/hifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/birarda/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/birarda/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/birarda/hifi/merges","archive_url":"https://api.github.com/repos/birarda/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/birarda/hifi/downloads","issues_url":"https://api.github.com/repos/birarda/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/birarda/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/birarda/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/birarda/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/birarda/hifi/labels{/name}","releases_url":"https://api.github.com/repos/birarda/hifi/releases{/id}","created_at":"2013-04-11T17:58:46Z","updated_at":"2015-05-08T19:10:20Z","pushed_at":"2015-08-17T23:57:46Z","git_url":"git://github.com/birarda/hifi.git","ssh_url":"git@github.com:birarda/hifi.git","clone_url":"https://github.com/birarda/hifi.git","svn_url":"https://github.com/birarda/hifi","homepage":null,"size":173675,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"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":"birarda:protocol","ref":"protocol","sha":"052978898e49a02b5e6d84ecf39cf33993a32ffe","user":{"login":"birarda","id":724069,"avatar_url":"https://avatars.githubusercontent.com/u/724069?v=3","gravatar_id":"","url":"https://api.github.com/users/birarda","html_url":"https://github.com/birarda","followers_url":"https://api.github.com/users/birarda/followers","following_url":"https://api.github.com/users/birarda/following{/other_user}","gists_url":"https://api.github.com/users/birarda/gists{/gist_id}","starred_url":"https://api.github.com/users/birarda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birarda/subscriptions","organizations_url":"https://api.github.com/users/birarda/orgs","repos_url":"https://api.github.com/users/birarda/repos","events_url":"https://api.github.com/users/birarda/events{/privacy}","received_events_url":"https://api.github.com/users/birarda/received_events","type":"User","site_admin":false},"repo":{"id":9376753,"name":"hifi","full_name":"birarda/hifi","owner":{"login":"birarda","id":724069,"avatar_url":"https://avatars.githubusercontent.com/u/724069?v=3","gravatar_id":"","url":"https://api.github.com/users/birarda","html_url":"https://github.com/birarda","followers_url":"https://api.github.com/users/birarda/followers","following_url":"https://api.github.com/users/birarda/following{/other_user}","gists_url":"https://api.github.com/users/birarda/gists{/gist_id}","starred_url":"https://api.github.com/users/birarda/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birarda/subscriptions","organizations_url":"https://api.github.com/users/birarda/orgs","repos_url":"https://api.github.com/users/birarda/repos","events_url":"https://api.github.com/users/birarda/events{/privacy}","received_events_url":"https://api.github.com/users/birarda/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/birarda/hifi","description":"Test platform for various render and interface tests for next-gen VR system","fork":true,"url":"https://api.github.com/repos/birarda/hifi","forks_url":"https://api.github.com/repos/birarda/hifi/forks","keys_url":"https://api.github.com/repos/birarda/hifi/keys{/key_id}","collaborators_url":"https://api.github.com/repos/birarda/hifi/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/birarda/hifi/teams","hooks_url":"https://api.github.com/repos/birarda/hifi/hooks","issue_events_url":"https://api.github.com/repos/birarda/hifi/issues/events{/number}","events_url":"https://api.github.com/repos/birarda/hifi/events","assignees_url":"https://api.github.com/repos/birarda/hifi/assignees{/user}","branches_url":"https://api.github.com/repos/birarda/hifi/branches{/branch}","tags_url":"https://api.github.com/repos/birarda/hifi/tags","blobs_url":"https://api.github.com/repos/birarda/hifi/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/birarda/hifi/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/birarda/hifi/git/refs{/sha}","trees_url":"https://api.github.com/repos/birarda/hifi/git/trees{/sha}","statuses_url":"https://api.github.com/repos/birarda/hifi/statuses/{sha}","languages_url":"https://api.github.com/repos/birarda/hifi/languages","stargazers_url":"https://api.github.com/repos/birarda/hifi/stargazers","contributors_url":"https://api.github.com/repos/birarda/hifi/contributors","subscribers_url":"https://api.github.com/repos/birarda/hifi/subscribers","subscription_url":"https://api.github.com/repos/birarda/hifi/subscription","commits_url":"https://api.github.com/repos/birarda/hifi/commits{/sha}","git_commits_url":"https://api.github.com/repos/birarda/hifi/git/commits{/sha}","comments_url":"https://api.github.com/repos/birarda/hifi/comments{/number}","issue_comment_url":"https://api.github.com/repos/birarda/hifi/issues/comments{/number}","contents_url":"https://api.github.com/repos/birarda/hifi/contents/{+path}","compare_url":"https://api.github.com/repos/birarda/hifi/compare/{base}...{head}","merges_url":"https://api.github.com/repos/birarda/hifi/merges","archive_url":"https://api.github.com/repos/birarda/hifi/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/birarda/hifi/downloads","issues_url":"https://api.github.com/repos/birarda/hifi/issues{/number}","pulls_url":"https://api.github.com/repos/birarda/hifi/pulls{/number}","milestones_url":"https://api.github.com/repos/birarda/hifi/milestones{/number}","notifications_url":"https://api.github.com/repos/birarda/hifi/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/birarda/hifi/labels{/name}","releases_url":"https://api.github.com/repos/birarda/hifi/releases{/id}","created_at":"2013-04-11T17:58:46Z","updated_at":"2015-05-08T19:10:20Z","pushed_at":"2015-08-17T23:57:46Z","git_url":"git://github.com/birarda/hifi.git","ssh_url":"git@github.com:birarda/hifi.git","clone_url":"https://github.com/birarda/hifi.git","svn_url":"https://github.com/birarda/hifi","homepage":null,"size":173675,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"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/birarda/hifi/pulls/12"},"html":{"href":"https://github.com/birarda/hifi/pull/12"},"issue":{"href":"https://api.github.com/repos/birarda/hifi/issues/12"},"comments":{"href":"https://api.github.com/repos/birarda/hifi/issues/12/comments"},"review_comments":{"href":"https://api.github.com/repos/birarda/hifi/pulls/12/comments"},"review_comment":{"href":"https://api.github.com/repos/birarda/hifi/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/birarda/hifi/pulls/12/commits"},"statuses":{"href":"https://api.github.com/repos/birarda/hifi/statuses/f039851f13546d877d4179e386282419d6a3b452"}}}}