| 781 | |
| 782 | |
| 783 | def sn_establish_new_GSL(container_id_list, matrix, constellation_size, bw, |
| 784 | loss, sat_index, GS_index, remote_ssh): |
| 785 | i = sat_index |
| 786 | j = GS_index |
| 787 | # IP address (there is a link between i and j) |
| 788 | delay = str(matrix[i - 1][j - 1]) |
| 789 | address_16_23 = (j - constellation_size) & 0xff |
| 790 | address_8_15 = i & 0xff |
| 791 | GSL_name = "GSL_" + str(i) + "-" + str(j) |
| 792 | # Create internal network in docker. |
| 793 | sn_remote_cmd( |
| 794 | remote_ssh, 'docker network create ' + GSL_name + " --subnet 9." + |
| 795 | str(address_16_23) + "." + str(address_8_15) + ".0/24") |
| 796 | print('[Create GSL:]' + 'docker network create ' + GSL_name + |
| 797 | " --subnet 9." + str(address_16_23) + "." + str(address_8_15) + |
| 798 | ".0/24") |
| 799 | sn_remote_cmd( |
| 800 | remote_ssh, 'docker network connect ' + GSL_name + " " + |
| 801 | str(container_id_list[i - 1]) + " --ip 9." + str(address_16_23) + "." + |
| 802 | str(address_8_15) + ".50") |
| 803 | ifconfig_output = sn_remote_cmd( |
| 804 | remote_ssh, "docker exec -it " + str(container_id_list[i - 1]) + |
| 805 | " ip addr | grep -B 2 9." + str(address_16_23) + "." + |
| 806 | str(address_8_15) + |
| 807 | ".50 | head -n 1 | awk -F: '{ print $2 }' | tr -d [:blank:]") |
| 808 | target_interface = str(ifconfig_output[0]).split("@")[0] |
| 809 | sn_remote_cmd( |
| 810 | remote_ssh, "docker exec -d " + str(container_id_list[i - 1]) + |
| 811 | " ip link set dev " + target_interface + " down") |
| 812 | sn_remote_cmd( |
| 813 | remote_ssh, "docker exec -d " + str(container_id_list[i - 1]) + |
| 814 | " ip link set dev " + target_interface + " name " + "B" + |
| 815 | str(i - 1 + 1) + "-eth" + str(j)) |
| 816 | sn_remote_cmd( |
| 817 | remote_ssh, "docker exec -d " + str(container_id_list[i - 1]) + |
| 818 | " ip link set dev B" + str(i - 1 + 1) + "-eth" + str(j) + " up") |
| 819 | sn_remote_cmd( |
| 820 | remote_ssh, "docker exec -d " + str(container_id_list[i - 1]) + |
| 821 | " tc qdisc add dev B" + str(i - 1 + 1) + "-eth" + str(j) + |
| 822 | " root netem delay " + str(delay) + "ms") |
| 823 | sn_remote_cmd( |
| 824 | remote_ssh, "docker exec -d " + str(container_id_list[i - 1]) + |
| 825 | " tc qdisc add dev B" + str(i - 1 + 1) + "-eth" + str(j) + |
| 826 | " root netem loss " + str(loss) + "%") |
| 827 | sn_remote_cmd( |
| 828 | remote_ssh, "docker exec -d " + str(container_id_list[i - 1]) + |
| 829 | " tc qdisc add dev B" + str(i - 1 + 1) + "-eth" + str(j) + |
| 830 | " root netem rate " + str(bw) + "Gbps") |
| 831 | print('[Add current node:]' + 'docker network connect ' + GSL_name + " " + |
| 832 | str(container_id_list[i - 1]) + " --ip 10." + str(address_16_23) + |
| 833 | "." + str(address_8_15) + ".50") |
| 834 | sn_remote_cmd( |
| 835 | remote_ssh, 'docker network connect ' + GSL_name + " " + |
| 836 | str(container_id_list[j - 1]) + " --ip 9." + str(address_16_23) + "." + |
| 837 | str(address_8_15) + ".60") |
| 838 | ifconfig_output = sn_remote_cmd( |
| 839 | remote_ssh, "docker exec -it " + str(container_id_list[j - 1]) + |
| 840 | " ip addr | grep -B 2 9." + str(address_16_23) + "." + |