AndyChiang
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 計算機網路 Ch02 - Application Layer ###### tags: `計網` [![](https://img.shields.io/badge/dynamic/json?color=orange&label=總觀看人數&query=%24.viewcount&url=https://hackmd.io/FTy12zTFTpWpGEke4lzWbw%2Finfo)]() :::danger 🛠 施工中 ::: ## 2.4 DNS: domain name system ### iterated query ![](https://i.imgur.com/FKlHYgv.png) ### recursive query ![](https://i.imgur.com/rztTinU.png) ### DNS resource records(RR) ![](https://i.imgur.com/b6Qdtfv.png) * type=A: hostname/IP address * type=NS: domain/authoritative server name for this domain * type=CNAME: alias name/canonical name * type=MX: mailserver list/names of mailserver ## 2.5 peer-to-peer(P2P) ### P2P 架構 ![](https://i.imgur.com/djoCFpx.png) * 沒有一個永遠開機的server * host和host間直接做連線,不經由server * peer間會間斷性的連線並更改IP #### 應用 * File distribution(BitTorrent) * Streaming(KanKan) * VoIP(Skype) ### client-server vs. P2P ![](https://i.imgur.com/1AePdU8.png) 假設一個情境: server必須將檔案大小為F的檔案,傳送給N個使用者,所需要花的時間是多少? * **u~s~**: server上傳頻寬 * **d~i~**: 第i個peer下載頻寬 * **u~i~**: 第i個peer上傳頻寬 #### File distribution time: client-server ![](https://i.imgur.com/thak8BY.png) * server上傳一份檔案要花 **F/u~s~**,上傳N份檔案就要花 **NF/u~s~** * peer下載速度最慢所要花 **F/d~min~** #### File distribution time: P2P ![](https://i.imgur.com/RJaN4kZ.png) * server只需要上傳一份檔案: **F/u~s~** * peer下載速度最慢所要花 **F/d~min~** * 檔案的總量還是 **NF**,只不過讓所有的使用者去分擔上傳的頻寬: **u~s~ + Σu~i~** #### 效能比較 ![](https://i.imgur.com/dHJSbRN.png) * Client-Server: 呈線性增長。 * P2P: 使用者越多,上傳速度越快。 ### BitTorrent ![](https://i.imgur.com/6fbfKD2.png) * chunks: 檔案被分割成好幾個 256Kb 的小區段。 * torrent: 由一群peer彼此交換chunk的群集。 * tracker: 追蹤所有torrent中的使用者,以及檔案流向。 但問題來了,如果有人取得完整檔案就離開(自私)的話,就可能導致檔案遺失,因此設計了 **requesting chunks** 和 **tit-for-tat** 機制。 #### requesting chunks 1. 先看其他peer目前所擁有的chunks。 2. 請求獲取最稀少的chunks。 #### tit-for-tat ![](https://i.imgur.com/6KvC1Fp.png) 1. 取寄送chunk給自己最快的前四名成為Top 4 peer(unchoked),每十秒更新一次。 2. 和Top4交換chunk。 3. 每三十秒寄chunk給隨機一個peer(optimistically unchoked),有可能成為他的Top4。 4. 其他非Top 4 peer和optimistically unchoked的peer,則稱為choked,這些choked不會接收到來自你的chunk。 ## 2.6 video streaming and content distribution networks (CDNs) 影片串流,因應大量觀看影片的需求。 ![](https://i.imgur.com/ui9a3u6.png) 挑戰: * 巨大的傳輸流量 * 不同裝置間的相容性 解決方法: * 分散式主機 * 優化應用層 ![](https://i.imgur.com/PyPfYv3.png) 只要黑影的輪廓或者紀錄畫面間的差異就好 ![](https://i.imgur.com/WZEB7Aw.png) 每次傳1/24秒的片段 預留5~10秒的buffer,預先載好影片,不會因為網路短暫中斷而導致影片卡住 ### DASH: Dynamic, Adaptive Streaming over HTTP #### server * divides video file into multiple chunks -> 將影片切割成片段 * each chunk stored, encoded at different rates -> 每個片段分成不同的解析度 * **manifest file**: provides URLs for different chunks -> 提供不同片段和解析度的URL #### client * buffer * periodically measures server-to-client bandwidth -> 依照網路頻寬決定下載的解析度 因此在client端必須知道什麼時候要下載chunk? 下載什麼解析度的? 以及要去哪裡下載? 這就是前面說的**優化應用層** ### Content Distribution Networks (CDNs) 類似proxy的概念,儲存影片的副本CDN節點,從最靠近的CDN節點中取得影片 * enter deep: 放在區域中某個連結網路的server * bring home: 放在POP 以Netflix為例: ![](https://i.imgur.com/KXlJp97.png) ![](https://i.imgur.com/N9qAngJ.png) #### over the top(OTT)問題 1. From which CDN node to retrieve content? 離自己最近的 2. Viewer behavior in presence of congestion? 換解析度較低的chunk 3. What content to place in which CDN node? 影片的副本 #### CDN content access(運作方式) ![](https://i.imgur.com/fyl4z5D.png)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully