File tree 2 files changed +15
-3
lines changed
examples/basic/A00_simple_as
2 files changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -29,7 +29,9 @@ def run(dumpfile = None):
29
29
30
30
# Initialize the emulator and layers
31
31
emu = Emulator ()
32
- base = Base ()
32
+ # set global defaults..
33
+ base = Base (bandwidth = OptionRegistry ().net_bandwidth (10000000 ),# 10 Mbit/s on all links
34
+ mtu = OptionRegistry ().net_mtu (9000 )) # use JumboFrames
33
35
routing = Routing ()
34
36
ebgp = Ebgp ()
35
37
web = WebService ()
@@ -43,7 +45,7 @@ def run(dumpfile = None):
43
45
44
46
# Create an autonomous system
45
47
as150 = base .createAutonomousSystem (150 )
46
- as150 .setOption (OptionRegistry ().net_mtu (9000 ))
48
+ as150 .setOption (OptionRegistry ().net_mtu (1500 ))
47
49
48
50
# Create a network
49
51
as150 .createNetwork ('net0' )
Original file line number Diff line number Diff line change @@ -60,14 +60,24 @@ def getNetOptions(self):
60
60
return [OptionRegistry ().getOption (o ) for o in opt_keys ]
61
61
62
62
63
- def __init__ (self ):
63
+ def __init__ (self , ** kwargs ):
64
64
"""!
65
65
@brief Base layer constructor.
66
66
"""
67
67
super ().__init__ ()
68
68
self .__ases = {}
69
69
self .__ixes = {}
70
70
self .__name_servers = []
71
+ from seedemu .core import OptionRegistry
72
+ for k ,v in kwargs .items ():
73
+ # Replace the 'defaults' class methods dynamically
74
+
75
+ opt_cls = type (v )
76
+ # Capture 'new_value' as default argument (forces a snapshot of the current value)
77
+ opt_cls .default = classmethod (lambda cls , new_value = v .value : new_value )
78
+ opt_cls .defaultMode = classmethod (lambda cls , newmode = v .mode : newmode )
79
+ prefix = getattr (opt_cls , '__prefix' ) if hasattr (opt_cls , '__prefix' ) else None
80
+ OptionRegistry ().register (opt_cls , prefix )
71
81
72
82
def getName (self ) -> str :
73
83
return "Base"
You can’t perform that action at this time.
0 commit comments