File tree Expand file tree Collapse file tree
src/services/pcn-router/test/test_shadow Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+
3+ source " ${BASH_SOURCE%/* } /../helpers.bash"
4+
5+ function cleanup {
6+ set +e
7+ del_routers 1
8+ }
9+ trap cleanup EXIT
10+
11+ set -x
12+ set -e
13+
14+ # Create the router r1
15+ polycubectl router add r1 shadow=true
16+ # Check if the namespace is created
17+ sudo ip netns ls
18+
19+ # Add port p1
20+ router_add_port r1 p1 10.0.0.1 255.255.255.0
21+ sudo ip netns exec pcn-r1 ip -c a
22+
23+ # Change the Ip address of the p1 port from Linux
24+ sudo ip netns exec pcn-r1 ifconfig p1 10.0.0.2/24
25+ polycubectl router r1 ports p1 show
26+
27+ # Add route from Linux
28+ sudo ip netns exec pcn-r1 ip route add 30.0.0.0/24 dev p1
29+ polycubectl router r1 route show
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # TOPOLOGY
3+ # +------+ +------+
4+ # | r1 |--------------------------------| r2 |
5+ # +------+ p1:10.0.0.1 p2:10.0.0.2 +------+
6+ #
7+ #
8+
9+ source " ${BASH_SOURCE%/* } /../helpers.bash"
10+
11+ function cleanup {
12+ set +e
13+ del_routers 2
14+ }
15+ trap cleanup EXIT
16+
17+ set -x
18+ set -e
19+ # Create the routers and connect them
20+ polycubectl router add r1 shadow=true
21+ polycubectl router add r2 # the router r2 can also be shadow, it is the same
22+ connect_router_p_to_p r1 r2 0
23+
24+ # Ping from inside r1 to r2
25+ sudo ip netns exec pcn-r1 ping 10.0.0.2 -c 3 -i 0.5
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # TOPOLOGY
3+ #
4+ #
5+ #
6+ # +------+
7+ # veth1 ------| r1 |------- veth2
8+ # +------+
9+ # |
10+ # |
11+ # |
12+ # veth3
13+
14+
15+ source " ${BASH_SOURCE%/* } /../helpers.bash"
16+
17+ function cleanup {
18+ set +e
19+ del_routers 1
20+ delete_veth 3
21+ }
22+ trap cleanup EXIT
23+
24+ # Create 3 namespaces
25+ # - "ns1", attached to the interface veth1. Such a network interface has
26+ # ip address 10.0.1.1/24, while the address 10.0.1.254 is set as a default gateway
27+ # - "ns2", attached to the interface veth2. Such a network interface has
28+ # ip address 10.0.2.1/24, while the address 10.0.2.254 is set as a default gateway
29+ # - "ns3", attached to the interface veth1. Such a network interface has
30+ # ip address 10.0.3.1/24, while the address 10.0.3.254 is set as a default gateway
31+ set -x
32+ create_veth_net 3
33+
34+ # You can use the following commands to check that everything has been set up correctly
35+
36+ # sudo ip netns ls
37+ # sudo ip netns exec ns3 [command]
38+
39+ set -e
40+
41+ # Create the router r1 (shadow)
42+ polycubectl router add r1 shadow=true
43+
44+ # Attaches the three ports to the router
45+ router_add_port_as_gateway r1 veth1 1
46+ router_add_port_as_gateway r1 veth2 2
47+ router_add_port_as_gateway r1 veth3 3
48+
49+ # All the namespaces try to ping each other
50+ ping_cycle 3
51+
52+ # Active span mode
53+ polycubectl router r1 set span=true
54+
55+ # Ping again with span mode active
56+ echo " enable Wireshark or Tcpdump"
57+ sleep 15
58+ ping_cycle 3
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ # TOPOLOGY
3+ #
4+ # +-----------+
5+ # | namespace |
6+ # +-----------+
7+ # ||
8+ # Linux ||
9+ # ________________||__________________
10+ # ||
11+ # Polycube ||
12+ # +------+
13+ # | r1 |
14+ # +------+
15+ #
16+
17+ source " ${BASH_SOURCE%/* } /../helpers.bash"
18+
19+ function cleanup {
20+ set +e
21+ del_routers 1
22+ }
23+ trap cleanup EXIT
24+
25+ set -x
26+ set -e
27+
28+ # Create the router r1 (shadow) and the port p1
29+ polycubectl router add r1 shadow=true
30+ router_add_port r1 p1 10.0.0.1 255.255.255.0
31+
32+ # Show router r1
33+ polycubectl router r1 show
34+
35+ # Change the Ip address of the p1 port from Linux
36+ sudo ip netns exec pcn-r1 ifconfig p1 192.168.0.1/24
37+ polycubectl router r1 show
38+
39+ # Add route from Linux
40+ sudo ip netns exec pcn-r1 ip route add 30.0.0.0/24 dev p1
41+ polycubectl router r1 show
42+
43+ # Remove route from Linux
44+ sudo ip netns exec pcn-r1 ip route del 30.0.0.0/24 dev p1
45+ polycubectl router r1 show
You can’t perform that action at this time.
0 commit comments