自定义配置文件

用户终端配置完成之后默认进入上传配置ZIP包页面,用户可以在此页面下载默认配置文件或当前配置文件,如果是通过默认配置创建网络,两者无异。

image.png

用户也可以在上传配置ZIP包页面点击完成,先跳转至网络列表页面,在刚刚创建好的网络的操作中点击上传zip

image.png

再次进入上传配置ZIP包页面

image.png

用户点击当前配置文件,或者是默认配置文件下载zip,解压得到 config.yaml和节点的配置文件。

每个节点信息文件夹下存在两个子文件夹,分别为 frr_conffrr_logfrr_conf会保存底层节点的配置信息,而frr_log会保存节点的运行日志信息。

image.png

用户只需编辑config.yaml做进一步配置,例如配置半实物节点,将文件夹压缩,拖拽上传,修改网络配置。

地面网络卫星网络详细配置文件字段可以参考config.yaml

image.png

上传成功点击完成按钮,跳转至网络列表页面,进行进一步操作。

config.yaml

地面网络

config.yaml包含了该地面网络的核心配置信息。

地面网络规范yaml格式如下:

templates:
  frr:
    image: library/frrouting/frr:v8.4.0
    start_commands:
    - chown -R frr:frr /var/log/frr
    - /usr/lib/frr/frrinit.sh start
    stop_commands:
    - /usr/lib/frr/frrinit.sh stop
    volumes:
    - frr_conf:/etc/frr
nodes:
  node1:
    default_status: UP
    node_type: host
    alias: my_node_1
    extra_args:
      x:
      - -171
      - 948
      y:
      - -82
      - 498
    template: frr
    vNICs:
      eth0:
        ip:
        - 10.0.0.2/8
        - fd00::2/8
        mac: 36:50:fc:3c:e9:bc
  node2:
    default_status: UP
    node_type: router
    alias: node2
    extra_args:
      x:
      - 31
      - 948
      y:
      - -98
      - 498
    template: frr
    physical: true
    vNICs:
      eth0:
        physical_nic_name: XGE1/0/6
        ip:
        - 10.0.0.3/8
        - fd00::3/8
        mac: 36:50:fc:7b:11:a3
  node3:
    default_status: UP
    node_type: monitor
    alias: node3
    extra_args:
      x:
      - -60
      - 948
      y:
      - 47
      - 498
    template: frr
    vNICs:
      eth0:
        ip:
        - 10.0.0.4/8
        - fd00::4/8
        mac: 36:50:fc:9a:e0:8e
logical_links:
  veth_pairs:
  - - node2:eth0
    - node3:eth0
  - - node1:eth0
    - node3:eth0

节点配置

在config.yaml中,用户可以在 nodes 字段下自定义拓扑节点。每个 node 可以包含以下可选字段:

  • node_type:字符串类型,节点类型。可选值包括 hostrouterasmonitornull
  • image:字符串类型,节点的镜像地址。
  • start_commands:字符串数组,节点启动时执行的命令。
  • stop_commands:字符串数组,节点删除时执行的命令。
  • volumes:由 volume 组成的数组,用于定义挂载的存储卷。
  • resources:节点的资源配置。
  • default_status:节点的默认状态,只能是 UPDOWN
  • vNICs:节点的网络接口配置。
  • alias:字符串类型,节点的别名。
  • extra_args:额外参数(节点在拓扑中的 X 轴和 Y 轴坐标)。
  • physical:布尔值,表示该节点是否为物理节点。用于在半实物仿真场景中进行区分。

节点网络接口(Network Interface)配置

用户可以在每个节点的 vNICs 字段下,为节点配置其网络接口,包括 IPv4 和 IPv6 地址以及 MAC 地址。如果该节点为物理节点,还可以配置 physical_nic_name 字段,指定物理设备网口的名称。

配置示例1

vNICs:
  eth0:
    ip:
    - 10.0.0.3/8
    - fd00::3/8
    mac: 36:50:fc:7b:11:a3

上述配置为节点的 eth0 网口分配了 IPv4 地址 10.0.0.3/8 和 IPv6 地址 fd00::3/8,以及 MAC 地址 36:50:fc:7b:11:a3

配置示例2

physical: true
vNICs:
  eth0:
    physical_nic_name: XGE1/0/6
    ip:
    - 10.0.0.3/8
    - fd00::3/8
    mac: 36:50:fc:7b:11:a3

额外配置该物理节点eth0网卡名为XGE1/0/6

链路配置

目前支持links“点对点”链路以及bridges桥接模式。logical_link则表示两端的可达性(Reachability)

veth_pair表示链路的一端,由(节点名: 网卡名)构成,网卡必须正确配置在节点上。

veth_pairs表示一条链路,由两个veth_pair,即[(节点名1: 网卡名1), (节点名2, 网卡名2)]组成。

links:
  veth_pairs:
  - - node2:eth0
    - node3:eth0

指定node2:eth0node3:eth0以点对点的形式连接。

以点对点形式配置的链路,两端网口必须都配置MAC地址。

logical_link:
  veth_pairs:
  - - node2:eth0
    - node3:eth0

表示node2:eth0node3:eth0可达。

bridges由多个bridge构成,每一个bridge可以配置nameveths字段,分别表示其名字与通过桥接模式连接的veth_pair

bridges:
  bridge1:
    name: my_bridge
    veths:
      - node0:eth0
      - node1:eth0
      - node2:eth0

配置(node0:eth0) (node1:eth0) (node2:eth0)以桥接模式互联。

模板配置

templates - 节点模板,可以在配置节点时复用。

用户可以在配置文件的 templates 字段下定义节点模板(如 tmpl),每个模板可以包含 node_typeimagestart_commandsstop_commandsvolumesresourcesdefault_statusvNICs 等字段。如果节点中也配置了上述字段,节点的配置将优先于模板,不会被模板覆盖。

模版中的vNICs需要单独用tmpl_vNIC配置,与普通网口配置一样。

templates:
  frr:
    image: library/frrouting/frr:v8.4.0
    start_commands:
    - chown -R frr:frr /var/log/frr
    - /usr/lib/frr/frrinit.sh start
    stop_commands:
    - /usr/lib/frr/frrinit.sh stop
    volumes:
    - frr_conf:/etc/frr
    default_status: DOWN
  openeuler:
    image: library/openeuler/openeuler:22.03
    node_type: host
    volumes: []
    start_commands: []
    stop_commands: []

表示定义了frropeneuler这两个模板

nodes:
  node1:
    default_status: UP
    node_type: host
    alias: my_node_1
    extra_args:
      x:
      - -171
      - 948
      y:
      - -82
      - 498
    template: frr
    vNICs:
      eth0:
        ip:
        - 10.0.0.2/8
        - fd00::2/8
        mac: 36:50:fc:3c:e9:bc

配置节点时用template定义该节点用frr模板填充该配置。若该节点与模板配置有重复字段,则不会用模板值填充。上述node1中尽管用frr模板填充配置,但default_status不会被模板中的default_status覆盖。

卫星网络

配置文件包含了该网络的核心配置信息。

卫星网络规范yaml格式如下:

templates:
  sat_tmpl:
    node_type: sat
    image: ponedo/frr-ubuntu20:tiny
    start_commands:
    - chown -R frr:frr /var/log/frr
    - /usr/lib/frr/frrinit.sh start
    stop_commands:
    - /usr/lib/frr/frrinit.sh stop
    volumes:
    - frr_conf:/etc/frr
    - frr_log:/var/log/frr
    fixed_vNICs:
      eth0: {}
      eth1: {}
      eth2: {}
      eth3: {}
      eth4: {}
      eth5: {}
    resources:
      cpu_score: 1691
      memory: 4GB
  gs_tmpl:
    node_type: gs
    image: ponedo/frr-ubuntu20:tiny
    start_commands:
    - chown -R frr:frr /var/log/frr
    - /usr/lib/frr/frrinit.sh start
    stop_commands:
    - /usr/lib/frr/frrinit.sh stop
    volumes:
    - frr_conf:/etc/frr
    - frr_log:/var/log/frr
  end_user_tmpl:
    node_type: end_user
    image: alvrme/alpine-android
    start_commands: []
    stop_commands: []
    volumes: []
    fixed_vNICs:
      eth0: {}
# Fixed nodes (satellites)
fixed_nodes:
  Sat0:
    sat_id: 0
    template: sat_tmpl
  Sat1:
    sat_id: 1
    template: sat_tmpl
  Sat2:
    sat_id: 2
    node_type: sat
    physical: true
    fixed_vNICs:
      eth0:
        physical_nic_name: XGE1/0/5
      eth1:
        physical_nic_name: XGE1/0/6
      eth2:
        physical_nic_name: XGE1/0/7
      eth3:
        physical_nic_name: XGE1/0/8
      eth4:
        physical_nic_name: XGE1/0/9
      eth5:
        physical_nic_name: XGE1/0/10
    vNICs: # User-defined vNICs
      eth6:
        physical_nic_name: XGE1/0/11
       # New interface linking to the computing host
  Sat3:
    sat_id: 3
    template: sat_tmpl
    
  gs_0:
    template: gs_tmpl
    gs_id: 0
    fixed_vNICs:
      eth0: {}
  gs_1:
    template: gs_tmpl
    gs_id: 1
    fixed_vNICs:
      eth0: {}
  alice:
    template: end_user_tmpl
    end_user_id: 0
  bob:
    template: end_user_tmpl
    end_user_id: 1

nodes: # User-defined nodes
  Sat2_host: # The computing host on Sat100
    physical: true
    node_type: host
    vNICs:
      eth0:
        physical_nic_name: XGE1/0/12
        
  Sat321_host: # The computing host on Sat321
    image: library/openeuler/openeuler:22.03
    node_type: host
    volumes:
    - logs:/var/log/
    vNICs:
      eth0: {}
    
    
links:
  engines:
  - walker_delta
  veth_pairs:
    - [ "Sat2:eth6", "Sat2_host:eth0" ]
    - [ "Sat3:eth2", "Sat3_host:eth0" ]
  • templates

该部分表示为每一个 node 中的公共配置,通过公共配置可以批次处理若干节点。

sat_tmpl :自定义配置的key,该值可以自定义设置,此处为卫星节点的公共配置信息。其中:

node_typesat 表示节点类型为卫星。

image :该节点的镜像系统,为runc的运行镜像。

start_commands :节点初次运行所需要执行的命令。

stop_commands :节点停止时执行的命令。

volumes :物理存储的映射位置,注意格式为 - frr_conf:/etc/frrfrr_conf 为节点信息文件夹中需要存在子文件夹。

fixed_vNICs :必须存在的网口信息,表示该节点需要具有的网口数量,在例子中,卫星默认为 4 个,1 个信关站通信网口,1 个用户终端通信网口。

resources :该虚拟节点需要分配的资源。

physical :该节点是否为实物节点,注意:如果该节点是实物节点,需要在 fixed_vNICs 下的网口信息中配置 physical_nic_name ,该字段非必须。

vNICs :用户手动添加的网口信息,非必须。

gs_tmplend_user_tmpl 同理,分别表示信关站公共配置信息和公共用户终端的配置信息,需要注意的是公共配置 node_typegsend_user

  • fixed_nodes

必须存在的节点,该部分的节点名称需要与zip压缩包内的节点信息文件夹一一对应。同时可以通过设置节点下的 template 字段来指定该节点的公用配置信息,如果需要自定义覆盖公共配置信息下的特定字段,可以在节点下直接设置该字段的值来实现自定义配置 override 公共配置信息。例如:

fixed_nodes:
  Sat0:
    sat_id: 0
    template: sat_tmpl
    image: test/frr-ubuntu20:tiny
  Sat1:
    sat_id: 1
    template: sat_tmpl

在配置文件读取下会默认使用用户自定义的字段数据来覆盖公共配置,例子中,将会按照用户自定义的 image 字段来 override sat_tmpl 中的 image 信息。通过此方式来灵活的实现用户的个性化需求。

每个fixed_nodes下的node中可配置参数同 templates ,这里不再赘述。

  • nodes

该部分为用户自定义添加的节点信息,一般对应卫星载荷等设备,node_type 设置为 host ,该部分下的节点同样需要在zip配置存在对应的节点信息文件夹

配置参数同 templates ,这里不再赘述。

  • links

该部分定义网络的链路状态。卫星场景下,可配置两个字段:

engines :卫星的轨道构型。

veth_pairs :用户自定义的链路连接,可为空,如果自定义格式为 [ "Sat2:eth6", "Sat2_host:eth0" ] ,格式为一个长度为 2 的字符串数组,每个字符串格式为 节点名称:网口名称 ,该数组表示链路的起点和终点。

==格式验证==

当用户自定义修改 config.yaml,网络仿真平台会核验用户填写的字段是否合规,核验格则如下:

  1. fixed_nodesnodes下定义的节点在zip配置文件中存在对应的节点信息文件夹。
  2. physical 为 false 或者不存在时,表示虚拟节点,虚拟节点必须设置 image字段。为 true 时表示该节点为实物节点,必须配置 fixed_vNICsvNICs 下的网口信息中的 physical_nic_name 字段,设置网口信息。