{"action":"created","comment":{"url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments/44228442","id":44228442,"diff_hunk":"@@ -95,3 +164,118 @@ def __eq__(self, other):\n \n     def __ne__(self, other):\n         return not self.__eq__(other)\n+\n+    def get_link_cost(self):\n+        \"\"\"\n+        Returns link cost. For now, just returns static propagation delay.\n+        :return: float of link delay time in seconds\n+        \"\"\"\n+\n+        # TODO consider average wait time for last N packets\n+        return self.static_delay_sec\n+\n+    def push(self, packet, global_clock_sec):\n+        \"\"\"\n+        Pushes packet onto own LinkBuffer\n+\n+        :param Packet packet: Packet to push\n+        :param global_clock_sec: store when packet pushed\n+        :return: True if pushed, False if not\n+        \"\"\"\n+        return self.link_buffer.push(packet, global_clock_sec)\n+\n+\n+\n+class LinkSendEvent(Event):\n+    \"\"\"\n+    Event representing a packet arriving at the Link\n+    \"\"\"\n+\n+    def __init__(self, link):\n+        \"\"\"\n+        :ivar link: link that must send its next packet\n+        :ivar buff_elem: temporary variable containing LinkBufferElement to send\n+        \"\"\"\n+        self.link = link\n+\n+    def run(self, main_event_loop, statistics):\n+        \"\"\"\n+        runs by popping off top packet\n+        :param MainEventLoop main_event_loop: event loop for global timing\n+        :param Statistics statistics: the Statistics to update\n+        \"\"\"\n+\n+        # sanity check\n+        if(self.link.queue.empty()):\n+            logger.warning(\"LinkSendEvent while Link empty!\")\n+            return\n+\n+        # now pop\n+        self.buffer_elem = self.link.pop()\n+\n+        # update statistics only if not RouterPacket\n+        if(not isinstance(self.buffer_elem.packet, RouterPacket)):\n+            statistics.link_packet_transmitted(link, buffer_elem.packet, \\\n+                    main_event_loop.global_cloc_sec)\n+\n+    def schedule_new_events(self, main_event_loop):\n+        \"\"\"\n+        Schedules new Events. This is called immediately after run().\n+        :param MainEventLoop main_event_loop: event loop where new Events will\n+        be scheduled.\n+        \"\"\"\n+        # schedule a RouterReceivedPacket with propagation + transmission delay\n+        main_event_loop.schedule_event_with_delay(RouterReceivedPacketEvent(0),\\\n+                self.link.static_delay_sec + self.packet.size_bits / \\\n+                    self.link.capacity_bps)\n+            # TODO(Laksh): RouterReceivedPacketEvent signature\n+            # recommended signature RouterReceivedPacketEvent(router, packet)?\n+\n+        if self.link.link_buffer.queue.empty():\n+            # if link_buffer.queue is empty, then link is no longer busy\n+            self.link.busy = False\n+        else:\n+            # queue new event with just transmission delay\n+            main_event_loop.schedule_event_with_delay(LinkSendEvent(self.link),\\\n+                    self.buffer_elem.packet.size_bits / self.link.capacity_bps)\n+\n+\n+\n+class DeviceToLinkEvent(Event):\n+    \"\"\"\n+    Event representing a packet arriving at the Link","path":"network_simulator/link.py","position":226,"original_position":226,"commit_id":"ce231d86402881d3cf2b3423b99ffc47b13b3c1c","original_commit_id":"ce231d86402881d3cf2b3423b99ffc47b13b3c1c","user":{"login":"yubo56","id":5651687,"avatar_url":"https://avatars.githubusercontent.com/u/5651687?v=3","gravatar_id":"","url":"https://api.github.com/users/yubo56","html_url":"https://github.com/yubo56","followers_url":"https://api.github.com/users/yubo56/followers","following_url":"https://api.github.com/users/yubo56/following{/other_user}","gists_url":"https://api.github.com/users/yubo56/gists{/gist_id}","starred_url":"https://api.github.com/users/yubo56/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yubo56/subscriptions","organizations_url":"https://api.github.com/users/yubo56/orgs","repos_url":"https://api.github.com/users/yubo56/repos","events_url":"https://api.github.com/users/yubo56/events{/privacy}","received_events_url":"https://api.github.com/users/yubo56/received_events","type":"User","site_admin":false},"body":"fixed","created_at":"2015-11-08T18:48:20Z","updated_at":"2015-11-08T18:48:20Z","html_url":"https://github.com/lakshbhasin/network_simulator/pull/11#discussion_r44228442","pull_request_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments/44228442"},"html":{"href":"https://github.com/lakshbhasin/network_simulator/pull/11#discussion_r44228442"},"pull_request":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11","id":49788523,"html_url":"https://github.com/lakshbhasin/network_simulator/pull/11","diff_url":"https://github.com/lakshbhasin/network_simulator/pull/11.diff","patch_url":"https://github.com/lakshbhasin/network_simulator/pull/11.patch","issue_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/11","number":11,"state":"open","locked":false,"title":"Link basics yubo","user":{"login":"yubo56","id":5651687,"avatar_url":"https://avatars.githubusercontent.com/u/5651687?v=3","gravatar_id":"","url":"https://api.github.com/users/yubo56","html_url":"https://github.com/yubo56","followers_url":"https://api.github.com/users/yubo56/followers","following_url":"https://api.github.com/users/yubo56/following{/other_user}","gists_url":"https://api.github.com/users/yubo56/gists{/gist_id}","starred_url":"https://api.github.com/users/yubo56/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yubo56/subscriptions","organizations_url":"https://api.github.com/users/yubo56/orgs","repos_url":"https://api.github.com/users/yubo56/repos","events_url":"https://api.github.com/users/yubo56/events{/privacy}","received_events_url":"https://api.github.com/users/yubo56/received_events","type":"User","site_admin":false},"body":"Implemented Link and related subclasses/events. Notably, LinkSendEvent and DeviceToLinkEvent should be working.\r\n\r\nRecords timing of pushed LinkBufferElements for possible future dynamic deque of wait times, but currently not implemented.","created_at":"2015-11-05T06:54:18Z","updated_at":"2015-11-08T18:48:20Z","closed_at":null,"merged_at":null,"merge_commit_sha":"aaf3ea64ac9c2b73f808e73cf483f896a27f892c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11/commits","review_comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11/comments","review_comment_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/11/comments","statuses_url":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/ce231d86402881d3cf2b3423b99ffc47b13b3c1c","head":{"label":"lakshbhasin:link-basics-yubo","ref":"link-basics-yubo","sha":"ce231d86402881d3cf2b3423b99ffc47b13b3c1c","user":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"repo":{"id":44171299,"name":"network_simulator","full_name":"lakshbhasin/network_simulator","owner":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lakshbhasin/network_simulator","description":"A network simulator for the project portion of CS 143","fork":false,"url":"https://api.github.com/repos/lakshbhasin/network_simulator","forks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/forks","keys_url":"https://api.github.com/repos/lakshbhasin/network_simulator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lakshbhasin/network_simulator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lakshbhasin/network_simulator/teams","hooks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/hooks","issue_events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/events{/number}","events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/events","assignees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/assignees{/user}","branches_url":"https://api.github.com/repos/lakshbhasin/network_simulator/branches{/branch}","tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/tags","blobs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/refs{/sha}","trees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/{sha}","languages_url":"https://api.github.com/repos/lakshbhasin/network_simulator/languages","stargazers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/stargazers","contributors_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contributors","subscribers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscribers","subscription_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscription","commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/commits{/sha}","git_commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/commits{/sha}","comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/comments{/number}","issue_comment_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/comments{/number}","contents_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contents/{+path}","compare_url":"https://api.github.com/repos/lakshbhasin/network_simulator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lakshbhasin/network_simulator/merges","archive_url":"https://api.github.com/repos/lakshbhasin/network_simulator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lakshbhasin/network_simulator/downloads","issues_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues{/number}","pulls_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls{/number}","milestones_url":"https://api.github.com/repos/lakshbhasin/network_simulator/milestones{/number}","notifications_url":"https://api.github.com/repos/lakshbhasin/network_simulator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lakshbhasin/network_simulator/labels{/name}","releases_url":"https://api.github.com/repos/lakshbhasin/network_simulator/releases{/id}","created_at":"2015-10-13T11:21:24Z","updated_at":"2015-10-25T21:16:11Z","pushed_at":"2015-11-08T14:39:17Z","git_url":"git://github.com/lakshbhasin/network_simulator.git","ssh_url":"git@github.com:lakshbhasin/network_simulator.git","clone_url":"https://github.com/lakshbhasin/network_simulator.git","svn_url":"https://github.com/lakshbhasin/network_simulator","homepage":null,"size":324,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"base":{"label":"lakshbhasin:master","ref":"master","sha":"a8444503fb51c60c2237d1a615a9682bee02b6f9","user":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"repo":{"id":44171299,"name":"network_simulator","full_name":"lakshbhasin/network_simulator","owner":{"login":"lakshbhasin","id":1183879,"avatar_url":"https://avatars.githubusercontent.com/u/1183879?v=3","gravatar_id":"","url":"https://api.github.com/users/lakshbhasin","html_url":"https://github.com/lakshbhasin","followers_url":"https://api.github.com/users/lakshbhasin/followers","following_url":"https://api.github.com/users/lakshbhasin/following{/other_user}","gists_url":"https://api.github.com/users/lakshbhasin/gists{/gist_id}","starred_url":"https://api.github.com/users/lakshbhasin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lakshbhasin/subscriptions","organizations_url":"https://api.github.com/users/lakshbhasin/orgs","repos_url":"https://api.github.com/users/lakshbhasin/repos","events_url":"https://api.github.com/users/lakshbhasin/events{/privacy}","received_events_url":"https://api.github.com/users/lakshbhasin/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lakshbhasin/network_simulator","description":"A network simulator for the project portion of CS 143","fork":false,"url":"https://api.github.com/repos/lakshbhasin/network_simulator","forks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/forks","keys_url":"https://api.github.com/repos/lakshbhasin/network_simulator/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lakshbhasin/network_simulator/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lakshbhasin/network_simulator/teams","hooks_url":"https://api.github.com/repos/lakshbhasin/network_simulator/hooks","issue_events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/events{/number}","events_url":"https://api.github.com/repos/lakshbhasin/network_simulator/events","assignees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/assignees{/user}","branches_url":"https://api.github.com/repos/lakshbhasin/network_simulator/branches{/branch}","tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/tags","blobs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/refs{/sha}","trees_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/{sha}","languages_url":"https://api.github.com/repos/lakshbhasin/network_simulator/languages","stargazers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/stargazers","contributors_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contributors","subscribers_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscribers","subscription_url":"https://api.github.com/repos/lakshbhasin/network_simulator/subscription","commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/commits{/sha}","git_commits_url":"https://api.github.com/repos/lakshbhasin/network_simulator/git/commits{/sha}","comments_url":"https://api.github.com/repos/lakshbhasin/network_simulator/comments{/number}","issue_comment_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/comments{/number}","contents_url":"https://api.github.com/repos/lakshbhasin/network_simulator/contents/{+path}","compare_url":"https://api.github.com/repos/lakshbhasin/network_simulator/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lakshbhasin/network_simulator/merges","archive_url":"https://api.github.com/repos/lakshbhasin/network_simulator/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lakshbhasin/network_simulator/downloads","issues_url":"https://api.github.com/repos/lakshbhasin/network_simulator/issues{/number}","pulls_url":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls{/number}","milestones_url":"https://api.github.com/repos/lakshbhasin/network_simulator/milestones{/number}","notifications_url":"https://api.github.com/repos/lakshbhasin/network_simulator/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lakshbhasin/network_simulator/labels{/name}","releases_url":"https://api.github.com/repos/lakshbhasin/network_simulator/releases{/id}","created_at":"2015-10-13T11:21:24Z","updated_at":"2015-10-25T21:16:11Z","pushed_at":"2015-11-08T14:39:17Z","git_url":"git://github.com/lakshbhasin/network_simulator.git","ssh_url":"git@github.com:lakshbhasin/network_simulator.git","clone_url":"https://github.com/lakshbhasin/network_simulator.git","svn_url":"https://github.com/lakshbhasin/network_simulator","homepage":null,"size":324,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":3,"forks":0,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11"},"html":{"href":"https://github.com/lakshbhasin/network_simulator/pull/11"},"issue":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/11"},"comments":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/lakshbhasin/network_simulator/statuses/ce231d86402881d3cf2b3423b99ffc47b13b3c1c"}}}}