Skip to content
Merged
Show file tree
Hide file tree
Changes from 217 commits
Commits
Show all changes
247 commits
Select commit Hold shift + click to select a range
83c3936
Servicio de conexión UDP
AlejandroAvilesSerrano Jul 3, 2024
cbeb58f
fix_filename
AlejandroAvilesSerrano Jul 3, 2024
3e9ad7b
fix_nebulamulticasting
AlejandroAvilesSerrano Jul 6, 2024
7c039a3
feat_mobility_module
AlejandroAvilesSerrano Jul 10, 2024
f9a3964
fix_function_arguments
AlejandroAvilesSerrano Jul 10, 2024
edd4ef5
fix_compiler_errors
AlejandroAvilesSerrano Jul 13, 2024
092af15
feat_timer_generator
AlejandroAvilesSerrano Jul 16, 2024
66613aa
Merge branch 'main' into feat_nebula_mobility
AlejandroAvilesSerrano Jul 17, 2024
85b706b
fix_timer_integrated
AlejandroAvilesSerrano Jul 17, 2024
2012cc1
fix_lock_release_excep
AlejandroAvilesSerrano Jul 17, 2024
f53b32c
fix_waiting_logic
AlejandroAvilesSerrano Jul 17, 2024
2925f21
Merge branch 'main' into feat_nebula_mobility
AlejandroAvilesSerrano Nov 2, 2024
5ca1761
fixed_some_mobility_configurations
AlejandroAvilesSerrano Nov 15, 2024
cab1ba0
update_nebula_p2b.py
AlejandroAvilesSerrano Nov 15, 2024
80df6e3
Merge branch 'main' into feat_nebula_mobility
AlejandroAvilesSerrano Nov 15, 2024
e7ac641
feat_mobility_upgrade
AlejandroAvilesSerrano Nov 24, 2024
2a081e1
feat_late_starting_trainning
AlejandroAvilesSerrano Nov 25, 2024
c0768cd
feat_LateNodes_train
AlejandroAvilesSerrano Nov 26, 2024
a1166b0
Merge branch 'main' into feat_nebula_mobility
AlejandroAvilesSerrano Nov 26, 2024
71c7604
fix_fast_push
AlejandroAvilesSerrano Nov 27, 2024
3e0353f
Merge branch 'main' into feat_nebula_mobility
AlejandroAvilesSerrano Nov 27, 2024
c495af6
feat_weights_modifiers
AlejandroAvilesSerrano Nov 27, 2024
ec553b6
fix_slow_push_strategy
AlejandroAvilesSerrano Nov 28, 2024
ab1af93
fix_metric_delay
AlejandroAvilesSerrano Nov 29, 2024
fc64e40
feat_fast_push
AlejandroAvilesSerrano Nov 29, 2024
9051a78
fix_fast_reboot
AlejandroAvilesSerrano Dec 2, 2024
2077832
feat_upgrading_network_robustness
AlejandroAvilesSerrano Dec 2, 2024
e86db89
fix_ecs_run_shutdown
AlejandroAvilesSerrano Dec 3, 2024
11f37d8
fix_info_points
AlejandroAvilesSerrano Dec 4, 2024
3e8ed56
feat_nebulamulticasting_on_off
AlejandroAvilesSerrano Dec 5, 2024
b84818d
fix_errors_reestructuring
AlejandroAvilesSerrano Dec 10, 2024
7ebf7de
fix_restructure_errors
AlejandroAvilesSerrano Dec 10, 2024
3b72cde
feat_connection_optimizator
AlejandroAvilesSerrano Dec 10, 2024
b8f7c35
feat_network_optimization
AlejandroAvilesSerrano Dec 11, 2024
fbbccd0
fix_minor_errors
AlejandroAvilesSerrano Dec 12, 2024
1fe818d
fix_remove_weight_error
AlejandroAvilesSerrano Dec 12, 2024
33d9578
fix_solving_distributions
AlejandroAvilesSerrano Dec 16, 2024
8325055
feat_additional_data_dist_png
AlejandroAvilesSerrano Dec 16, 2024
5b9ef3d
fix_additional_nodes_ip
AlejandroAvilesSerrano Dec 17, 2024
8c177fa
ft_test_setup
AlejandroAvilesSerrano Dec 19, 2024
9a7d809
fix_no_coinciding_samples
AlejandroAvilesSerrano Dec 19, 2024
d05833b
fix_update
AlejandroAvilesSerrano Dec 24, 2024
7d6dbf4
feat_defaultMH
AlejandroAvilesSerrano Dec 24, 2024
111568c
fix_error_defaultHM
AlejandroAvilesSerrano Dec 24, 2024
882e4eb
fix_wrong_payload
AlejandroAvilesSerrano Dec 24, 2024
ba6a397
fix_keyerror_np
AlejandroAvilesSerrano Dec 25, 2024
b70cc41
fix_general_errors
AlejandroAvilesSerrano Dec 27, 2024
82bc4bf
fix_reestructure_loop
AlejandroAvilesSerrano Dec 28, 2024
66d62bc
fix_slow_push_issue
AlejandroAvilesSerrano Jan 1, 2025
3445a76
fix:concurrency_issue
AlejandroAvilesSerrano Jan 2, 2025
19e53f9
fix_get_neighbors_np
AlejandroAvilesSerrano Jan 2, 2025
fbf9eb1
daily_update
AlejandroAvilesSerrano Jan 7, 2025
822a470
change_scenario_config
AlejandroAvilesSerrano Jan 9, 2025
9b50740
fix_momentum
AlejandroAvilesSerrano Jan 10, 2025
4637885
update_from_main
AlejandroAvilesSerrano Jan 10, 2025
139dae7
fix_com_error
AlejandroAvilesSerrano Jan 10, 2025
1177a4f
updt_momentum
AlejandroAvilesSerrano Jan 11, 2025
e4e5287
feat_momentum
AlejandroAvilesSerrano Jan 12, 2025
282ab2f
feat_momemtum_penalty
AlejandroAvilesSerrano Jan 12, 2025
7f5e230
updt_momemtum_penalty_ext
AlejandroAvilesSerrano Jan 13, 2025
e57767c
update momemtum
AlejandroAvilesSerrano Jan 23, 2025
a0c9c24
update_messages_refactor
AlejandroAvilesSerrano Jan 24, 2025
7001c6c
fix_msg_errors
AlejandroAvilesSerrano Jan 24, 2025
614af0f
fix_messages_factory
AlejandroAvilesSerrano Jan 25, 2025
8adf02c
fix_error
AlejandroAvilesSerrano Jan 25, 2025
25ca56d
fix_factory_message_action
AlejandroAvilesSerrano Jan 25, 2025
55bfb2e
fix_message_factory
AlejandroAvilesSerrano Jan 26, 2025
13547ba
feat_refactor_messages
AlejandroAvilesSerrano Jan 26, 2025
849d1b8
fix_clean_code
AlejandroAvilesSerrano Jan 26, 2025
5812aa3
fix_refactor_communciations
AlejandroAvilesSerrano Jan 27, 2025
ed2d764
fix_handle_model_error
AlejandroAvilesSerrano Jan 27, 2025
bfef62c
feat_message_events
AlejandroAvilesSerrano Jan 29, 2025
ff2a3d1
fix_error_msg
AlejandroAvilesSerrano Jan 29, 2025
7f9d4be
fix_event_error
AlejandroAvilesSerrano Jan 29, 2025
18e9183
fix_errors
AlejandroAvilesSerrano Jan 29, 2025
6a1384a
update_momemtum
AlejandroAvilesSerrano Jan 30, 2025
db3710b
updt
AlejandroAvilesSerrano Jan 30, 2025
3b3d523
fix_momemtum_config
AlejandroAvilesSerrano Feb 3, 2025
56b8997
optimization_sinc
AlejandroAvilesSerrano Feb 6, 2025
fd1e734
opt_sinc++
AlejandroAvilesSerrano Feb 6, 2025
bc6f7b8
fix_momentum
AlejandroAvilesSerrano Feb 7, 2025
81edea1
fix_disconnect_error
AlejandroAvilesSerrano Feb 7, 2025
8c1fc0f
fix_disconnection_node
AlejandroAvilesSerrano Feb 7, 2025
e6413cd
fix_TCP_temporary_port
AlejandroAvilesSerrano Feb 7, 2025
85fabd2
fix_notself_agg
AlejandroAvilesSerrano Feb 7, 2025
4ecb5bd
fix_tcp_ports
AlejandroAvilesSerrano Feb 7, 2025
2275f65
feat_node_disconnection
AlejandroAvilesSerrano Feb 8, 2025
cef7757
feat_blacklist
AlejandroAvilesSerrano Feb 10, 2025
c8c3656
fix_resinc_error
AlejandroAvilesSerrano Feb 10, 2025
d8fbb31
fix_resinc_after_disc
AlejandroAvilesSerrano Feb 11, 2025
6348cee
fix_resinc_Node
AlejandroAvilesSerrano Feb 11, 2025
83ce2ff
merge 'origin/main' into feat_nebula_connection_service
AlejandroAvilesSerrano Feb 11, 2025
0669f8f
feat_target_attacks
AlejandroAvilesSerrano Feb 12, 2025
3031cfe
feature select changing targets
AlejandroAvilesSerrano Feb 13, 2025
43cce2b
feat standar mobility strategies
AlejandroAvilesSerrano Feb 13, 2025
d5cdb7d
feataure update storage
AlejandroAvilesSerrano Feb 13, 2025
d3abf62
fix update storage errors
AlejandroAvilesSerrano Feb 13, 2025
16ca2da
fix_no_round_mechs
AlejandroAvilesSerrano Feb 14, 2025
2dafe3a
fix_error
AlejandroAvilesSerrano Feb 14, 2025
646c9a3
Feature update handlers interface
AlejandroAvilesSerrano Feb 15, 2025
ceb516f
feature dfl no rounds
AlejandroAvilesSerrano Feb 17, 2025
9d96587
fix updates handling and ecs service
AlejandroAvilesSerrano Feb 17, 2025
b821b37
fix_propagator_error
AlejandroAvilesSerrano Feb 18, 2025
37a017c
opt_test_mobility
AlejandroAvilesSerrano Feb 18, 2025
4432f46
refactor situational awareness
AlejandroAvilesSerrano Feb 18, 2025
4f23e38
feature situational awareness module functionalities
AlejandroAvilesSerrano Feb 18, 2025
f1364f0
feature nebula discover service asynchronous
AlejandroAvilesSerrano Feb 19, 2025
c2e1d7c
optimization code
AlejandroAvilesSerrano Feb 19, 2025
1f28f77
feature beacon service
AlejandroAvilesSerrano Feb 20, 2025
3d5ff25
fix fully integrated beacon
AlejandroAvilesSerrano Feb 20, 2025
f4951d6
feature geolocalization in beacon
AlejandroAvilesSerrano Feb 20, 2025
4afccbc
fix daily update
AlejandroAvilesSerrano Feb 20, 2025
98e3e2e
feature nebula gps service
AlejandroAvilesSerrano Feb 21, 2025
e6bb7b4
fix mobility errors
AlejandroAvilesSerrano Feb 21, 2025
2f8f2d8
feature updating mobility module
AlejandroAvilesSerrano Feb 21, 2025
474de4c
fix mobility errors
AlejandroAvilesSerrano Feb 21, 2025
56928c6
fix missing await
AlejandroAvilesSerrano Feb 21, 2025
1d32273
fix generate network conditions
AlejandroAvilesSerrano Feb 23, 2025
58c65b5
fix mobility low threshold error
AlejandroAvilesSerrano Feb 23, 2025
00eff3f
feature network simulator
AlejandroAvilesSerrano Feb 23, 2025
8c4ec3b
feature integrated nebula network simulator
AlejandroAvilesSerrano Feb 24, 2025
aaccf0a
feature SA submodules
AlejandroAvilesSerrano Feb 25, 2025
bda0596
fix additional node network conditions
AlejandroAvilesSerrano Feb 26, 2025
387ec6d
fix network conditions fist attemp
AlejandroAvilesSerrano Feb 26, 2025
e552734
feature training policy interface
AlejandroAvilesSerrano Feb 26, 2025
bc5dec0
feature event system for addon functionalities
AlejandroAvilesSerrano Feb 27, 2025
b244684
feat aggregation event
AlejandroAvilesSerrano Feb 27, 2025
8f957c1
feature event system integrated
AlejandroAvilesSerrano Feb 28, 2025
ced5f9b
feature QDS tp - update received event
AlejandroAvilesSerrano Mar 3, 2025
270a56a
feature round start event
AlejandroAvilesSerrano Mar 4, 2025
dabc965
feature speed oriented selection
AlejandroAvilesSerrano Mar 4, 2025
719cefd
feature CFL implementation for udpate storage
AlejandroAvilesSerrano Mar 5, 2025
0bd99b2
feature beacon received event
AlejandroAvilesSerrano Mar 6, 2025
836fbad
feature sos sa strategy
AlejandroAvilesSerrano Mar 7, 2025
ef5033b
opt sat sos
AlejandroAvilesSerrano Mar 10, 2025
1655705
feature sat hts
AlejandroAvilesSerrano Mar 11, 2025
b5c1dab
fix error offers accepted after stopped lt process
AlejandroAvilesSerrano Mar 12, 2025
0b2cdc4
opt engine
AlejandroAvilesSerrano Mar 13, 2025
a6f34d4
Merge remote-tracking branch 'origin/main' into mobility_roundsoff
AlejandroAvilesSerrano Mar 13, 2025
6b3fe49
fix evaluation before aggregation
AlejandroAvilesSerrano Mar 13, 2025
02111eb
fix additional participants datasets
AlejandroAvilesSerrano Mar 13, 2025
10578b3
opt nebuladataset factory
AlejandroAvilesSerrano Mar 14, 2025
540771b
saving wating scenarios in the database
FerTV Mar 14, 2025
3d92944
feature hybrid datasets
AlejandroAvilesSerrano Mar 14, 2025
448b5ff
feat datasets 'n' splitted
AlejandroAvilesSerrano Mar 14, 2025
88b281e
feature split dataset IID subsets
AlejandroAvilesSerrano Mar 17, 2025
907a81a
wip hybrid datasets
AlejandroAvilesSerrano Mar 17, 2025
9031ebd
fix dirichlet subset generated
AlejandroAvilesSerrano Mar 18, 2025
e99eb8f
feature unbalanced IID hybrid datasets
AlejandroAvilesSerrano Mar 20, 2025
62adab9
feature cifar10 hybrid data partitioning
AlejandroAvilesSerrano Mar 21, 2025
de55472
fix mnist error
AlejandroAvilesSerrano Mar 21, 2025
4a9e25d
fix dflupdatehandler & qds
AlejandroAvilesSerrano Mar 24, 2025
09e5fbe
updt
AlejandroAvilesSerrano Mar 25, 2025
4ff9eb3
opt space
AlejandroAvilesSerrano Mar 26, 2025
6ae66c7
feature nebula plugin loader
AlejandroAvilesSerrano Mar 27, 2025
dccd82f
refactor(controller): migrate user modifications from front-end to co…
FerTV Mar 28, 2025
9766c3e
feature SA command
AlejandroAvilesSerrano Apr 2, 2025
db182ad
fix communciation manager importatition
AlejandroAvilesSerrano Apr 2, 2025
2babfd4
feature connectivity commands
AlejandroAvilesSerrano Apr 2, 2025
05f2b4b
refactor previous created endpoints and scenarios endpoints added
FerTV Apr 2, 2025
0f7581e
feature suggestionbuffer
AlejandroAvilesSerrano Apr 3, 2025
982d0fe
fix suggestionbuffer
AlejandroAvilesSerrano Apr 3, 2025
f18ef81
daile update
AlejandroAvilesSerrano Apr 3, 2025
f824224
fix endpoints for scenarios
FerTV Apr 3, 2025
4cc2091
feature integrated suggestions system
AlejandroAvilesSerrano Apr 4, 2025
df24dfd
fix error interface
AlejandroAvilesSerrano Apr 4, 2025
044d517
opt suggestion buffer
AlejandroAvilesSerrano Apr 5, 2025
144c3f3
feat integrated more events
AlejandroAvilesSerrano Apr 5, 2025
d56b361
refactor communication manager property
AlejandroAvilesSerrano Apr 6, 2025
f78efdd
fix early updates received before starting learning
AlejandroAvilesSerrano Apr 6, 2025
c642d5e
feature training policies as SA Agents
AlejandroAvilesSerrano Apr 7, 2025
a60336b
fix owner missing SACommands
AlejandroAvilesSerrano Apr 7, 2025
b2a20bf
Merge remote-tracking branch 'origin/main' into feature/db-optimization
FerTV Apr 8, 2025
dcf415d
morning update
AlejandroAvilesSerrano Apr 8, 2025
17ade40
removed unused parameters
FerTV Apr 8, 2025
d3f09f1
databases removed of frontend docker container
FerTV Apr 8, 2025
8cac0b2
fix monitor page and node related endpoints
FerTV Apr 8, 2025
ca04b12
fix samodule mediate function
AlejandroAvilesSerrano Apr 8, 2025
f6c374d
fix sa module arbitatrion
AlejandroAvilesSerrano Apr 9, 2025
64e8e05
feature close to integrate node forgiveness
AlejandroAvilesSerrano Apr 9, 2025
f9c56c5
feature system monitoring + forget nodes
AlejandroAvilesSerrano Apr 10, 2025
5a47c4a
feature static arbitatrion policy
AlejandroAvilesSerrano Apr 11, 2025
d4075aa
feature behavior reputation
AlejandroAvilesSerrano Apr 16, 2025
c554a91
feature reputation messages
AlejandroAvilesSerrano Apr 23, 2025
7c4144b
feature dinamically loading sa components
AlejandroAvilesSerrano Apr 24, 2025
1ffb5e2
refactor situational awareness module
AlejandroAvilesSerrano Apr 24, 2025
7360711
refactor SA module
AlejandroAvilesSerrano Apr 28, 2025
745b731
feature consistency reputation
AlejandroAvilesSerrano Apr 30, 2025
9e567eb
feature advanced consistency metrics
AlejandroAvilesSerrano May 2, 2025
abb2155
Merge remote-tracking branch 'origin/main' into mobility_roundsoff
AlejandroAvilesSerrano May 5, 2025
d272058
fix merge errors
AlejandroAvilesSerrano May 5, 2025
fdbc0d8
refactor soem stuff
AlejandroAvilesSerrano May 6, 2025
952f5c6
refactor private methods
AlejandroAvilesSerrano May 6, 2025
97bc699
refactor pluging loader
AlejandroAvilesSerrano May 6, 2025
a0a4740
refactor ring topology np
AlejandroAvilesSerrano May 7, 2025
584e94a
feature sa frontend
FerTV May 8, 2025
fe90ea6
fix ring error
AlejandroAvilesSerrano May 8, 2025
5a2ea7a
fix random topology cs
AlejandroAvilesSerrano May 8, 2025
0ffb541
refactor intro message
AlejandroAvilesSerrano May 9, 2025
4039420
feature sar components dinamically loaded
AlejandroAvilesSerrano May 9, 2025
02b4e74
fix ring error
AlejandroAvilesSerrano May 9, 2025
84787be
fix not simultaneos ring extra participants
AlejandroAvilesSerrano May 10, 2025
eaac70c
pre integration
AlejandroAvilesSerrano May 12, 2025
0a3f70a
sa commentaries
AlejandroAvilesSerrano May 12, 2025
31646ca
optimization ring error
AlejandroAvilesSerrano May 12, 2025
8ad41ff
fix strict ring topology
AlejandroAvilesSerrano May 12, 2025
3f0ac2c
feature undirect connections inactivity
AlejandroAvilesSerrano May 12, 2025
8dd5ba5
feature connetion priority
AlejandroAvilesSerrano May 13, 2025
acee4a1
daily update
AlejandroAvilesSerrano May 16, 2025
2d1e9dc
Merge remote-tracking branch 'origin/feature/db-optimization' into co…
FerTV May 19, 2025
8adbdb0
controller and frontend splitted
FerTV May 19, 2025
fc1e68e
upgrade collaborative rep
AlejandroAvilesSerrano May 19, 2025
8db63d6
refactor controller folder created
FerTV May 19, 2025
a1da1ce
upgrade collaborative
AlejandroAvilesSerrano May 19, 2025
0467be5
feature distance neighbor policy
AlejandroAvilesSerrano May 20, 2025
e8dc915
node endpoints created in the controller
FerTV May 20, 2025
18d32c9
fix distance errors
AlejandroAvilesSerrano May 20, 2025
f8f7c92
fix await erros
AlejandroAvilesSerrano May 20, 2025
80d9807
feature distance candidate selector
AlejandroAvilesSerrano May 20, 2025
a7b962b
fix mobility longitude
AlejandroAvilesSerrano May 20, 2025
266b12d
default mobility
FerTV May 20, 2025
c32ddda
fix mob
AlejandroAvilesSerrano May 20, 2025
4987b56
Merge branch 'mobility_integration_v3' into simple-mobility
AlejandroAvilesSerrano May 20, 2025
0f72fa7
additional merge changes
AlejandroAvilesSerrano May 20, 2025
1927b27
remove bad dir
AlejandroAvilesSerrano May 20, 2025
f3c3323
added docstrings for the frontend
FerTV May 20, 2025
986688f
fix same owner commands conflict
AlejandroAvilesSerrano May 20, 2025
660cc69
improve node dynamism
enriquetomasmb May 20, 2025
c54dff8
Merge branch 'simple-mobility' of https://github.com/CyberDataLab/neb…
enriquetomasmb May 20, 2025
66c9da7
fix filtered discovers
AlejandroAvilesSerrano May 20, 2025
ef67f54
feature ttl for corfimations
AlejandroAvilesSerrano May 21, 2025
7f5091c
fix rep messages
AlejandroAvilesSerrano May 21, 2025
d32573b
fix rep setup
AlejandroAvilesSerrano May 21, 2025
32a4a20
rep proto
AlejandroAvilesSerrano May 21, 2025
6fb66ca
remove unused files
AlejandroAvilesSerrano May 21, 2025
83c28d8
add/remove comments
AlejandroAvilesSerrano May 21, 2025
5a81356
added docstrings for the controller
FerTV May 21, 2025
15f1159
update message definition
enriquetomasmb May 21, 2025
e8e08d6
update format, style and comments
enriquetomasmb May 21, 2025
31d7fe2
remove situational awareness from participant.json.example
FerTV May 21, 2025
207d53e
Merge remote-tracking branch 'origin/controller_frontend_split' into …
FerTV May 21, 2025
d670ea2
fix dynamism on node distance
enriquetomasmb May 21, 2025
a7609e5
fix strict_topology
FerTV May 21, 2025
f5316d2
fix delay error
AlejandroAvilesSerrano May 21, 2025
582882a
fix flooding
AlejandroAvilesSerrano May 21, 2025
e722740
fix processes deployment
FerTV May 21, 2025
e559429
fix delayer attack
FerTV May 21, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions nebula/addons/attacks/communications/communicationattack.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import logging
import random
import random
import types
from abc import abstractmethod

from nebula.addons.attacks.attacks import Attack
from nebula.core.network.communications import CommunicationsManager


class CommunicationAttack(Attack):
def __init__(
self,
engine,
target_class,
target_method,
round_start_attack,
round_stop_attack,
attack_interval,
decorator_args=None,
selectivity_percentage: int = 100,
selection_interval: int = None,
):
def __init__(
self,
engine,
Expand Down Expand Up @@ -46,21 +60,23 @@ async def select_targets(self):
if self.selection_interval:
if self.last_selection_round % self.selection_interval == 0:
logging.info("Recalculating targets...")
all_nodes = await self.engine.cm.get_addrs_current_connections(only_direct=True)
all_nodes = await CommunicationsManager.get_instance().get_addrs_current_connections(only_direct=True)
num_targets = max(1, int(len(all_nodes) * (self.selectivity_percentage / 100)))
self.targets = set(random.sample(list(all_nodes), num_targets))
elif not self.targets:
logging.info("Calculating targets...")
all_nodes = await self.engine.cm.get_addrs_current_connections(only_direct=True)
all_nodes = await CommunicationsManager.get_instance().get_addrs_current_connections(only_direct=True)
num_targets = max(1, int(len(all_nodes) * (self.selectivity_percentage / 100)))
self.targets = set(random.sample(list(all_nodes), num_targets))
else:
logging.info("All neighbors selected as targets")
self.targets = await self.engine.cm.get_addrs_current_connections(only_direct=True)
self.targets = CommunicationsManager.get_instance().get_addrs_current_connections(only_direct=True)

logging.info(f"Selected {self.selectivity_percentage}% targets from neighbors: {self.targets}")
self.last_selection_round += 1

self.last_selection_round += 1

async def _inject_malicious_behaviour(self):
"""Inject malicious behavior into the target method."""
decorated_method = self.decorator(self.decorator_args)(self.original_method)
Expand Down
3 changes: 2 additions & 1 deletion nebula/addons/attacks/communications/delayerattack.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from functools import wraps

from nebula.addons.attacks.communications.communicationattack import CommunicationAttack
from nebula.core.network.communications import CommunicationsManager


class DelayerAttack(CommunicationAttack):
Expand Down Expand Up @@ -32,7 +33,7 @@ def __init__(self, engine, attack_params: dict):

super().__init__(
engine,
engine._cm,
CommunicationsManager.get_instance(),
"send_model",
round_start,
round_stop,
Expand Down
7 changes: 3 additions & 4 deletions nebula/addons/attacks/communications/floodingattack.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import asyncio
import logging
from functools import wraps
import time

from nebula.addons.attacks.communications.communicationattack import CommunicationAttack
from nebula.core.network.communications import CommunicationsManager


class FloodingAttack(CommunicationAttack):
Expand Down Expand Up @@ -35,8 +34,8 @@ def __init__(self, engine, attack_params: dict):

super().__init__(
engine,
engine._cm,
"send_model",
CommunicationsManager.get_instance(),
"send_message",
round_start,
round_stop,
attack_interval,
Expand Down
43 changes: 22 additions & 21 deletions nebula/addons/mobility.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@
import math
import random
import time
from typing import TYPE_CHECKING

from nebula.addons.functions import print_msg_box
from functools import cached_property
from nebula.core.network.communications import CommunicationsManager
from nebula.core.eventmanager import EventManager
from nebula.core.nebulaevents import GPSEvent
from nebula.core.nebulaevents import GPSEvent, ChangeLocationEvent
from nebula.core.utils.locker import Locker

if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager
from nebula.addons.functions import print_msg_box


class Mobility:
def __init__(self, config, cm: "CommunicationsManager", verbose=False):
def __init__(self, config, verbose=False):
"""
Initializes the mobility module with specified configuration and communication manager.

Expand Down Expand Up @@ -52,7 +49,6 @@
"""
logging.info("Starting mobility module...")
self.config = config
self.cm = cm
self.grace_time = self.config.participant["mobility_args"]["grace_time_mobility"]
self.period = self.config.participant["mobility_args"]["change_geo_interval"]
self.mobility = self.config.participant["mobility_args"]["mobility"]
Expand All @@ -61,9 +57,9 @@
self.scheme_mobility = self.config.participant["mobility_args"]["scheme_mobility"]
self.round_frequency = int(self.config.participant["mobility_args"]["round_frequency"])
# Protocol to change connections based on distance
self.max_distance_with_direct_connections = 300 # meters
self.max_movement_random_strategy = 100 # meters
self.max_movement_nearest_strategy = 100 # meters
self.max_distance_with_direct_connections = 150 # meters
self.max_movement_random_strategy = 50 # meters
self.max_movement_nearest_strategy = 50 # meters
self.max_initiate_approximation = self.max_distance_with_direct_connections * 1.2
# Logging box with mobility information
mobility_msg = f"Mobility: {self.mobility}\nMobility type: {self.mobility_type}\nRadius federation: {self.radius_federation}\nScheme mobility: {self.scheme_mobility}\nEach {self.round_frequency} rounds"
Expand All @@ -72,6 +68,10 @@
self._nodes_distances_lock = Locker("nodes_distances_lock", async_lock=True)
self._verbose = verbose

@cached_property
def cm(self):
return CommunicationsManager.get_instance()

@property
def round(self):
"""
Expand Down Expand Up @@ -101,10 +101,11 @@
`run_mobility` operation.
"""
await EventManager.get_instance().subscribe_addonevent(GPSEvent, self.update_nodes_distances)
await EventManager.get_instance().subscribe_addonevent(GPSEvent, self.update_nodes_distances)
task = asyncio.create_task(self.run_mobility())
return task

async def update_nodes_distances(self, gpsevent: GPSEvent):
async def update_nodes_distances(self, gpsevent : GPSEvent):
distances = await gpsevent.get_event_data()
async with self._nodes_distances_lock:
self._nodes_distances = dict(distances)
Expand Down Expand Up @@ -135,7 +136,7 @@
"""
if not self.mobility:
return
# await asyncio.sleep(self.grace_time)
#await asyncio.sleep(self.grace_time)
while True:
await self.change_geo_location()
await asyncio.sleep(self.period)
Expand All @@ -161,8 +162,7 @@
- The calculated radius is converted from meters to degrees based on an approximate
conversion factor (1 degree is approximately 111 kilometers).
"""
if self._verbose:
logging.info("📍 Changing geo location randomly")
if self._verbose: logging.info("📍 Changing geo location randomly")
# radius_in_degrees = self.radius_federation / 111000
max_radius_in_degrees = self.max_movement_random_strategy / 111000
radius = random.uniform(0, max_radius_in_degrees) # noqa: S311
Expand Down Expand Up @@ -198,7 +198,7 @@
coordinates to determine the direction of movement.
- The conversion from meters to degrees is based on approximate geographical conversion factors.
"""
logging.info("📍 Changing geo location towards the nearest neighbor")
if self._verbose: logging.info("📍 Changing geo location towards the nearest neighbor")
scale_factor = min(1, self.max_movement_nearest_strategy / distance)
# Calcular el ángulo hacia el vecino
angle = math.atan2(neighbor_longitude - longitude, neighbor_latitude - latitude)
Expand Down Expand Up @@ -243,8 +243,9 @@

self.config.participant["mobility_args"]["latitude"] = latitude
self.config.participant["mobility_args"]["longitude"] = longitude
if self._verbose:
logging.info(f"📍 New geo location: {latitude}, {longitude}")
if self._verbose: logging.info(f"📍 New geo location: {latitude}, {longitude}")
Comment thread Fixed
cle = ChangeLocationEvent(latitude, longitude)
asyncio.create_task(EventManager.get_instance().publish_addonevent(cle))

async def change_geo_location(self):
"""
Expand Down Expand Up @@ -281,11 +282,11 @@

selected_neighbor = result[0] if result else None
if selected_neighbor:
# logging.info(f"📍 Selected neighbor: {selected_neighbor}")
#logging.info(f"📍 Selected neighbor: {selected_neighbor}")
addr, dist, (lat, long) = selected_neighbor
if dist > self.max_initiate_approximation:
# If the distance is too big, we move towards the neighbor
logging.info(f"Moving towards nearest neighbor: {addr}")
if self._verbose: logging.info(f"Moving towards nearest neighbor: {addr}")
await self.change_geo_location_nearest_neighbor_strategy(
dist,
latitude,
Expand Down
32 changes: 18 additions & 14 deletions nebula/addons/networksimulation/nebulanetworksimulator.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import asyncio
import logging
import subprocess
from typing import TYPE_CHECKING
from functools import cached_property

from nebula.addons.networksimulation.networksimulator import NetworkSimulator
from nebula.core.eventmanager import EventManager
from nebula.core.nebulaevents import GPSEvent
from nebula.core.network.communications import CommunicationsManager
from nebula.core.utils.locker import Locker

if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager


class NebulaNS(NetworkSimulator):
NETWORK_CONDITIONS = {
Expand All @@ -21,8 +19,7 @@ class NebulaNS(NetworkSimulator):
}
IP_MULTICAST = "239.255.255.250"

def __init__(self, communication_manager: "CommunicationsManager", changing_interval, interface, verbose=False):
self._cm = communication_manager
def __init__(self, changing_interval, interface, verbose=False):
self._refresh_interval = changing_interval
self._node_interface = interface
self._verbose = verbose
Expand All @@ -31,9 +28,16 @@ def __init__(self, communication_manager: "CommunicationsManager", changing_inte
self._current_network_conditions = {}
self._running = False

@cached_property
def cm(self):
return CommunicationsManager.get_instance()

async def start(self):
logging.info("🌐 Nebula Network Simulator starting...")
self._running = True
grace_time = self.cm.config.participant["mobility_args"]["grace_time_mobility"]
# if self._verbose: logging.info(f"Waiting {grace_time}s to start applying network conditions based on distances between devices")
# await asyncio.sleep(grace_time)
await EventManager.get_instance().subscribe_addonevent(
GPSEvent, self._change_network_conditions_based_on_distances
)
Expand Down Expand Up @@ -213,7 +217,7 @@ def extract_number(value):

match = re.match(r"([\d.]+)", value)
if not match:
raise ValueError(f"Invalid format: {value}")
raise ValueError(f"Formato inválido: {value}")
return float(match.group(1))

if self._verbose:
Expand All @@ -224,11 +228,11 @@ def extract_number(value):

thresholds = sorted(th.keys())

# If the distance is less than the first threshold, return the best condition
# Si la distancia es menor que el primer umbral, devolver la mejor condición
if distance < thresholds[0]:
conditions = {"bandwidth": th[thresholds[0]]["bandwidth"], "delay": th[thresholds[0]]["delay"]}

# Find the section in which the distance is located.
# Encontrar el tramo en el que se encuentra la distancia
for i in range(len(thresholds) - 1):
lower_bound = thresholds[i]
upper_bound = thresholds[i + 1]
Expand All @@ -241,7 +245,7 @@ def extract_number(value):
lower_cond = th[lower_bound]
upper_cond = th[upper_bound]

# Extract numerical values and units
# Extraer valores numéricos y unidades
lower_bandwidth_value = extract_number(lower_cond["bandwidth"])
upper_bandwidth_value = extract_number(upper_cond["bandwidth"])
lower_bandwidth_unit = lower_cond["bandwidth"].replace(str(lower_bandwidth_value), "")
Expand All @@ -251,22 +255,22 @@ def extract_number(value):
upper_delay_value = extract_number(upper_cond["delay"])
delay_unit = lower_cond["delay"].replace(str(lower_delay_value), "")

# Calculate progress in the leg (0 to 1)
# Calcular el progreso en el tramo (0 a 1)
progress = (distance - lower_bound) / (upper_bound - lower_bound)
if self._verbose:
logging.info(f"Progress between the bounds: {progress}")

# Linear interpolation of values
# Interpolación lineal de valores
bandwidth_value = lower_bandwidth_value - progress * (lower_bandwidth_value - upper_bandwidth_value)
delay_value = lower_delay_value + progress * (upper_delay_value - lower_delay_value)

# Reconstruct values with original units
# Reconstruir valores con unidades originales
bandwidth = f"{round(bandwidth_value, 2)}{lower_bandwidth_unit}"
delay = f"{round(delay_value, 2)}{delay_unit}"

conditions = {"bandwidth": bandwidth, "delay": delay}

# If the distance is infinite, return the last value
# Si la distancia es infinita, devolver el último valor
if not conditions:
conditions = {"bandwidth": th[float("inf")]["bandwidth"], "delay": th[float("inf")]["delay"]}
if self._verbose:
Expand Down
6 changes: 2 additions & 4 deletions nebula/addons/networksimulation/networksimulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class NetworkSimulatorException(Exception):
pass


def factory_network_simulator(
net_sim, communication_manager, changing_interval, interface, verbose
) -> NetworkSimulator:
def factory_network_simulator(net_sim, changing_interval, interface, verbose) -> NetworkSimulator:
from nebula.addons.networksimulation.nebulanetworksimulator import NebulaNS

SIMULATION_SERVICES = {
Expand All @@ -39,6 +37,6 @@ def factory_network_simulator(
net_serv = SIMULATION_SERVICES.get(net_sim, NebulaNS)

if net_serv:
return net_serv(communication_manager, changing_interval, interface, verbose)
return net_serv(changing_interval, interface, verbose)
else:
raise NetworkSimulatorException(f"Network Simulator {net_sim} not found")
16 changes: 13 additions & 3 deletions nebula/addons/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import psutil

if TYPE_CHECKING:
from nebula.core.network.communications import CommunicationsManager
pass


class Reporter:
def __init__(self, config, trainer, cm: "CommunicationsManager"):
def __init__(self, config, trainer):
"""
Initializes the reporter module for sending periodic updates to a dashboard controller.

Expand Down Expand Up @@ -48,9 +48,9 @@ def __init__(self, config, trainer, cm: "CommunicationsManager"):
- Initializes both current and accumulated metrics for traffic monitoring.
"""
logging.info("Starting reporter module")
self._cm = None
self.config = config
self.trainer = trainer
self.cm = cm
self.frequency = self.config.participant["reporter_args"]["report_frequency"]
self.grace_time = self.config.participant["reporter_args"]["grace_time_reporter"]
self.data_queue = asyncio.Queue()
Expand All @@ -68,6 +68,16 @@ def __init__(self, config, trainer, cm: "CommunicationsManager"):
self.acc_packets_sent = 0
self.acc_packets_recv = 0

@property
def cm(self):
if not self._cm:
from nebula.core.network.communications import CommunicationsManager

self._cm = CommunicationsManager.get_instance()
return self._cm
else:
return self._cm

async def enqueue_data(self, name, value):
"""
Asynchronously enqueues data for reporting.
Expand Down
Loading
Loading