Skip to content

Commit ebb194b

Browse files
committed
parent 238ceed
author Afmurillo <[email protected]> 1629479791 +0800 committer Andrés F. Murillo <[email protected]> 1646797824 +0800 Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Testing a first implementation of a stale attack. This is a simple type of attack that stops forwarding traffic when trigger conditions are met Testing a first implementation of a stale attack. This is a simple type of attack that stops forwarding traffic when trigger conditions are met Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Update configuration.rst Minor change to include the optional parameter "direction" in simple_dos_attack and naive_mitm_attack Update attacks.rst Minor update into naive_mitm documentation to include the optional 'direction' parameter Update attacks.rst Added entry for simple_dos attacks into the attacks documentation Fixed issue with attack names. Now if an attack name has more than 10 characters, we will use only the first 10 characters for the attacker node name and its interfaces. Framework for network events is ready. We will proceed to implement the packet loss event now. Testing packet loss event Testing packet loss event Testing packet loss event Update configuration to fix simulator option Simulator option documentation was outdated, pointing to "pdd" or "dd" demand parameter Testing packet loss event Updating installation script to install dependencies for netfilterqueue in Python3 There is a possible dependency issue with WNTR 0.4.0 Testing packet loss event Testing packet loss event Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Updated physical process to only update sqlite DB and report results if a full timestep was completed using epynet Update configuration.rst Minor change to include the optional parameter "direction" in simple_dos_attack and naive_mitm_attack Update attacks.rst Minor update into naive_mitm documentation to include the optional 'direction' parameter Update attacks.rst Added entry for simple_dos attacks into the attacks documentation Fixed issue with attack names. Now if an attack name has more than 10 characters, we will use only the first 10 characters for the attacker node name and its interfaces. Framework for network events is ready. We will proceed to implement the packet loss event now. Testing packet loss event Testing packet loss event Testing packet loss event Update configuration to fix simulator option Simulator option documentation was outdated, pointing to "pdd" or "dd" demand parameter Updating installation script to install dependencies for netfilterqueue in Python3 There is a possible dependency issue with WNTR 0.4.0 Testing packet loss event Condifuration documentation - network events Updated configuration documentation to include network events Fixing documentation Fixing documentation Create events.rst Created the documentation page for network events Adapted KY15 to have different District Metered Areas demand patterns tuned the parameters for DoS attacks on complex water networks Testing Davide's version of skipping intermediate steps. tuned the parameters for DoS attacks on complex water networks tuned the parameters for DoS attacks on complex water networks Testing Davide's version of skipping intermediate steps. Testing Davide's version of skipping intermediate steps. Testing Davide's version of skipping intermediate steps. tuned the parameters for DoS attacks on complex water networks Testing Davide's version of skipping intermediate steps. tuned the parameters for DoS attacks on complex water networks Update install.sh Newer version of matplotlib is potentially causing issues with pyparse, hopefully they'll fix that on their end, doing a workaround in the meantime Temporary (hopefully) fix to pyproject.toml, setuptools 60 broke everything. There are multiple issues with latest version of setuptools Initializing all the RNG with the same seed Testing Davide's version of skipping intermediate steps. Testing Davide's version of skipping intermediate steps. Testing Davide's version of skipping intermediate steps. Testing Davide's version of skipping intermediate steps. Initializing all the RNG with the same seed test to fix outdate data Initializing all the RNG with the same seed Fixed the synchronization between PLCs and physical process. Updated the simulation to register the initial values of the simulation at iteration 0 using epynet. We still need to confirm the values for the junctions pressure and pumps/valves flow. In addition, we need to extend the synchronization mechanism to the network attack scripts and network events Fixed the synchronization between PLCs and physical process. Updated the simulation to register the initial values of the simulation at iteration 0 using epynet. We still need to confirm the values for the junctions pressure and pumps/valves flow. In addition, we need to extend the synchronization mechanism to the network attack scripts and network events Fixed the synchronization between PLCs and physical process. Updated the simulation to register the initial values of the simulation at iteration 0 using epynet. We still need to confirm the values for the junctions pressure and pumps/valves flow. In addition, we need to extend the synchronization mechanism to the network attack scripts and network events Fixed the synchronization between PLCs and physical process. Updated the simulation to register the initial values of the simulation at iteration 0 using epynet. We still need to confirm the values for the junctions pressure and pumps/valves flow. In addition, we need to extend the synchronization mechanism to the network attack scripts and network events Fixed the synchronization between PLCs and physical process. Updated the simulation to register the initial values of the simulation at iteration 0 using epynet. We still need to confirm the values for the junctions pressure and pumps/valves flow. In addition, we need to extend the synchronization mechanism to the network attack scripts and network events Applied the same synchronization scheme to network events Applied the same synchronization scheme to network attacks Applied the same synchronization scheme to network attacks Applied the same synchronization scheme to network attacks Applied the same synchronization scheme to network attacks Applied the same synchronization scheme to network attacks Applied the same synchronization scheme to network attacks Applied the same synchronization scheme to network attacks Minor changes to installation scripts, because setuptools 60.0 is causing installation issues
1 parent 238ceed commit ebb194b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+3036
-264
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Declare files that will always have CRLF line endings on checkout.
2+
*.sln text eol=lf

dhalsim/command_line.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ def run(self):
4646
yaml_paths.append(config_parser.generate_intermediate_yaml())
4747
for yaml_path in yaml_paths:
4848
self.run_simulation(yaml_path)
49+
50+
4951
else:
5052
# Else generate the one we need and run the simulation
5153
intermediate_yaml_path = config_parser.generate_intermediate_yaml()

dhalsim/epynet/epynet/network.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def solve(self, simtime=0):
336336
self.reset()
337337
self.ep.ENsettimeparam(4, simtime)
338338
self.ep.ENopenH()
339-
self.ep.ENinitH(0)
339+
self.ep.ENinitH(11)
340340
self.ep.ENrunH()
341341
self.ep.ENcloseH()
342342
self.solved = True
@@ -347,7 +347,7 @@ def run(self):
347347
self.time = []
348348
# open network
349349
self.ep.ENopenH()
350-
self.ep.ENinitH(0)
350+
self.ep.ENinitH(11)
351351

352352
simtime = 0
353353
timestep = 1

dhalsim/epynet/network.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def init_simulation(self, interactive=False):
129129
self.reset()
130130
self.times = []
131131
self.ep.ENopenH()
132-
self.ep.ENinitH(flag=0)
132+
self.ep.ENinitH(flag=11)
133133

134134
def simulate_step(self, curr_time, actuators_status=None):
135135
"""
@@ -138,18 +138,19 @@ def simulate_step(self, curr_time, actuators_status=None):
138138
:param curr_time: current simulation time
139139
:return: time until the next event, if 0 the simulation is going to end
140140
"""
141+
142+
# update the status of actuators after the first step
143+
# TODO: DHALSIM works with the status update here
144+
if actuators_status and self.interactive:
145+
self.update_actuators_status(actuators_status)
146+
141147
self.ep.ENrunH()
142148
timestep = self.ep.ENnextH()
143149

144150
# append new values to reports
145151
self.times.append(curr_time)
146152
self.load_attributes(curr_time)
147153

148-
# update the status of actuators after the first step
149-
# TODO: DHALSIM works with the status update here
150-
if actuators_status and self.interactive and timestep != 0:
151-
self.update_actuators_status(actuators_status)
152-
153154
return timestep, self.get_network_state()
154155

155156
def update_actuators_status(self, new_status):

dhalsim/init_database.py

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,23 @@ def write(self):
3030
PRIMARY KEY (name, pid)
3131
);""")
3232

33+
34+
# Initialize actuators state in DB
3335
if "actuators" in self.data:
3436
for actuator in self.data["actuators"]:
3537
initial_state = "0" if actuator["initial_state"].lower() == "closed" else "1"
3638
cur.execute("INSERT INTO plant VALUES (?, 1, ?);",
3739
(actuator["name"], initial_state,))
3840

41+
# Initialize sensors in DB, we should read EPANET file
3942
if "plcs" in self.data:
4043
for plc in self.data["plcs"]:
4144
for sensor in plc["sensors"]:
42-
cur.execute("INSERT INTO plant VALUES (?, 1, 0);", (sensor,))
45+
if sensor in self.data["initial_tank_values"]:
46+
# We only initialize tank levels into the SQlite3 DB
47+
cur.execute("INSERT INTO plant VALUES (?, 1, ?);", (sensor,self.data["initial_tank_values"][sensor]))
48+
else:
49+
cur.execute("INSERT INTO plant VALUES (?, 1, 0);", (sensor,))
4350

4451
# Creates master_time table if it does not yet exist
4552
cur.execute("CREATE TABLE master_time (id INTEGER PRIMARY KEY, time INTEGER)")
@@ -56,14 +63,14 @@ def write(self):
5663

5764
if "plcs" in self.data:
5865
for plc in self.data["plcs"]:
59-
cur.execute("INSERT INTO sync (name, flag) VALUES (?, 1);",
66+
cur.execute("INSERT INTO sync (name, flag) VALUES (?, 0);",
6067
(plc["name"],))
6168

62-
cur.execute("INSERT INTO sync (name, flag) VALUES ('scada', 1);")
69+
cur.execute("INSERT INTO sync (name, flag) VALUES ('scada', 0);")
6370

6471
if "network_attacks" in self.data:
6572
for attacker in self.data["network_attacks"]:
66-
cur.execute("INSERT INTO sync (name, flag) VALUES (?, 1);",
73+
cur.execute("INSERT INTO sync (name, flag) VALUES (?, 0);",
6774
(attacker["name"],))
6875

6976
# Creates attack table
@@ -85,6 +92,25 @@ def write(self):
8592
cur.execute("INSERT INTO attack (name, flag) VALUES (?, 0);",
8693
(network_attack["name"],))
8794

95+
# Event DB entries
96+
# network event sync registers
97+
if 'network_events' in self.data:
98+
for event in self.data['network_events']:
99+
cur.execute("INSERT INTO sync (name, flag) VALUES (?, 0);",
100+
(event["name"],))
101+
102+
# Creates event table
103+
cur.execute("""CREATE TABLE event (
104+
name TEXT NOT NULL,
105+
flag INT NOT NULL,
106+
PRIMARY KEY (name)
107+
);""")
108+
109+
if "network_events" in self.data:
110+
for network_event in self.data["network_events"]:
111+
cur.execute("INSERT INTO event (name, flag) VALUES (?, 0);",
112+
(network_event["name"],))
113+
88114
conn.commit()
89115

90116
def drop(self):
@@ -94,6 +120,7 @@ def drop(self):
94120
cur.execute("DROP TABLE IF EXISTS master_time;")
95121
cur.execute("DROP TABLE IF EXISTS sync;")
96122
cur.execute("DROP TABLE IF EXISTS attack;")
123+
cur.execute("DROP TABLE IF EXISTS event;")
97124
conn.commit()
98125

99126
def print(self):
@@ -102,6 +129,7 @@ def print(self):
102129
self.logger.debug(pd.read_sql_query("SELECT * FROM master_time;", conn))
103130
self.logger.debug(pd.read_sql_query("SELECT * FROM sync;", conn))
104131
self.logger.debug(pd.read_sql_query("SELECT * FROM attack;", conn))
132+
self.logger.debug(pd.read_sql_query("SELECT * FROM event;", conn))
105133

106134

107135
def is_valid_file(file_parser, arg):

dhalsim/network_attacks/enip_cip_parser/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)