| 648 | |
| 649 | |
| 650 | def sn_damage(ratio, damage_list, constellation_size, remote_ssh, remote_ftp, |
| 651 | file_path, configuration_file_path): |
| 652 | print("Randomly setting damaged links...\n") |
| 653 | random_list = [] |
| 654 | cumulated_damage_list = damage_list |
| 655 | while len(random_list) < (int(constellation_size * ratio)): |
| 656 | target = int(random.uniform(0, constellation_size - 1)) |
| 657 | random_list.append(target) |
| 658 | cumulated_damage_list.append(target) |
| 659 | numpy.savetxt( |
| 660 | configuration_file_path + "/" + file_path + |
| 661 | '/mid_files/damage_list.txt', random_list) |
| 662 | remote_ftp.put(os.path.join(os.getcwd(), "starrynet/sn_orchestrater.py"), |
| 663 | file_path + "/sn_orchestrater.py") |
| 664 | remote_ftp.put( |
| 665 | configuration_file_path + "/" + file_path + |
| 666 | '/mid_files/damage_list.txt', file_path + "/damage_list.txt") |
| 667 | sn_remote_cmd(remote_ssh, |
| 668 | "python3 " + file_path + "/sn_orchestrater.py " + file_path) |
| 669 | print("Damage done.\n") |
| 670 | |
| 671 | |
| 672 | def sn_recover(damage_list, sat_loss, remote_ssh, remote_ftp, file_path, |