Ping CN1- switch1 - switch2 - CN2
交换机物理连接
5(s1)-(s4)
9(s1)-9(s2)
13(s1)-cn0
17(s1)-cn1
5(s2)-5(s3)
9(s2)-9(s1)
13(s2)-cn2
17(s2)-cn3
开启物理机S1、S2
asic-setup.sh
开启stratum
stratum_bfrt -chassis_config_file=/etc/stratum/x86-64-accton-wedge100bf-32x-r0/chassis_config.pb.txt -bf_switchd_cfg=/usr/local/sde/share/p4/targets/tofino/skip_p4.conf -enable_onlp=false -bf_sde_install=$SDE_INSTALL
交换机打开runtime-shell,并下发表项

s1交换机
S1开启p4-runtime:
docker run -ti -v $PWD:/tmp/ p4lang/p4runtime-sh --grpc-addr 202.197.0.140:9559 --device-id 1 --election-id 0,1 --config /tmp/p4info.txt,/tmp/device_config.pb.bin
向S1交换机下发表项:
te1 = table_entry["Ingress.ipv4_lpm"](action="send")
te1.match["hdr.ipv4.dst_addr"] = "10.0.2.31/32"
te1.action["port"]="48"
te1.insert()
te2 = table_entry["Ingress.ipv4_lpm"](action="send")
te2.match["hdr.ipv4.dst_addr"] = "10.0.2.21/32"
te2.action["port"]="12"
te2.insert()
s2交换机
docker run -ti -v $PWD:/tmp/ p4lang/p4runtime-sh --grpc-addr 202.197.0.150:9559 --device-id 1 --election-id 0,1 --config /tmp/p4info.txt,/tmp/device_config.pb.bin
te1 = table_entry["Ingress.ipv4_lpm"](action="send")
te1.match["hdr.ipv4.dst_addr"] = "10.0.2.31/32"
te1.action["port"]="20"
te1.insert()
te2 = table_entry["Ingress.ipv4_lpm"](action="send")
te2.match["hdr.ipv4.dst_addr"] = "10.0.2.21/32"
te2.action["port"]="52"
te2.insert()
测试CN1 ping CN2
首次进入CN2时,IP还是10.0.1.31,IP网段不正确。【经过本次调整后,通过该程序可直接ping成功!】
进入
sudo vim /etc/sysconfig/network-scripts/ifcfg-eth2 修改相应的网络卡

再分别在CN1和CN2中加入对方的arp
[hxy@cn1 ~]$ sudo arp -s 10.0.2.31 e8:eb:d3:a7:2c:af
[hxy@cn1 ~]$ arp -a 10.0.2.31
? (10.0.2.31) at e8:eb:d3:a7:2c:af [ether] PERM on eth2
[gyn@cn2 ~]$ sudo arp -s 10.0.2.21 e8:eb:d3:a7:29:af
[gyn@cn2 ~]$ arp -a 10.0.2.21
? (10.0.2.21) at e8:eb:d3:a7:29:af [ether] PERM on eth2
测试CN1 ping CN2 成功!

测试CN2 ping CN1 成功!
