68469663e2b0302aab5ae98b0ea37971aa84c2dd
[demo.git] / vnfs / vFW / scripts / v_packetgen_init.sh
1 #!/bin/bash
2
3 # Start VPP
4 start vpp
5 sleep 1
6
7 # Configure VPP for vPacketGenerator
8 IPADDR1=$(ifconfig eth1 | grep "inet addr" | tr -s ' ' | cut -d' ' -f3 | cut -d':' -f2)
9 HWADDR1=$(ifconfig eth1 | grep HWaddr | tr -s ' ' | cut -d' ' -f5)
10 FAKE_HWADDR1=$(echo -n 00; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"')
11 PROTECTED_NET_CIDR=$(cat /opt/config/protected_net_cidr.txt)
12 FW_IPADDR=$(cat /opt/config/fw_ipaddr.txt)
13 SINK_IPADDR=$(cat /opt/config/sink_ipaddr.txt)
14
15 ifconfig eth1 down
16 ifconfig eth1 hw ether $FAKE_HWADDR1
17 ip addr flush dev eth1
18 ifconfig eth1 up
19 vppctl tap connect tap111 hwaddr $HWADDR1
20 vppctl set int ip address tap-0 $IPADDR1"/24"
21 vppctl set int state tap-0 up
22 brctl addbr br0
23 brctl addif br0 tap111
24 brctl addif br0 eth1
25 ifconfig br0 up
26 vppctl ip route add $PROTECTED_NET_CIDR via $FW_IPADDR
27 sleep 1
28
29 # Install packet streams
30 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp1
31 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp2
32 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp3
33 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp4
34 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp5
35 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp6
36 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp7
37 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp8
38 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp9
39 sed -i -e "0,/UDP/ s/UDP:.*/UDP: "$IPADDR1" -> "$SINK_IPADDR"/" /opt/pg_streams/stream_fw_udp10
40 vppctl exec /opt/pg_streams/stream_fw_udp1
41 vppctl exec /opt/pg_streams/stream_fw_udp2
42 vppctl exec /opt/pg_streams/stream_fw_udp3
43 vppctl exec /opt/pg_streams/stream_fw_udp4
44 vppctl exec /opt/pg_streams/stream_fw_udp5
45 vppctl exec /opt/pg_streams/stream_fw_udp6
46 vppctl exec /opt/pg_streams/stream_fw_udp7
47 vppctl exec /opt/pg_streams/stream_fw_udp8
48 vppctl exec /opt/pg_streams/stream_fw_udp9
49 vppctl exec /opt/pg_streams/stream_fw_udp10
50 sleep 1
51
52 # Start HoneyComb
53 echo "" > /var/lib/honeycomb/persist/context/data.json
54 echo "" > /var/lib/honeycomb/persist/config/data.json
55 /opt/honeycomb/sample-distribution-1.0.0/honeycomb &>/dev/null &disown
56 sleep 20
57
58 # Enable traffic flows
59 cd /opt
60 chmod +x run_traffic_fw_demo.sh
61 ./run_traffic_fw_demo.sh &>/dev/null &disown