C.A.Lee
    • 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 New
    • 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 Note Insights Versions and GitHub Sync 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- robots: index, follow tags: NCTU, CS, 共筆 description: 交大資工課程學習筆記 lang: zh-tw dir: ltr breaks: true disqus: calee GA: UA-100433652-1 --- SDN -- 王協源 ===== ... ## The State of Networking ### SDN #### SDN application 2. 1. Seamless mobility and migration : 移動時service不中斷 2. Server load balancing: 根據source IP做load balancing 3. Dynamic access control: 認證才能服務,認證後controller會記住此MAC addr 4. Using multiple wireless access points: 告知使用者用哪個AP比較好 5. Energy-efficient networking: 動態關閉沒有使用的機器 6. Adaptive traffic monitoring 7. Denial-of-Service attack detection 8. Network virtualization: 將網路切割成虛擬子網路 #### How the Internet Works ##### Best-Effort Packet Switching 1. Packet switching: 1. 將data切成packets,packets的傳送是各自獨立的 2. statistical multiplexing: 誰有paket上傳就傳誰的,不用時可以給別人用 2. Best-effort delivery: 1. 盡量送,但不做優化,也不保證能不能收到 2. packets會有掉落deley、順序錯亂的問題 3. 在頂層另外做保證傳送的機制 ##### Layering 1. Packet Encapsulation: 1. 不同設備交換不同東西 - Network layer: packets (routers) - Link layer: frames (bridges and switches) - Physical layer: electrical signals (repeaters and hubs) 2. Link Layer: 1. Adaptors Communicating 2. MAC adrr - Hierarchical allocation: blocks(廠商編號)+adapters(產品編號) - broadcast addr: FF-FF-FF-FF-FF-FF 3. 為什麼不用IP addr? - link要支援各種network protocal - 設備會移到新的地點 - Must identify the adapter during bootstrap 4. Dynamic Host Configuration Protocol (DHCP): 拿到自己的IP 5. Address Resolution Protocol (ARP): 用這個IP的是誰 3. Network Layer : 1. longest prefix match: dst IP addr 進來match prefix最長的那個 2. Domain Name System: 1. Hierarchical directory, Caching of results 2. Autonomy: 將namespace切開,給不同server負責 4. Transport Layer: 1. Two Main Ideas 1. Demultiplexing: port numbers 2. Error detection: checksums 2. User Datagram Protocol (UDP) 3. Transmission Control Protocol (TCP) ### OpenFlow Switch Architecture - Ports 1. Physical Ports - 對應到實體的hardware interface 2. Logical Ports - 沒有直接對應到硬體 - packet encapsulation - map to various physical ports 3. Reserved Ports - specify generic forwarding actions. - Required: - All: 會回送給所有的port,包含自己 - Controller: control channel - Table: OpenFlow pipeline的開頭。只有在packet-out的output action才有用 - In_Port: 代表pkt是從哪個port進來 - Any: 代表沒有要指定特別哪個port時用 - Optional: - Local: 代表switch的local networking stack或是他的management stack 。用dataplane網路直接下命令給switch,而不用分開來的controller network - Normal: 傳統非openflow的pkt switch pipeline - Flood: flooding operation 4. Standard Ports 5. Port Structure: - port_no: uniquely identifies a port within a switch - hw_addr : the MAC address for the port - name : readable name for the interface - config: - OFPPC_PORT_DOWN : port已經被管理者關掉 - OFPPC_NO_RECV : 在這個port收到的packets都要被丟掉 - OFPPC_NO_FWD : 不能在這個port做flooding - OFPPC_NO_PACKET_IN : 從這個port產生的table miss should永遠不會觸發packet-in message送到controller - Flow Tables 1. Pipeline 2. Flow Entries: - Match Fields - Priority: 包含一個optional的importance ,可以讓比較重要的資料把比較不重要的踢出table - Counters - Instructions - Timeouts: - hard timeout: 加了entry後過了幾秒一定要刪掉 - idle tiomeout: 過了幾秒都沒match到pkt才刪掉 - Cookie: controller知道就好的值 3. Flow Removal: 1. Controller: Flow-Delete message 2. Switch: timeout, eviction mechanism (optional) 4. table miss: 1. packet match不到任何entry 2. table miss entry: 把match field全設成don't care,priority設最低 - Group Table 1. Group Identifier 2. Group Type : 讓switch自己決定pkt要從哪個port出去 - All: 執行所有Action Buckets中的動作,用來做multicast或broadcast forwarding - Indirect: 執行既有定義的某個Action Bucket中的動作,在網路狀態改變時,能把entry中的同樣的資訊快速換掉 - Select (optional): 用自選的algorithm挑執行的bucket - Fast failover (optional): 執行第一個還能用的bucket,找不到的話就丟掉,快速切換到能用的port 3. Counters : updated when packets are processed by a group 4. Action Buckets : contains an ordered list of action buckets - Meter Table - 把管控聚合起來 (有點像 QoS) - 品質保證 - SLA - 跟你簽約,要保證給你的流量與你給他的流量 - 超過了話,丟包 or mark priority - ![](https://i.imgur.com/TM80cjV.png =300x) - Band Type - Drop - DSCP remark(用 mark 降低 priority) - Rate - 用來作標準的 - Instructions - Require - Write-Actions - 把 Action 加入 - 若以存在,更新 Action - Goto-Table + next-id - 跳到那個 Table 執行 - Optional - Meter + meter_id - 來到 meter table 規則 - Apply-action - 提供得資料放入 action-set - Clear-action - Write-metadata - 提供的資料寫入 metadata - Actions - Required - Output - Drop - 沒有這個 Action,default 就是 drop - Group - 跳到對應的 group - **優先等級比 output action 高** - Optional - Set-Queue - packet 送到 output port 時,要存在哪個等級的 output port - 作 QoS - (目前 IEEE 對 port 有 8 個等級的的分類) - Push/Pop tag - ex. VLAN, MPLS, ... - Set-Fields - 改 header fields - Change-TTL - Action List - 一個 list - 會一個一個拿出來執行(疊加) - Instruction-Fields | Instruction | index | context | | :-: | :-: | :-: | | goto-table | 1 | type, len, table_id, pad | | write-metadata | 2 | type, len, pad, metadata, mask | | write-action | 3 | | | apply-action | 4 | | | clear-action | 5 | | | meter | 6 | | - Statistics Counters 作分析用的 counter,監控網路狀況 1. reference count: 目前有幾個pkt 2. packet lookup: 有幾個pkt來查詢 3. packet matches: 有幾個pkt成功match 4. duration: 從action加進table後存活多久了 ![](https://i.imgur.com/msE9x9O.png =320x) ![](https://i.imgur.com/b7vVYRn.png =250x) ![](https://i.imgur.com/3Dchnpl.png =250x) ### OpenFlow Channel 從 switch 通知 OpenFlow Controller 特殊事件 - 利用 TLS 加密於 TCP 協定 (由 switch 發出,會填入 controller 的位址(可能會填多個controller)) - 種類 - Controller-to-switch - Feature(switch 要跟 controller 說你有什麼能力) - datapath id (就是 switch 自己的 id) - #buffer - #flow table - match fields size - ... - Config - IP fragments 處理方法 (SDN switch 可以重組被切割的 packet) - Modify-State - Add, delete and modify flows/groups in the OpenFlow tables - 改 port state (duplex, bandwidth, ...) - Packet-Out - 將 packet 從指定的 port 出去,可以是實體 port, 邏輯 port, TABLE port, ... - 若發生 table miss,switch 要把 packet 送到 controller,這叫做 **Packet-In** - Read State - 收集資訊 - Barrier - 訊息處理 - 確保訊息的相依性 - 要先處理這個訊息,才能處理下一個訊息 - 因為 switch 有能力改變 controller 處理訊息的順序以增加效能 - Flow-Modify - Add, modify, delete flow entries into/in/from the flow tables - 可以包含 packet-buffer-id - ex. packet-in 到 controller 回來後,指定哪一個 buffer 理的 packet 拿來繼續用 - Role-Request - Role: - Master - Slave - Equal - Load balance / multi-controller 用 - Asynchronous-Configuration - Master 下 rule 時,應該要同步通知 Slave / Equal - 減少 amount of asynchronous(非同步) message traffic - 可以設怎麼樣的訊息要收,怎麼樣的不收 (filter) - Asynchronous - 使用狀況 - Switch -> Controller - 通知性質 - Packet-in - New Flow - packet-in buffer - Flow-Remove - Idle/Hard timeout timer - 你殺掉 flow 時,需要告知 controller - (controller 應該要知道網路上的所有狀況) - [Optional] Switch eviction mechanism:rule 太多,空間不夠時,switch 可以根據 Importance / timeout 來決定丟棄 flow - Port-Status - Port up/down 等等的資訊 - Error - Symmetric(雙方互送訊息) - Hello - TCP 交握 - 了解雙方能力 (OpenFlow 版本...) - 不同於 Controller-to-switch Feature - Echo Request/Reply - 互相確認活著 - 是否失連 - => 若失連,需趕快找 Slave Controller 來確認狀態 - 測試 latency / bandwidth - Experimenter - Message Handling - TCP - Processing - Switch 必須處理每個 controller 給的 process - Switch 若處理有問題,必須讓 controller 知道(controller 要知道網路全局狀況,以免不同步) - controller 是 free-to-drop 的,但是必須回給 switch 的 hello echo,才不會讓 switch 不知道狀態(可能根本就斷線了) - Switch buffer 會有 time out 機制(controller 會 drop 卻沒有回給 Switch) - Ordering - barriar: 確保處理順序的機制 - Switch 處理完有 barriar reply - Bundle - 要下一系列指令時 - (switch 內)避免部分執行(ALL or NONE) - (跨 switch)避免只給到幾台機器(不然封包可能到一半,就不知道怎麼走了) - Read 比較不會造成不一致 / Write 不完全會造成可怕的不一致 - “ordered executions” and “packet atomic” flags - 正在修改 rules 時,不應該讓 packet 進來(可能會看到舊的/正在改變的 flow),可是這還蠻困難的 QQ - in packet buffer - 同時修改 flow - 把所有table變成兩份,命令下去後再一次替換 - ? - ![](https://i.imgur.com/DaotUlp.png) - ![](https://i.imgur.com/v1unMgs.png) - Encryption - TLS - fake controller - fake switch ## App over NOX Controller - 第一個 SDN Controller ### 在 SDN 裡實踐 LBP - LBP (Learning Bridge Protocol) - switch forwarding table (MAC-intface-TTL) - switch entry 是如何建立、如何維護 - SPT, Flood - 運行在一個沒有 loop 的網路上 -> STP(IEEE 802.11d) - SDN 運行(以 ping 為例) - Connect Setup - Hello - Feature Request - Set init config - Do - 當全新的 packet 進入 Switch 後,Switch 查找 Flow Table - 沒有找到 rule,Packet in 到 Controller - Controller 也是新的,所以會 Packet out 叫 Switch Flood (broadcast) - Flood 完後,Destion host 會回 echo - 再次 packet in 到 controller - Packet out 一個 Flow Modify(或其他指令,這就要看 SDN APP 的能力了) 到 Switch ,叫 Switch 把封包送回當初發 request 的 port - ![](https://i.imgur.com/dsmFW3P.jpg =400x) - Spanning Tree Algo. -- kruskal - 分散式系統(傳統網路)需要處理的 - 容錯 - 溝通 - 避免 loop / 減少網路切割 - SDN 因為有 中心 controller,所以應該會大量減少複雜度 - 不應該在用分散式的處理方法 - 已經會有蠻可靠的全網路拓樸 - SDN 用 LLDP (Link Layer Discovery Protocol) - controller 藉由 LLDP 跟 switch 溝通拓樸資訊 - switch 與 switch 也可以藉由 LLDP 溝通 - 當 controller 第一次跟 switch 連線時,會開 entry,接下來就是下一個 所有 LLDP 都送到 controller - ![](https://i.imgur.com/EtYO6gg.png =200x)![](https://i.imgur.com/tgdRsQw.png =200x) - ![](https://i.imgur.com/CQ9TkNN.png =200x)![](https://i.imgur.com/NkxGaHw.png =200x) - 溝通完,才能開始作 port modify - 每 5 分鐘送一個 LLDP 來確認 Link 還活著,容忍 miss 兩次 - 若 link 失敗,重新計算網路拓樸 ## Four Controller(Ryu, NOX, POX, Floodlight, ONOS) - Network emulator & simulator - emulator - 時間需要跟真實世界一樣 - ex. mininet - simulator - 可以直接把 OpenSource 的 controller 拿來跑 - 可以有自己的時間,加速、減速 - ex. EstiNet ## SDN Emulator -- Mininet Mininet 基本上是整合所有現有 app 做出來的模擬器 - switch 用 OpenVSwitch 兜 - 用 container 包,避免 VM Loading 太高 - host 的 app 用現有的 OS 的 app - 無法所有參數都 real-time 模擬,所以出來的數值幾乎都跟現實世界不同 - `--link=tc`: linux kernal 裡面的 traffic control,可以管理 interface 出來的 bandwidth => 才能在 addLink 下 bw 的參數 ## Open vSwitch (OVS) - 軟體實作的 virtual switch - 最原始是給 hypervisor 用的,讓多個 VM 可以溝通 - ![](https://i.imgur.com/I1lfDSq.png =400x) - 可選擇 bridge(learning bridge protocol) or NAT - 存在的時間遠比 SDN 早很多,在 Cloud computing 出來時,就被設計出來了 - (2004) Cloud Computing 需要作大量的虛擬化 - 讓 (Virtual)Server 可以輕鬆的轉移到不同的實體機 (Server Migration) - 讓筆電進入 Sleep 再起來,基本上就是 Server Migration 的實作方法 - VM image 基本上就是 Server wake up 的資源量 - 因為全軟體實作,所以 OpenFlow 一出現,馬上就可以跟上支援 - 可以直接讓 Linux 變成 OpenFlow Switch(變成單顆的 SDN Switch) - OVS 也成為硬體 SDN Switch 的 OpenFlow agent(跟 controller 溝通的 agent) 了 - ![](https://i.imgur.com/MpW6Cvu.png =400x) - 下層 match / action / ... 等還是用 ASIC 加速實作 - SDN Switch 的 Linux 是作 Management/Config 用的,不會作 table lookup (ASIC 作掉了) {跟 OVS On Linux 的 Linux 用途不一樣}

    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