| 689 | |
| 690 | |
| 691 | def sn_sr(src, des, target, container_id_list, remote_ssh): |
| 692 | ifconfig_output = sn_remote_cmd( |
| 693 | remote_ssh, "docker exec -it " + str(container_id_list[des - 1]) + |
| 694 | " ifconfig | sed 's/[ \t].*//;/^\(eth0\|\)\(lo\|\)$/d'") |
| 695 | des_IP = sn_remote_cmd( |
| 696 | remote_ssh, |
| 697 | "docker exec -it " + str(container_id_list[des - 1]) + " ifconfig " + |
| 698 | ifconfig_output[0][:-1] + "|awk -F '[ :]+' 'NR==2{print $4}'") |
| 699 | target_IP = sn_remote_cmd( |
| 700 | remote_ssh, "docker exec -it " + str(container_id_list[target - 1]) + |
| 701 | " ifconfig B" + str(target) + "-eth" + str(src) + |
| 702 | "|awk -F '[ :]+' 'NR==2{print $4}'") |
| 703 | sn_remote_cmd( |
| 704 | remote_ssh, "docker exec -d " + str(container_id_list[src - 1]) + |
| 705 | " ip route del " + str(des_IP[0][:-3]) + "0/24") |
| 706 | sn_remote_cmd( |
| 707 | remote_ssh, "docker exec -d " + str(container_id_list[src - 1]) + |
| 708 | " ip route add " + str(des_IP[0][:-3]) + "0/24 dev B%d-eth%d via " % |
| 709 | (src, target) + target_IP[0]) |
| 710 | print("docker exec -d " + str(container_id_list[src - 1]) + |
| 711 | " ip route add " + str(des_IP[0][:-3]) + "0/24 dev B%d-eth%d via " % |
| 712 | (src, target) + target_IP[0]) |
| 713 | |
| 714 | |
| 715 | def sn_ping(src, des, time_index, constellation_size, container_id_list, |