Steven Lung
    • 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
    • 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

    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
    1
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # P4 10 ## 龍帆軒 楊逸婷 20201130 ### ECN ECN 全名 Explicit Congestion Notification 顯式擁塞通知,是一個對IP和TCP的擴充 TCP/IP 在傳輸封包時,會在通道阻塞時丟棄封包。 如果這時候有開啟ECN功能,ECN 的 router 會在IP的 header 中設定一個標記來代替丟棄封包,以告知阻塞即將發生。 封包的接收端回應傳送端的表示,降低其傳輸速率,以避免封包遺失 #### IP 中的 ECN 操作 ECN 使用 IPv4 header或 IPv6 header 中 ToS (Type of Service) 欄位的兩個最低有效位(最右側的位編碼)來表示四個狀態: 00 – 不支援 ECN 的傳輸,非 ECT(Non ECN-Capable Transport) 10 – 支援 ECN 的傳輸,ECT(0) 01 – 支援 ECN 的傳輸,ECT(1) 11 – 發生擁塞,CE(Congestion Encountered)。 ![](https://i.imgur.com/Lcl7EGw.gif) 當兩端支援 ECN 時,它將封包標為 ECT(0) 或 ECT(1)。 如果封包穿過一個遇到阻塞並且 router 支援 ECN 的 AQM 佇列,它可以將代碼更改為CE而非丟包。 > AQM : Active queue management > AQM常在 routers 跟 switches 使用到,為了要保持通道暢通跟降低 latency ,會將封包丟進一個 buffer 暫存 這種行為就是「標記」,其目的是通知接收端即將發生擁塞。在接收端,該擁塞指示由上層協定(傳輸層協定)處理,並且需要將訊號回傳給傳送端,以通知其降低傳輸速率。 因為 CE 指示只能由支援它的上層協定有效處理,ECN 只能配合上層協定使用。例如 TCP 協定,它支援阻塞控制並且有方法將 CE 指示回傳給傳送端。 #### TCP中的ECN TCP header 中的三個 flag 來支援ECN。第一個 flag 是隨機和(NS),另外兩個用於回傳擁塞指示(即指示傳送者應減少資訊傳送量)和確認接收到了擁塞指示回應(ECE跟CWR)。 > 隨機和 (Nonce Sum) : 用於防止TCP傳送者的封包標記被意外或惡意改動 > ECN-Echo(ECE) : 在 TCP 三方信號交換程序期間,TCP 對等體具備 ECN 功能 > Congestion Window Reduced(CWR) : 由傳送主機設定,指出已接到設定 ECE 旗標的 TCP 區段 當在一個 TCP 連接上 ECN 後,傳送方指示連接上的TCP packet 攜帶 IP 分組傳輸流量,將支援ECN的傳輸用ECT碼做標記。可以使支援ECN的中間 router 可以標記具有 CE 碼的 IP 分組而不是丟棄它們,以指示即將發生的阻塞。 當接收到具有遇到阻塞碼的封包時,TCP接收者使用TCP頭中的ECE標記回傳這個阻塞指示。當一個端點收到TCP帶有ECE位的 header 時,它減少其擁塞窗口來代替丟包。 ![](https://i.imgur.com/gQST0QO.png) ### Firewall Topology : ![](https://i.imgur.com/6iRSV0v.png) firewall.p4需要有以下的components 1. Ethernet (ethernet_t), IPv4 (ipv4_t) and TCP (tcp_t) 的header 2. Ethernet (ethernet_t), IPv4 (ipv4_t) and TCP (tcp_t) 的parser 3. 一個action來丟丟棄封包 4. 一個action來運算bloom filter的兩個hash 5. 基本的ipv4 forwarding 6. 一個action來設置一個變數來存action的參數 7. 一個table來讀封包的ingress和egress並且使用到 6. 的action 8. 一個control用來 9. 一個deparser用來emit Ethernet (ethernet_t), IPv4 (ipv4_t) and TCP (tcp_t) 封包 10. 一個 package instantiation 要實作 Firewall 會到 bloom filter >Bloom filter 就是用來尋找資料有沒有存在的hash function。 >![](https://i.imgur.com/lUsQD30.png) P4 有自己的封包傳送定義,儅封包規格符合定義,啓動action。 Make指令把Packet-processing rules 載入switch中(定義在sX-runtime) Iperf : 一種開源網路工具用來測量網路的throughput 和performance ![](https://i.imgur.com/xndSOlM.png) S1 是當作firewall,所以在需要添加一個firewall.json ![](https://i.imgur.com/ti7ADXw.png) Mark_to_drop() 用來丟棄封包 High-level approach : 此bloom filter擁有2個hash function,檢查送到internal network的封包是否建立TCP連接。在bloom filter用2個各爲32bits的reg array 更新每次hash 的結果。 ![](https://i.imgur.com/06mrXWd.png) Set_direction會建立一個1 bit的方向。如果封包來自internal network, 方向是1; 來自external 方向為0 Table check_port判斷direction,方向為1就丟入compute_hash計算 ![](https://i.imgur.com/ntp2V6B.png) //還沒看>< ![](https://i.imgur.com/MPE6XfM.png) ###### tags: `P4`

    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