experimental_packet_routing
cosmica.experimental_packet_routing
BackupCaseType
module-attribute
BackupCaseType = Literal[
"no-backup",
"backup-feeder-links",
"backup-n-hops-links",
"backup-n-hops-links-and-feeder-links",
"dual-backup-n-hops-links-and-feeder-links",
]
__all__
module-attribute
__all__ = [
"BackupCaseType",
"PacketCommunicationSimulator",
"PacketRoutingResult",
"PacketRoutingSetting",
"RoutingResultVisualizer",
"RoutingResultVisualizer",
"SpaceTimeGraph",
]
PacketCommunicationSimulator
PacketCommunicationSimulator(
time: NDArray[datetime64],
all_graphs_with_comm_performance: list[Graph],
nodes_dict: dict[NodeGID, Node],
demands: list[Demand],
*,
backup_case: BackupCaseType = "no-backup",
hop_limit: int = 1,
packet_size: int = int(10000.0),
space_time_graph: SpaceTimeGraph
)
時系列のパケットレベルの通信シミュレーションを実施するクラス.
| PARAMETER | DESCRIPTION |
|---|---|
time
|
Array of datetime64 representing the time points
TYPE:
|
all_graphs_with_comm_performance
|
List of Graph objects representing communication performance over time
TYPE:
|
nodes_dict
|
Dictionary mapping NodeGID to Node objects |
demands
|
List of demands
TYPE:
|
backup_case
|
Backup case scenario identifier, default is 'no-backup'
TYPE:
|
hop_limit
|
Hop limit for backup routing, default is 1
TYPE:
|
packet_size
|
Size of the packet for communication [bit], default is 10,000
TYPE:
|
space_time_graph
|
SpaceTimeGraph object
TYPE:
|
Source code in src/cosmica/experimental_packet_routing/simulator.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
all_graphs_with_comm_performance
instance-attribute
all_graphs_with_comm_performance: list[Graph] = (
all_graphs_with_comm_performance
)
hop_limit
instance-attribute
hop_limit: int = hop_limit
node_knowledge_known_by_each_node
instance-attribute
node_knowledge_known_by_each_node: dict[
Node, NodeKnowledge
] = {}
packet_size
instance-attribute
packet_size: int = packet_size
space_time_graph
instance-attribute
space_time_graph = space_time_graph
time
instance-attribute
time: NDArray[datetime64] = time
create_packet_routing_setting
create_packet_routing_setting() -> PacketRoutingSetting
Generate and return a PacketRoutingSetting object.
Source code in src/cosmica/experimental_packet_routing/simulator.py
95 96 97 98 99 100 101 102 103 104 | |
run
run(
*,
rng: Generator | None = None,
edge_remove_schedule: (
list[tuple[datetime64, tuple[Node, Node]]] | None
) = None,
failure_detection_time: timedelta64 | None = None,
enable_random_routing_when_edge_failure: bool = False,
prevent_loop: bool = False,
with_lsa: bool = True,
lsa_case: LsaCaseType = "from-source-to-all"
) -> PacketRoutingResult
| PARAMETER | DESCRIPTION |
|---|---|
rng
|
NumPy random number generator. If None, use default.
TYPE:
|
edge_remove_schedule
|
List of edge removal schedule
TYPE:
|
failure_detection_time
|
Time taken for failure detection
TYPE:
|
enable_random_routing_when_edge_failure
|
Flag to enable random routing when edge failure
TYPE:
|
prevent_loop
|
Flag to prevent loop in routing
TYPE:
|
with_lsa
|
Flag to enable LSA data
TYPE:
|
lsa_case
|
Case scenario identifier for LSA data, default is 'nominal'
TYPE:
|
Source code in src/cosmica/experimental_packet_routing/simulator.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 | |
PacketRoutingResult
dataclass
PacketRoutingResult(
*,
all_graphs_after_simulation: list[Graph] = list[
Graph
](),
node_knowledge_known_by_each_node: dict[
Node, NodeKnowledge
] = dict[Node, NodeKnowledge](),
comm_data_demand_list: list[CommDataDemand] = list[
CommDataDemand
](),
comm_data_lsa_list: list[CommDataLSA] = list[
CommDataLSA
]()
)
all_graphs_after_simulation
class-attribute
instance-attribute
all_graphs_after_simulation: list[Graph] = field(
default_factory=list[Graph]
)
comm_data_demand_list
class-attribute
instance-attribute
comm_data_demand_list: list[CommDataDemand] = field(
default_factory=list[CommDataDemand]
)
comm_data_lsa_list
class-attribute
instance-attribute
comm_data_lsa_list: list[CommDataLSA] = field(
default_factory=list[CommDataLSA]
)
node_knowledge_known_by_each_node
class-attribute
instance-attribute
node_knowledge_known_by_each_node: dict[
Node, NodeKnowledge
] = field(default_factory=dict[Node, NodeKnowledge])
load
classmethod
load(
graphs_path: Path | None = None,
node_knowledge_path: Path | None = None,
comm_data_demand_path: Path | None = None,
comm_data_lsa_path: Path | None = None,
) -> Self
指定されたパスからpickleファイルを読み込み.
Source code in src/cosmica/experimental_packet_routing/dtos.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 | |
save_all_graphs_after_simulation
save_all_graphs_after_simulation(save_path: Path) -> None
Source code in src/cosmica/experimental_packet_routing/dtos.py
44 45 46 47 48 49 50 | |
save_comm_data_demand_list
save_comm_data_demand_list(save_path: Path) -> None
Source code in src/cosmica/experimental_packet_routing/dtos.py
60 61 62 63 64 65 66 | |
save_comm_data_lsa_list
save_comm_data_lsa_list(save_path: Path) -> None
Source code in src/cosmica/experimental_packet_routing/dtos.py
68 69 70 71 72 73 74 | |
save_node_knowledge_known_by_each_node
save_node_knowledge_known_by_each_node(
save_path: Path,
) -> None
Source code in src/cosmica/experimental_packet_routing/dtos.py
52 53 54 55 56 57 58 | |
PacketRoutingSetting
dataclass
PacketRoutingSetting(
*,
time: NDArray[datetime64],
nodes_dict: dict[NodeGID, Node],
demands: list[Demand],
backup_case: BackupCaseType,
hop_limit: int,
packet_size: int
)
hop_limit
instance-attribute
hop_limit: int
packet_size
instance-attribute
packet_size: int
time
instance-attribute
time: NDArray[datetime64]
load
classmethod
load(load_path: Path) -> PacketRoutingSetting
Source code in src/cosmica/experimental_packet_routing/dtos.py
140 141 142 143 144 145 | |
save
save(save_path: Path) -> None
Source code in src/cosmica/experimental_packet_routing/dtos.py
135 136 137 138 | |
RoutingResultVisualizer
RoutingResultVisualizer(
simulation_settings: PacketRoutingSetting,
packet_routing_result: PacketRoutingResult,
)
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
32 33 34 35 36 37 38 | |
packet_routing_result
instance-attribute
packet_routing_result: PacketRoutingResult = (
packet_routing_result
)
simulation_settings
instance-attribute
simulation_settings: PacketRoutingSetting = (
simulation_settings
)
time
cached
property
time: NDArray
time_from_epoch
cached
property
time_from_epoch: NDArray
time_step_array
cached
property
time_step_array: NDArray
calculate_average_delay
calculate_average_delay(
*,
time_from: datetime64 | None = None,
time_to: datetime64 | None = None,
weighted_data_size: bool = True
) -> float
到着したデータについて平均遅延時間を計算する.
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
calculate_average_increased_delay
calculate_average_increased_delay(
time_baseline: datetime64,
*,
time_from: datetime64 | None = None,
time_to: datetime64 | None = None,
weighted_data_size: bool = True
) -> float
到着したデータについて平均遅延時間の、ある時刻の遅延時間に対する増加量を計算する.
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
calculate_average_packet_loss_rate
calculate_average_packet_loss_rate(
*,
time_from: datetime64 | None = None,
time_to: datetime64 | None = None,
weighted_data_size: bool = True
) -> float
生成データの平均パケットロス率を計算する.
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
plot_accumulated_arrival_data_size
plot_accumulated_arrival_data_size(
save_path: Path,
*,
with_title: bool = False,
title_fontsize: int = 16,
label_fontsize: int = 14,
legend_fontsize: int = 12,
tick_label_fontsize: int = 12,
legend_loc: str = "best",
xlim: tuple | None = None,
ylim: tuple | None = None,
dpi: int = 300,
with_grid: bool = False,
use_time_from_epoch: bool = False
) -> None
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 | |
plot_arrival_data_rate
plot_arrival_data_rate(
save_path: Path,
*,
with_title: bool = False,
title_fontsize: int = 16,
label_fontsize: int = 14,
legend_fontsize: int = 12,
tick_label_fontsize: int = 12,
legend_loc: str = "best",
xlim: tuple | None = None,
ylim: tuple | None = None,
dpi: int = 300,
with_grid: bool = False,
use_time_from_epoch: bool = False
) -> None
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 | |
plot_delay
plot_delay(
save_path: Path,
*,
with_title: bool = False,
title_fontsize: int = 16,
label_fontsize: int = 14,
legend_fontsize: int = 12,
tick_label_fontsize: int = 12,
legend_loc: str = "best",
xlim: tuple | None = None,
ylim: tuple | None = None,
dpi: int = 300,
with_grid: bool = False,
use_time_from_epoch: bool = False,
replace_inf: bool = False
) -> None
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
plot_graph_animation
plot_graph_animation(
time_index_from: int,
time_index_to: int,
time_index_step: int,
dynamics_data: DynamicsData[ConstellationSatellite],
save_path: Path,
*,
with_demand_data: bool = True,
with_lsa_data: bool = False,
dpi: int = 100
) -> None
時間経過に伴うグラフの変化をアニメーションで描画する.
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 | |
plot_graph_at_certain_time
plot_graph_at_certain_time(
time: datetime64,
dynamics_data: DynamicsData[ConstellationSatellite],
save_path: Path,
*,
with_demand_data: bool = True,
with_lsa_data: bool = False,
dpi: int = 100
) -> None
指定した時間のグラフを描画する.
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
plot_graph_over_time
plot_graph_over_time(
time_index_from: int,
time_index_to: int,
time_index_step: int,
dynamics_data: DynamicsData[ConstellationSatellite],
save_path: Path,
*,
with_demand_data: bool = True,
with_lsa_data: bool = False,
dpi: int = 100
) -> None
時間経過に伴うグラフの変化を描画する.
Source code in src/cosmica/experimental_packet_routing/routing_result_visualizer.py
488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 | |
SpaceTimeGraph
dataclass
SpaceTimeGraph(
time_for_snapshots: list[datetime64],
graph_for_snapshots: list[Graph],
)
Base model for a space time graph.
Source code in src/cosmica/experimental_packet_routing/space_time_graph.py
27 28 29 30 31 32 33 | |
graph_for_snapshots
instance-attribute
graph_for_snapshots: list[Graph] = graph_for_snapshots
time_for_snapshots
instance-attribute
time_for_snapshots: list[datetime64] = time_for_snapshots
get_space_time_graph_at_time
get_space_time_graph_at_time(time: datetime64) -> Graph
Get the space time graph at the specified time.
Source code in src/cosmica/experimental_packet_routing/space_time_graph.py
169 170 171 172 | |
make_space_time_graph_from_graph
classmethod
make_space_time_graph_from_graph(
time: NDArray[datetime64],
graphs: list[Graph],
*,
check_interval_time: timedelta64 | None = None
) -> Self
Update time and graph lists if the graph shape changes.
Source code in src/cosmica/experimental_packet_routing/space_time_graph.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
update_space_time_graph_for_failure_edge
update_space_time_graph_for_failure_edge(
failure_edge: tuple[Node, Node], update_time: datetime64
) -> Self
Update the space time graph for the failure edge.
Source code in src/cosmica/experimental_packet_routing/space_time_graph.py
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |