Documentation for Sanetwork Module¶
SANetwork
¶
Bases: SAMComponent
Network situational awareness component responsible for monitoring and managing the communication context within the federation.
This component handles
- Tracking active and potential peer nodes.
- Evaluating network conditions for situational awareness decisions.
- Integrating with discovery and reasoning modules for dynamic topology updates.
Inherits from SAMComponent to participate in the broader Situational Awareness pipeline.
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
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 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 |
|
cm
property
¶
Communication Manager
np
property
¶
Neighbor Policy
sana
property
¶
SA Network Agent
sar
property
¶
SA Reasoner
accept_connection(source, joining=False)
async
¶
Decide whether to accept an incoming connection request from a source node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source
|
str
|
The address of the requesting node. |
required |
joining
|
bool
|
True if this is part of a join process. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
bool |
True if the connection should be accepted, False otherwise. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
198 199 200 201 202 203 204 205 206 207 208 209 210 |
|
beacon_received(beacon_recieved_event)
async
¶
Process a received beacon event by publishing a NodeFoundEvent for the given address.
Extracts the address and geolocation from the beacon event and notifies the system that a new node has been discovered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
beacon_recieved_event
|
BeaconRecievedEvent
|
The event containing beacon data. |
required |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
create_verification_task(nodes)
async
¶
Create and track a verification task for neighbor establishment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes
|
set
|
The set of node addresses for which connections were attempted. |
required |
Returns:
Type | Description |
---|---|
asyncio.Task: The created verification task. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 |
|
experiment_finish(efe)
async
¶
Handle the completion of an experiment by shutting down the external connection service.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
efe
|
ExperimentFinishEvent
|
The event indicating the experiment has finished. |
required |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
248 249 250 251 252 253 254 255 |
|
forget_nodes(nodes_to_forget)
async
¶
Instruct the neighbor policy to remove specified nodes from its known set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes_to_forget
|
set
|
Addresses of nodes to be purged from policy memory. |
required |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
482 483 484 485 486 487 488 489 |
|
get_actions()
async
¶
Retrieve the set of situational awareness actions applicable to the current network state.
Returns:
Name | Type | Description |
---|---|---|
list |
Identifiers of available network actions. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
221 222 223 224 225 226 227 228 |
|
get_nodes_known(neighbors_too=False, neighbors_only=False)
async
¶
Retrieve the list of known nodes in the network.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
neighbors_too
|
bool
|
Include neighbors in the result. Defaults to False. |
False
|
neighbors_only
|
bool
|
Return only neighbors. Defaults to False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
set |
Addresses of known nodes based on the provided filters. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
176 177 178 179 180 181 182 183 184 185 186 187 |
|
get_restructure_process_lock()
¶
Retrieve the asynchronous lock protecting the restructure process.
Returns:
Type | Description |
---|---|
asyncio.Lock: Lock to ensure only one restructure operation runs at a time. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
299 300 301 302 303 304 305 306 |
|
init()
async
¶
Initialize the SANetwork component by deploying external connection services, subscribing to relevant events, starting beaconing, and configuring neighbor policies.
Actions performed: 1. If not an additional participant, start and subscribe to beacon and finish events. 2. Otherwise, initialize ECS without running it. 3. Build and apply the neighbor policy using current direct and undirected connections. 4. Subscribe to node discovery and neighbor update events. 5. Register this agent with the situational awareness network agent.
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
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 |
|
meet_node(node)
async
¶
Propose a meeting (connection) with a newly discovered node if it is not self.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
str
|
The address of the node to meet. |
required |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
166 167 168 169 170 171 172 173 174 |
|
need_more_neighbors()
async
¶
Determine if the network requires additional neighbor connections.
Returns:
Name | Type | Description |
---|---|---|
bool |
True if more neighbors are needed, False otherwise. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
212 213 214 215 216 217 218 219 |
|
neighbors_left()
async
¶
Check whether any direct neighbor connections remain.
Returns:
Name | Type | Description |
---|---|---|
bool |
True if there are one or more direct neighbor connections, False otherwise. |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
189 190 191 192 193 194 195 196 |
|
reconnect_to_federation()
async
¶
Clear any connection restrictions and initiate a late‐connection discovery process to rejoin the federation.
Steps: 1. Acquire the restructure lock. 2. Clear blacklist and recently disconnected restrictions. 3. If known node addresses exist, use them for discovery; otherwise, perform a fresh discovery. 4. Release the restructure lock.
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
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 |
|
sa_component_actions()
async
¶
Perform periodic situational awareness checks for network conditions.
This method evaluates the external connection service status and analyzes the robustness of the current network topology.
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
128 129 130 131 132 133 134 135 136 137 |
|
stop()
async
¶
Stop the SANetwork component by releasing locks and clearing any pending operations.
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
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 |
|
stop_connections_with_federation()
async
¶
Disconnect from all current federation neighbors after a short delay.
- Waits for a predefined sleep period (to allow in‐flight messages to complete).
- Blacklists each direct neighbor.
- Disconnects from each neighbor without mutual handshake.
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 |
|
upgrade_connection_robustness(possible_neighbors)
async
¶
Attempt to strengthen network robustness by discovering or reconnecting to additional neighbors.
Steps: 1. Acquire the restructure lock. 2. If possible_neighbors is non‐empty, use them for a targeted late‐connection discovery. 3. Otherwise, perform a generic discovery of federation nodes. 4. Release the restructure lock.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
possible_neighbors
|
set
|
Addresses of candidate nodes for connection enhancement. |
required |
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
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 |
|
verify_neighbors_stablished(nodes)
async
¶
Verify that a set of connection attempts has succeeded within a timeout.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nodes
|
set
|
The set of node addresses for which connections were attempted. |
required |
Behavior: 1. Sleeps for NEIGHBOR_VERIFICATION_TIMEOUT seconds. 2. Compares the originally requested nodes against the currently known neighbors. 3. Logs any addresses that failed to establish and instructs the policy to forget them.
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
|
SANetworkAgent
¶
Bases: SAModuleAgent
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
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 |
|
create_and_suggest_action(saca, function=None, more_suggestions=False, *args)
async
¶
Create a situational awareness command based on the specified action and suggest it for arbitration.
Depending on the SACommandAction provided, this method:
- Instantiates the appropriate SACommand via the factory.
- Submits the command to the arbitration process (suggest_action
).
- Optionally finalizes suggestion collection (notify_all_suggestions_done
).
- In some cases waits for execution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
saca
|
SACommandAction
|
The situational awareness action to suggest (e.g., SEARCH_CONNECTIONS, RECONNECT). |
required |
function
|
Callable
|
The function to execute if the command is chosen. Defaults to None. |
None
|
more_suggestions
|
bool
|
If False, marks the end of suggestion gathering. Defaults to False. |
False
|
*args
|
Additional positional arguments passed to the SACommand constructor to be used as function parameters. |
()
|
Source code in nebula/core/situationalawareness/awareness/sanetwork/sanetwork.py
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 |
|