| 352 | |
| 353 | # A thread designed for emulation. |
| 354 | class sn_Emulation_Start_Thread(threading.Thread): |
| 355 | |
| 356 | def __init__(self, remote_ssh, remote_ftp, sat_loss, sat_ground_bw, |
| 357 | sat_ground_loss, container_id_list, file_path, |
| 358 | configuration_file_path, update_interval, constellation_size, |
| 359 | ping_src, ping_des, ping_time, sr_src, sr_des, sr_target, |
| 360 | sr_time, damage_ratio, damage_time, damage_list, |
| 361 | recovery_time, route_src, route_time, duration, |
| 362 | utility_checking_time, perf_src, perf_des, perf_time): |
| 363 | threading.Thread.__init__(self) |
| 364 | self.remote_ssh = remote_ssh |
| 365 | self.remote_ftp = remote_ftp |
| 366 | self.sat_loss = sat_loss |
| 367 | self.sat_ground_bw = sat_ground_bw |
| 368 | self.sat_ground_loss = sat_ground_loss |
| 369 | self.container_id_list = copy.deepcopy(container_id_list) |
| 370 | self.file_path = file_path |
| 371 | self.configuration_file_path = configuration_file_path |
| 372 | self.update_interval = update_interval |
| 373 | self.constellation_size = constellation_size |
| 374 | self.ping_src = ping_src |
| 375 | self.ping_des = ping_des |
| 376 | self.ping_time = ping_time |
| 377 | self.perf_src = perf_src |
| 378 | self.perf_des = perf_des |
| 379 | self.perf_time = perf_time |
| 380 | self.sr_src = sr_src |
| 381 | self.sr_des = sr_des |
| 382 | self.sr_target = sr_target |
| 383 | self.sr_time = sr_time |
| 384 | self.damage_ratio = damage_ratio |
| 385 | self.damage_time = damage_time |
| 386 | self.damage_list = damage_list |
| 387 | self.recovery_time = recovery_time |
| 388 | self.route_src = route_src |
| 389 | self.route_time = route_time |
| 390 | self.duration = duration |
| 391 | self.utility_checking_time = utility_checking_time |
| 392 | if self.container_id_list == []: |
| 393 | self.container_id_list = sn_get_container_info(self.remote_ssh) |
| 394 | |
| 395 | def run(self): |
| 396 | ping_threads = [] |
| 397 | perf_threads = [] |
| 398 | timeptr = 2 # current emulating time |
| 399 | topo_change_file_path = self.configuration_file_path + "/" + self.file_path + '/Topo_leo_change.txt' |
| 400 | fi = open(topo_change_file_path, 'r') |
| 401 | line = fi.readline() |
| 402 | while line: # starting reading change information and emulating |
| 403 | words = line.split() |
| 404 | if words[0] == 'time': |
| 405 | print('Emulation in No.' + str(timeptr) + ' second.') |
| 406 | # the time when the new change occurrs |
| 407 | current_time = str(int(words[1][:-1])) |
| 408 | while int(current_time) > timeptr: |
| 409 | start_time = time.time() |
| 410 | if timeptr in self.utility_checking_time: |
| 411 | sn_check_utility( |