UULi
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • 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 No publishing access yet

        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.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        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 New
      • Engagement control
      • Make a copy
      • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    19
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 計算機網路筆記-ch4 data plane : 處理資料傳輸 control plane : 路徑規劃 network layer protocols is in **<font color=red>every hosts and routers</font>**. routers: * 檢查所有經過的datagram的header * 將datagrams從input port送到正確的output port ### two key network-layer function #### forwarding 將packets從router's input link 送往合適的router's output link (像在旅行中決定下個路口往哪走) #### routing 決定packets從來源到目的地的路線 (規劃整體旅行起點到終點的路線)(產出如routing algorithm一樣的表來做導航) #### Data plane * local * per-router function * 決定datagram如何從router的 input port 傳到 output port #### Control plane * network-wide logic * 決定datagram從來源host傳遞到目的地host的路徑 * 法1: traditional routing alogrithms(由router執行) * 法2: software-defined networking(SDN) (由遠端的server執行) ##### traditional routing algorithm ![](https://i.imgur.com/PTGWLxV.png) 每個routers互相收集彼此的資訊,每個routers在各自的利用routing algorithm來計算出local forwarding table。 #### software-defined networking(SDN) ![](https://i.imgur.com/YLmdcjO.png) 藉由遠端的控制器來計算forwarding table, 並且安裝在每個router上 ### Network-layer service model ![](https://i.imgur.com/fwHBLl1.png) 在best effort模型中,是沒有甚麼保證(頻寬、遺失、順序、時間容許)的,從上層收到segment就封裝送出去了。如需要任何保障,只要transport layer做就可以解決了。 #### best-effort service * 較簡單 * 適合real-time application(如:語音對話、直播影音等) ## Inside a router ![](https://i.imgur.com/qYVUiSU.png) routing, management control plane(software) 須花較多時間 forwarding data plane(hardware) 非常快速 ### Input port function ![](https://i.imgur.com/u876gtP.png) Decentralize Switching: * 利用header去forwarding table尋找適合的output port * 假如datagrame到達的速率大於forwarding到switch fabric的速率,就會發生queueing * destination-based forwarding : 根據destination IP address 去forward * generalized forwarding : 根據header中其他的值去判斷如何forward ### Longest prefix matching 在查表時,要選取destination IP address的 prefix 與表中項目中相符合最長的那一項。 ### Switching fabrics * 將 packet 從 input link 傳輸到合適的 output link * 假設每個input port的傳輸速率是R,今天有N個input link,則理想的switching rate是N*R ![](https://i.imgur.com/Vw5vSvQ.png) #### Switching via memory 最初的generation router, 由一般電腦來完成,先將送進來的封包複製到處理器的記憶體中,處理器找出適當的輸出埠,再複製到輸出埠的緩衝區。 * 由電腦的CPU來決定output link * 需先複製到記憶體中 * 速度會受限於memory的頻寬 #### Switching via bus 不需要處理器的介入,input port會在封包加一個標籤,指定要傳送出去的output port,並由shared bus傳到每個output port,output port判斷該標頭是不是指自己,是的就保留,不是則捨棄。<font color=red>**同一時間只有一個封包可以跨過bus,所以封包交換速度會受限於匯流排速度**</font>。 #### Switching via interconnection network 利用<font color=red>**棋盤式交換結構**</font>(crossbar switch),若有N個輸入埠、N個輸出埠,會由2N條匯流排(N條水平、N條垂直)形成此結構,而<font color=red>**交換結構控制器可以決定那些是斷開或閉合,此結構便可以實現同一時間轉送多個封包的功能**</font>。 ### input port queuing * 當switch fabric的速度比input port傳入的速度慢,input port就會發生queuing 甚至是 loss。 * head-of-the-line(HOL) blocking : <font color=red>**排在前面的datagram阻止其他也在排隊,但在後面的datagram前進**</font>。 * ![](https://i.imgur.com/tfddpKC.png) ### output port queuing ![](https://i.imgur.com/krwyVPG.png) * 當今天datagram到達output port的速率大於output link的transmission rate,則會需要先將datagram buffer起來。(buffering when arrival rate via switch exceeds output line speed) * Scheduling discipline : 選擇正在queueing的datagram進行傳送(擁有優先權的人可以享受到更好的效能)。 * queueing (delay) and loss due to output port buffer overflow! ### Buffer Management Drop * 當buffer滿的時候 * tail drop : drop掉正準備到達的packet(tail尾巴) * priority: 依優先的順序drop甚至是remove掉在output port buffer的packet Marking * router可以將congestion的訊號標記在packet,讓host知道(ECN、RED) ### Packet Scheduling 決定該要先送出哪個在buffer上的封包 #### FCFS * first-come-first-served #### Priority * 進入buffer(queue)時會先分類 * 任何header裡的資訊都可以成為分類的依據 * 會優先傳送優先權高的封包 * 如果兩個封包來自同一個優先權分類,則用FCFS決定誰先傳 ![](https://i.imgur.com/gxPQPPs.png) #### Round Robin(RR) * 進入buffer(queue)時會先分類 * 任何header裡的資訊都可以成為分類的依據 * 會輪流的傳送每一個分類的封包 ![](https://i.imgur.com/7jrzUXA.png) #### Weighted Fair Queueing(WFQ) * 進入buffer(queue)時會先分類 * 任何header裡的資訊都可以成為分類的依據 * 原理跟round robin很像,一樣都會輪流傳送每一個class的封包 * 但差別在於每個class都有自己的權重 * 會根據每個class的權重大小來決定這個class被輪到後一次可以傳送多少的封包,而不是像RR一樣,每次輪到每個分類都是傳一樣的份量 ![](https://i.imgur.com/PVhTOjL.png) ![](https://www.researchgate.net/profile/Amor-Chowdhury/publication/221910737/figure/fig10/AS:669008852430851@1536515548142/The-hybrid-queuing-mechanism-consisting-of-the-WFQ-and-the-CBWFQ-regimes.png) ### Network Neutrality 保護所有的網路使用者都能不受限制的友善且合法的發言、創造與競爭。 * no blocking : 不要去阻擋合法友善的內容、應用程式或是服務 * no throttling : 不能去損壞或是降級合法友善的網路傳輸 * no paid prioritization : 不能去從事買賣網路優先權 ## IP : the Internet Protocol ### IP addressing #### IP address : 用來識別<font color=red>host與router interface</font>的32-bit識別碼 #### interface : host或router與physical link的連接點 * router通常有多個interfaces * host通常有一個或兩個interfaces(乙太+無線網路) ### Subnet 裝置與裝置間的interface不需要經由中間路由器就能相連的裝置 ##### subnet part : 在相同subnet的裝置,IP address有相同的high order bits ##### host part : 有自己獨有的low order bits 將router或host的interface分離,分離出的那塊孤立的區塊就是subnet #### Ip addressing : CIDR CIDR : Classes InterDomain Routing * address中subnet部分的<font color=red>長度是隨意的</font> * address format: a.b.c.d/x, x是subnet部分的長度 ### DHCP : Dynamic Host Configuration Protocol(為應用層的協定) 目的:可讓想加入網路的host被server動態地分配IP address * 同個IP可以不同時地分配給不同的host,因為可以將IP分配可以當下有需要的人,而不是IP永遠固定給某一台不是隨時在上網的host,這能減輕IP位置不夠的問題。 DHCP 細節: * host broadcast <font color=red>**DHCP discover**</font>訊息 * DHCP server 用<font color=red>**DHCP offer**</font>回應host,並告知host可以取得的IP adrress資訊 * host 用<font color=red>**DHCP request**</font>請求取得IP address * DHCP server 用<font color=red>**DHCP ack**</font>確認 大部分 DHCP server 是被建置在router內,服務router所連接的子網路。 ![](https://i.imgur.com/r3Dxggi.png) DHCP 還可傳遞IP位址外的資訊: * 離client最近的router的IP位址 * 離client最近的DNS server的name跟IP位址 * network mask ![](https://i.imgur.com/DeRRNt3.png) DHCP流程: 1. host發出的DHCP REQUEST msg被<font color=red>UDP、IP與Ethernet</font>一層一層向下封裝 2. Ethernet frame 在 LAN 中broadcast(設destination IP address為255.255.255.255) 3. 被有DHCP server的router接收,然後一層一層的往上傳遞到DHCP協定 ----- 4. DHCP server將要給client的IP位址、最接近的routerIP位址與最近的DNS名子與IP位址寫入DHCP ACK內 ## 如何得到IP位址 1. 取得固定IP位址,然後將host寫死 2. DHCP Q: 網路如何得到subnet part of IP位址 A: 向ISP租用ISP所擁有的IP位址 ISP會分配ISP所被分配到的address space(網段)給client, 如今天有n個組織向ISP租用網路,ISP會將他被分配到的IP位址區塊進行切割,切割成n等分給這n個組織去使用。 ### 位址分配屬於階層式 * route aggregation(聚合) : router可以設定條件(如:200.23.16.0/20開時的傳給我),讓封包透過階層式的傳遞,傳到正確的目的地。 * 而封包會選擇符合條件最多(最長)的router ### 那ISP如何取得網段 ICANN : Internet Coperation for assigned Names and Numbers ICANN 會分配IP位址給5個regional registries(RRs)(區域網路註冊機構,是管理世界上某特定地區Internet資源的組織) IPV4已經不夠用,但可以藉由NAT可以暫時解決IP位址不夠的問題。 而IPV6有128個bit,為未來將設法普及的定址方法,短時間內應該不會出現位址不夠分配的問題。 ## NAT : network address translation NAT,能讓在區域網路內的所有裝置共同使用一個IPv4(Internet Protocol version 4)的IP位址來對外界做連線。 ![](https://i.imgur.com/QBhFOpY.png) <font color=blue>**Same source NAT IP address, but different <font color = red>source port numbers</font>.**</font> ### 優點 * 只需要跟ISP租用一個IP,就能使私人區域網路能跟網際網路連線 * 當區域網路內更改了其中一個host的IP位址,不需要告知外界 * 如果換了另一家ISP的服務(換了IP),也不用改變區域網路裡的IP位址 * 可以讓外界無法直接地存取區域網路裡的裝置,對網路安全有幫助 ### 如何實現 當要將封包傳出區域網路時,router會將原封包的來源端NAT IP address與port number改成用戶被ISP分配到的IP address,並產生出一個新的port number。而router會將NAT IP address與原本的port number跟其對應到的source IP address與新的port number存入NAT translation table中。當router收到要傳給原host的封包時,router會依照NAT table將IP位址與新的port number換成NAT IP address與原本的port number。 ![](https://i.imgur.com/ISRikWC.png) ### NAT的爭議 * router"應該"只處理網路層的功能 * IP位址短缺問題應該由IPv6解決 * 違背end-to-end原則 * client無法連接在NAT區域網路裡的server 之所以NAT還是一直被使用,是因為NAT已經廣泛應用在我們的家裡或是各個機構中 ## IPv6 * 32-bit的IPv4快分配完了 * 固定的40-byte的header,加速了forwarding * 可以讓其他網路層做流量處理 ## datagram格式 ![](https://i.imgur.com/i6xR3SV.png) * flow label : 同筆資料給予相同的label,可用來做流量控制及統計 與IPv4的比較: * 由於沒有checksum,所以可以加速處理資料 * no fragmentation/reassembly * no options ### Tunneling 由於不是所有的router都更新成使用IPv6的版本, 所以tunneling是將IPv6的datagram放入IPv4 datagram裡的payload欄位中,在IPv4的routers中做傳遞。(封包放在封包內做傳遞) * 廣泛用於4G/5G中,因為4G/5G是使用IPv6 ![](https://i.imgur.com/latEhq6.png) ## Generalized forwarding : match plus action * match+action : 先match到達的封包的header(可以是網路層、傳輸層或是鏈結層)的bits再採取行動 * destination-based forwarding : forward based on dest. IP位址 * generalized forwarding : * 其他的header資訊都可以作為下一個行動的依據 * 可以做很多其他的動作 : drop/copy/modify/log packet #SDN : software-defined networking ### Flow table abstraction * flow : 可以是在link layer, network layer, transport layer裡header所定義的值 * generalized forwarding : simple packet-handling rules * match : pattern values in packet header fields(看網路層、鏈結層或傳輸層的headers裡一項或是多項的值是否match) * actions : 將match的packet進行drop, forward, modify, matched packet 或 send matched packet to controller的動作。 * priority : 可以控制封包的優先順序 * counters : 可以算總共用了多少的bytes或packets(計算user的用量) ![](https://i.imgur.com/0A1WqSw.png) ## OpenFlow OpenFlow,一種位於data link layer的protocol,能夠控制switch或router的forwarding plane,藉此改變packets所走的網路路徑。 ![](https://i.imgur.com/Re55rcq.png) ![](https://i.imgur.com/Ejh4ZrQ.png) #### 透過match+action實現了不同裝置的功能 * Router * match : longest destination IP prefix * action : forward out a link * Firewall * match : IP address and TCP/UDP port numbers * action : permit or deny * Switch * match : destination MAC address * action : forward or flood * NAT * match : IP address and port * action : rewrite address and port ###### tags: `計算機網路`

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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