# 云中网络-TODO

* [Network in the cloud](#network-in-the-cloud)
  * [Virtualization networkcard](#virtualization-networkcard)
    * [Flowchart](#flowchart)
    * [Share access](#share-access)
      * [Connect internally](#connect-internally)
      * [Connect to the outside](#connect-to-the-outside)
        * [Network bridging](#network-bridging)
        * [NAT](#nat)
    * [Separation access](#separation-access)
  * [Overlay network](#overlay-network)
    * [Motivation](#motivation)
    * [Definition](#definition)
    * [Approaches](#approaches)
      * [GRE - Generic Routing Encapsulation](#gre---generic-routing-encapsulation)
      * [VXLAN](#vxlan)
  * [SDN](#sdn)
    * [Use cases](#use-cases)
    * [OpenFlow and Openvswitch](#openflow-and-openvswitch)
  * [References](#references)

## Network in the cloud

### Virtualization networkcard

#### Flowchart

* The steps are shown in the graph below:
  1. Virtual machine could open a char dev file called TUN/TAP.
  2. After opening this file, a virtual network card driver will be seen on the physical machine.
  3. This virtual network card will intercept network packets and send it through TCP/IP.
  4. The virtual network card tap0 will send network packets.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-edcde8881a9f5ed7ca76485cf0dba84f06a5d377%2Fvirtualization_networkcard.png?alt=media)

#### Share access

**Connect internally**

1. Use the Linux command to create an ethernet bridge

> brctl addbr br0

1. Connect two virtual network card to br0

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-4cb5bf8e8784ac715b363ca750afcb5afa2a215d%2Fvirtualization_networkcard_share.png?alt=media)

**Connect to the outside**

**Network bridging**

* Def: Virtual machine and physical machine will share the same IP address.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-4d1b568e1e49e7728dd9052b8a48970a47a6e1fd%2Fvirtualization_networkcard_share_bridging.png?alt=media)

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-2a0bdf187ed29ebee8b2eec868ace9fd035c942c%2Fvirtualization_networkcard_share_bridging_flattened.png?alt=media)

* Within cloud, the virtual machines inside Linux also share the same address as physical machines.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-b56b870a0c69a421adeb34d3801c73082a44b6b7%2Fvirtualization_networkcard_cloud.png?alt=media)

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-ed652683628ae126685e41329b00f1a9c8b0515d%2Fvirtualization_networkcard_cloud_flattened.png?alt=media)

* Cons: When there is a large scale of machines, broadcast will be a problem because each virtualized machine needs to be broadcasted.

**NAT**

* Def: Virtual machines will have different ip address as physical machines.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-8057532224712c95489feef1425ebb685efc9f8a%2Fvirtualization_networkcard_nat.png?alt=media)

* A DHCP server will be created for assigning ip addresses to virtual machines dynamically.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-2de98f142118d43a406800a62869ad387721479f%2Fvirtualization_networkcard_nat_dhcp.png?alt=media)

#### Separation access

* Approach: create VLAN based on physical network card eth0

> vconfig

* Within the same machine, there is no connectivity between network bridges.
* Across machines, as long as physical bridge support VLAN, there will be no connectivity between different VLANs.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-9fcc53ef6898945292fe22d689b39e1502c35e40%2Fvirtualization_networkcard_separation.png?alt=media)

### Overlay network

#### Motivation

* Limitation of VLAN: Only has 12 bits and a capacity of 4096.
* Possible solutions
  * Modify the VLAN protocol.
  * Extend the protocol by adding an additional header.

#### Definition

* Underlay network: Physical network
* Overlay network: Virtual network implemented on top of underlay network.

#### Approaches

**GRE - Generic Routing Encapsulation**

* Idea: It increases the number of VLAN ID by the way of tunnel.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-a4032245a02fed586de490d517dd504413133306%2Fvirtualization_overlay_gre.png?alt=media)

* Example

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-876fda77d4366ea84b6f8525702ea956bf2d2b27%2Fvirtualization_overlay_gre_example.png?alt=media)

* Limitation:
  * The number of tunnels
  * It does not support group cast.

**VXLAN**

* Idea:

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-8cd30bbe1f587102fe0f2cf44dce8ecced735850%2Fvirtualization_overlay_VXLAN.png?alt=media)

### SDN

#### Use cases

* Control and forward

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-2b5d271ad95abdb1debbe63848dc32857b80b4e9%2Fvirtualization_sdn.png?alt=media)

#### OpenFlow and Openvswitch

* SDN controller administrates the network by OpenFlow protocol.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-cabd1f0dbca598200ff06976fa29bc6b80b48e5b%2Fvirtualization_sdn_openflow.png?alt=media)

* Within the Openvswitch, there is a flow table which defines flow rules.

![](https://1010073591-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mk8dv8Mfudl_6ziUzDf%2Fuploads%2Fgit-blob-6102330ee80a797cfa37cae3e34fcdf73b4a2d4c%2Fvirtualization_sdn_openflow_2.png?alt=media)

### References

* [趣谈网络协议](https://time.geekbang.org/column/article/10742)
