Filbert Cia
  • 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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 50.012 Lecture 12: Network Layer Overview # Network Layer ![](https://i.imgur.com/IfupsrZ.png) At the center of the Internet, there are a lot of routers that do not need the layers above the network layer. They are responsible in finding the path for the packets to travel around the network. They are also responsible in forwarding the packets from the source to destination. On the sending side, the network layer encapsulates segments into datagrams. On the receiving side, the network layer delivers segments to the transport layer -- the header is analyzed to determine how the packets are transported. A router examines the header fields in all IP datagrams passing through it. :::info Note: The term switching and forwarding in the context of network layer is interchangeable. Switching is used to cover both network layer and link layer. Forwarding is used specific for the network layer. ::: ## Forwarding vs Routing ### Forwarding Moving packets from router's input to appropriate router output. This happens in the data plane. Trip analogy: Process of getting through single interchange. ### Routing Determine route taken by packets from source to destination. This happens in the control plane. Trip analogy: Process of planning trip from source to destination. ### Data Plane ![](https://i.imgur.com/RMAGYPL.png) Data plane is a local, per-router function. It determines how datagram arriving on router input port is forwarded to router output port. ### Control Plane Control plane is a network-wide logic. It determines how datagram is routed among routers along end-to-end path from source host to destination host. There are two control-plane approaches: * Traditional routing algorithms (per-router control plane): Implemented in the routers (still a network-wide logic, but communication happens among the routers) * Software-defined networking (SDN): Implemented in (remote) servers. It's a more centralized approach that collects the information from the whole network, computes the path centrally, then distributes this information to all routers. #### Per-Router Control Plane ![](https://i.imgur.com/TK1Bq2B.png) The control plane in each router designs a local forwarding table (a lookup table) that the data plane can use to refer to when forwarding the data. #### Logically Centralized Control Plane ![](https://i.imgur.com/NmiMWIN.png) A distinct (typically remote) controller interacts with local control agents (CAs). Route calculations are aggregated into the SDN controller (remote controller on the diagram above). Each router now contains a CA that will gather information about the local situation of the router (conditions of the neighbouring routers) and through some interface, this information will be passed to the SDN controller. Once the forwarding table is calculated by the SDN controller, the forwarding table will be installed into each router. Through this concept, the data plane can be more generalized. Other than forwarding, it may also be able to do Firewall, etc. ## Network Service Model There are 2 main service models for the "channel" transporting datagrams from sender to receiver, grouped into individual datagrams and flow of datagrams. These are the list of services that are expected from the upper layers. Example services for individual datagrams: * guaranteed delivery * guaranteed delivery with less than 40 msec delay. Example services for a flow of datagrams: * in-order datagram delivery * guaranteed minimum bandwidth to flow * restrictions on changes in inter-packet spacing. # Routers High-level view of generic router architecture: ![](https://i.imgur.com/G0T07wd.png) The forwarding table is stored within each port. ## Input Port Functions ![](https://i.imgur.com/jyNEhzN.png) ![](https://i.imgur.com/Fi3Yg3E.png) When a packet arrives from the line, the line will first be terminated (by the physical layer). It will then be presented as a frame by the link layer. After some processing, it will be forwarded into the next block (which is within the network layer). This block will do a lookup to the forwarding table to decide which output port to forward this packet to. The switch fabric, however, may not be able to handle the packets as fast as the incoming line. Hence, it is the input port's responsibility to hold the packets from being processed. The reason why we need to have a forwarding table in each input port is so that this lookup process could be parallelized, removing one potential bottleneck. ### Destination-based Forwarding ![](https://i.imgur.com/v4EUkB8.png) For each particular range, we can forward the packet to the same interface. This is to allow for scaling. The neighbouring IP address is usually within the same ISP or organization. The logic is such that if the first x-bit of the incoming packet matches the prefix in the forwarding table, it will be sent through the respective link interface. #### Longest Prefix Matching Motivation Problem: In the previous example, Record 3 is a prefix of record 2. How does the router know where to forward the packet to? When looking for forwarding table entry for given destination address, use longest address prefix that matches destination address. ![](https://i.imgur.com/m5vgAlM.png) example 1: 0 example 2: 1 ##### Implementation of Longest Prefix Matching (TCAM) ![](https://i.imgur.com/Gq4RxXX.png) It is often performed using ternary content addressable memories (TCAMs). TCAM: Given a content, retrieve the address. Ternary means that there are 3 possible values: '0','1','X' (others). However, TCAM is more costly: * 6x more power than SRAM * 7x more area than SRAM * 4x higher latency than SRAM **Examples** ![](https://i.imgur.com/icfMgOm.png) ![](https://i.imgur.com/IsXhVOd.png) ### Typical Forwarding Diagram ![](https://i.imgur.com/iNp13m4.png) Use IP Address to find the index of the port. The forwarding table is split into the TCAM and the SRAM. ## Switching Fabrics The main responsibility of the switching fabrics is to transfer packet from input buffer to the appropriate output buffer. There are 3 types of switching fabrics: ![](https://i.imgur.com/oZJMwD8.png) ### First Generation Routers (Switching via Memory) ![](https://i.imgur.com/jqWk2AT.png) When a packet arrives at the ethernet port, it will be forwarded to the memory via the system bus. Then, it will be forwarded to the output port. * Traditional computers with switching under direct control of CPU. * Packet copied to system's memory. * Speed limited by memory bandwidth since there are 2 bus crossings per datagram. ### Switching via Bus ![](https://i.imgur.com/2Jksf0p.png) Datagram from the input port memory is forwarded to the output port memory via a **shared bus**. Bus Contention: Switching speed is now limited by bus bandwidth. ### Switching via Interconnection Network ![](https://i.imgur.com/GVcr8ZC.png) * Overcomes bus bandwidth limitation, since switchings can be done in parallel. * Crossbar (and other interconnection nets) was initially developed to connect processors in multiprocessors. There can be various topologies of crossbars. ## Input Port Queuing ![](https://i.imgur.com/SHNBFig.png) Fabric is slower than the input ports combined. Hence, we need to implement queuing mechanisms at the input ports. Queuing delay and loss are due to input buffer overflow. Head of the Line (HOL) blocking: queued datagram at front of queue prevents others in queue from moving forward (e.g. the front of queue packet is blocked from going to one of the output ports even though the destination of the second packet is free). ## Output Port ![](https://i.imgur.com/pvVL6eh.png) Buffering is required when datagrams that arrive from the fabric is faster than the **transmission rate**. Scheduling discipline (who gets the best performance) chooses among queued datagrams for transmission. ### Discard Policies If packet arrives to full queue, there are a few policies to choose which to discard: * Tail drop: drop arriving packet * Priority: drop/remove on priority basis * Random: drop/remove randomly Random dropping could be implemented to discourage people from hogging the bandwidth (those who use up a lot of bandwidth will get a higher packet loss rate). Another implementation is for TCP, when congestion happens (e.g. upon packet loss event), we will notify clients to reduce the bandwidth so that they will experience less packet loss. By doing random dropping, there is a higher chance to notify a lot of people to reduce the congestion. ### Scheduling Mechanisms Scheduling refers to choosing the next packet to send on link. #### FIFO scheduling ![](https://i.imgur.com/eXaO9Eq.png) Send in order of arrival to queue. #### Priority Scheduling ![](https://i.imgur.com/0gC9nk7.png) Send highest priority queued packet. For the implementation, we can have one class (queue) for each priority level. Class may depend on marking or other header info, e.g. IP source/destination, port numbers, etc. #### Round Robin (RR) Scheduling ![](https://i.imgur.com/nhZ1QdK.png) We will have multiple classes (not necessarily priority-based) in this implementation. Cyclically scan class queues, sending one complete packet from each class if available). This ensures fairness (all classes will be visited). #### Weighted Fair Queuing (WFQ) ![](https://i.imgur.com/LjKgQnO.png) It is a generalized Round Robin. Each class gets weighted amount of service in each cycle.

    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