> For the complete documentation index, see [llms.txt](https://www.opal-rt.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.opal-rt.com/docs/hypersim/examples/cyber-physical/cyber-physical-simulation-of-a-microgrid-subject-to-cyber-attacks.md).

# Cyber Physical Simulation of a Microgrid Subject to Cyber Attacks

## Description

The **Cyber-Physical Microgrid** example, located in **File > Open an Example File > Cyber-Physical>Cyber\_Physical\_Microgrid.ecf,** demonstrates a cyber-physical co-simulation of a microgrid exposed to cyberattacks. An OPAL-RT real-time simulator runs the microgrid, its distributed energy resources (DERs), power converters, and loads in HYPERSIM<sup>®</sup>, while the underlying communication network is emulated in EXata CPS.

The objective is to evaluate microgrid control behavior under normal and adverse cyber conditions, including islanding, load shedding, voltage support, and the impact of communication-based attacks.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-5c4043783615aa214b8ccea419d0529ade47aacb%2Fimage%20(948).png?alt=media" alt=""><figcaption></figcaption></figure>

## Requirements

Simulator:

* OPAL-RTLinux 64-bit.
* EXata CPS with a license for at least 12 communication nodes.
* License for IEC 61850 GOOSE.

{% hint style="info" %}
If **EXata CPS is not yet installed** or configured, see the section [Cybersecurity with EXATA CPS](https://github.com/Opal-RT-Technologies/product-docs-hypersim/tree/release-2026.4/model-and-simulation/cybersecurity-with-exata-cps.md)
{% endhint %}

Workstation:

* MobaXterm (latest version) or equivalent to connect to the simulator using SSH.

## Detailed explanation

The microgrid is a 25 kV medium-voltage distribution network connected to a 120 kV sub-transmission system through a 15 MVA delta-wye transformer. It includes six DERs: two 1.5 MVA PV systems; three energy storage systems (ESS) (two 500 kVA ESSs with 1.15 MWh capacity each, and one 1 MVA ESS with 5 MWh capacity); and one 10 MVA CHP unit. Four aggregated loads are modeled: two 4 MW critical loads, one 4 MW priority load, and one 5 MW non-critical load. The model does not include protective relays or a protection scheme.

A measurement subsystem generates P, Q, and V<sub>rms</sub> values from voltage and current signals for each asset. A simple rule-based microgrid central controller (MGCC) receives these measurements and, in islanded mode, sends reference setpoints for power balancing, sheds loads, and enables voltage support. The controller does not provide a reconnection function. Users may replace the internal controller with an external one; in that case, update the control devices at the DER inputs accordingly.

Communications between the MGCC and IEDs use IEC 61850 GOOSE for measurements and commands. The exchanged points and GOOSE parameters are listed in the Additional Information tables in this page.

EXata CPS emulates the communication network, enabling realistic delays and attack scenarios against command and measurement traffic, such as packet delay and data manipulation, to assess cyber resilience.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-34111b94a1c70255ade10011333163b74e961630%2Fimage%20(592).png?alt=media" alt=""><figcaption><p>Overview of the microgrid controller schematic as designed in HYPERSIM</p></figcaption></figure>

In addition, a high-fidelity communication network emulator, <mark style="background-color:yellow;">SCALABLE Network’s EXata CPS software,</mark> simulates the underlying communication fabric of electrical grids and can test the cyber resilience of such systems. Using EXata CPS, command, and measurement signals between the controller and microgrid can be subjected to cyberattacks, causing unexpected behavior within the system. The figure below shows a screenshot of the EXata CPS model schematic.

<figure><img src="https://3623212549-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FLxgTpoh7kyPmQ5vuyqD7%2Fuploads%2Fgit-blob-cfa0b2ea7f596b68ee170480c3ff5c197e676d8b%2Fimage%20(593).png?alt=media" alt=""><figcaption><p>The EXata CPS model schematic</p></figcaption></figure>

### Simulation procedure

This cyber-physical setup co-simulates an electrical microgrid and its communication network. HYPERSIM models the power system, DERs, and measurement subsystems. EXata CPS emulates the communication fabric connecting IEDs and the MGCC via IEC 61850 GOOSE. The MGCC applies simple rule-based logic for islanding operation: balancing power via setpoints, shedding loads, and enabling voltage support through ESS Q–v droop; it does not manage reconnection. Users can replace the internal controller with an external controller by adapting the DER input control devices.

{% stepper %}
{% step %}
**HYPERSIM Simulation Workflow**

* Open the HYPERSIM model and specify the simulator in the Simulation Settings.
* In Advanced Target Settings: if the compiler is set to opicc, switch it to opgcc.

  For help : [**Setting GCC compiler as default compiler in HYPERSIM**](https://portal.opal-rt.com/Knowledge-Base/Article?id=19b6144d-9356-ef11-bfe3-002248b1d264)
* Specify the EXata Network Interface : in the I/O interface, open the EXata-CPS Configurator and ensure the EXata Network Interface name matches the simulator’s dedicated interface for EXata.
* To identify simulator network interfaces, connect via SSH (e.g., MobaXterm) and run “ifconfig.” Typical names on OPAL-RTLinux include “eno1” and “eno2.”

  For help: [**Connecting to a Simulator with MobaXterm**](https://portal.opal-rt.com/Knowledge-Base/Article?id=18726aef-8d56-ef11-bfe3-0022483c3bc7)
* Start the HYPERSIM simulation.
* Follow the EXata CPS Simulation Workflow
* Open ScopeView and load the “Cyber\_Physical\_Microgrid.svt” template.
* Expected behavior:
  * EXata CPS IEDs begin communicating after emulation starts.
  * In ScopeView, sent and received signals match for the two scenarios
    {% endstep %}

{% step %}
**EXata CPS Simulation Workflow**

**EXata CPS 1.1**

* Open EXata CPS 1.1 GUI as administrator.
* Open the configuration: *...\Documents\HYPERSIM\Cyber\_Physical\_Microgrid\Cyber\_Physical\_Microgrid\_hyp\EXataCPS\_1\_1\Cyber\_Physical\_Microgrid.config.*
* Establish communication between HYPERSIM and EXata CPS as per the user documentation.
* Click Run Emulation, then click Play (Play button turns blue).

**EXata CPS 8.1.3**

* Open EXata CPS 8.1.3 GUI as administrator.
* Open the configuration: **.***..\Documents\HYPERSIM\Cyber\_Physical\_Microgrid\Cyber\_Physical\_Microgrid\_hyp\EXataCPS\Cyber\_Physical\_Microgrid.config.*
* Ensure the communication interface with HYPERSIM is configured as per the user documentation.
* Click Run Emulation, then click Play (Play button turns blue)
  {% endstep %}
  {% endstepper %}

{% hint style="info" %}

### **Important notes**

Because virtual Ethernet ports are configured (see Communication I/O Configuration), EXata CPS must be running for the microgrid controller to exchange data. To run without EXata CPS and still use IEC 61850, change all virtual Ethernet port values to a non-virtual Ethernet port (for example, eth1). In that case, connect eth1 to an isolated local area network.
{% endhint %}

### Communication I/O Configuration

| \*\* \*\* | **IED**     | **Virtual eth port** | **EXata IP address** | **From the MGC (veth17) to the IEDs** | **From the IEDS to the MGC (veth17)** |
| --------- | ----------- | -------------------- | -------------------- | ------------------------------------- | ------------------------------------- |
| **IED1**  | BESS1       | veth6                | 10.10.1.1            | <p><br></p>                           | 01-0C-CD-01-00-01                     |
| **IED2**  | PV1         | veth7                | 10.10.1.3            | <p><br></p>                           | 01-0C-CD-01-00-02                     |
| **IED3**  | BESS2       | veth8                | 10.10.1.5            | 01-0C-CD-01-00-24                     | 01-0C-CD-01-00-03                     |
| **IED4**  | BESS3       | veth9                | 10.10.1.7            | <p><br></p>                           | 01-0C-CD-01-00-04                     |
| **IED5**  | PV2         | veth10               | 10.10.1.9            | <p><br></p>                           | 01-0C-CD-01-00-05                     |
| **IED6**  | CHP         | veth11               | 10.10.1.11           | 01-0C-CD-01-00-27/2E                  | 01-0C-CD-01-00-06                     |
| **IED7**  | PCC Breaker | veth12               | 10.10.1.13           | <p><br></p>                           | 01-0C-CD-01-00-09                     |
| **IED8**  | Load1       | veth13               | 10.10.1.15           | <p><br></p>                           | 01-0C-CD-01-00-08                     |
| **IED9**  | Load2       | veth14               | 10.10.1.17           | <p><br></p>                           | 01-0C-CD-01-00-19                     |
| **IED10** | Load3       | veth15               | 10.10.1.19           | 01-0C-CD-01-00-2F                     | 01-0C-CD-01-00-1B                     |
| **IED11** | Load4       | veth16               | 10.10.1.21           | 01-0C-CD-01-00-2A                     | 01-0C-CD-01-00-1D/1E                  |
| **IED12** | MGCC        | veth17               | 10.10.1.23           | 01-0C-CD-01-00-2D/24/27/2A/2E/2F      | <p><br></p>                           |

### Communication Points Between Microgrid Controller and IEDs

| **IED**     | **From MGCC to IED** | **From IED to MGCC** |
| ----------- | -------------------- | -------------------- |
| BESS1       | --                   | --                   |
| PV1         | --                   | --                   |
| BESS2       | Pref                 | --                   |
| BESS3       | --                   | --                   |
| PV2         | --                   | --                   |
| CHP         | Pref                 | Mode                 |
| PCC Breaker | --                   | --                   |
| Load 1      | --                   | --                   |
| Load 2      | --                   | --                   |
| Load 3      | Trip                 | --                   |
| Load 4      | Trip                 | --                   |

### V<sub>rms</sub> Measurements

The measurement subsystem computes a true RMS value of phase a voltage using a running average over one cycle of the fundamental frequency. The output is multiplied by √3 to obtain line-to-line V<sub>rms</sub>. For validation, the computed value matches the ScopeView function Window\_RMS\_Value when measured at the microgrid-side PCC during islanding.

## Simulation and results

### Scenario introduction

Use parameter En\_S1\_S2 to select scenarios. This parameter and optional controls ( V\_Support, Inductive\_Fault, Internal\_MGCC) are available in the HYPERSIM schematic.

Default operation is Scenario 0: grid-connected mode with no cyberattacks.

| **Scenario** | **En\_S1\_S2** | **Test Execution – HYPERSIM**              | **Test Execution - EXata CPS**                              | **Description**                             |
| ------------ | -------------- | ------------------------------------------ | ----------------------------------------------------------- | ------------------------------------------- |
| **0**        | 0              | Change the En\_S1\_S2 constant value to 0. | None.                                                       | Microgrid grid-connected mode of operation. |
| **1**        | 1              | Change the En\_S1\_S2 constant value to 1. | Apply a modify packet – delay attack on the MGCC (node 1).  | Delay attack during Islanding.              |
| **2**        | 2              | Change the En\_S1\_S2 constant value to 2. | Apply a modify packet – multiply attack on load2 (node 13). | Multiple attacks in islanded mode.          |

### Scenario 1: Microgrid islanding without delay attack

The microgrid islands at t = 1 s. Immediately after islanding, the MGCC trips load 4 to balance generation and load.

Results without cyberattack:

* Trip commands sent and received are synchronized; EXata CPS adds no significant processing delay while routing the signal.
* Fast shedding allows DERs to contain the frequency deviation; the frequency dips briefly to 58.5 Hz.
* Power balance recovers as DER primary response plus load 4 shedding matches demand; a slight mismatch remains due to distribution losses.
* PCC V<sub>rms</sub> experiences a short dip during islanding until shedding occurs.

A packet delay attack against the shedding command to load 4 is launched in EXata CPS. The attack is preconfigured as Delay\_Attack. The delayed command causes a larger frequency excursion.

#### Triggering the Delay Attack in EXata CPS 1.1

* Right-click node 1 (MGCC) > Attacks > Modify Packets > Delay\_Attack.
* In Attack Editor:
  * Command Type: Attack Command
  * Attack Type: Modify Packets
  * Click Launch.

#### Triggering the Delay Attack in EXata CPS 8.1.3

* Right-click node 1 (MGCC) > Attacks > Modify Packets > New.
* Set parameters:
  * Command Type: Attack Command
  * Attack Type: Modify Packets
  * Layer Type: MAC
  * Destination MAC Address: MAC address of node 1 (RTAC controller)
  * MODP Attack Type: Flow Modification
  * Number of Flow Modifications: 1
  * Flow Modification Type: Delay
  * Random Delay Distribution: Deterministic
  * Click Launch.

#### ScopeView results (scenario 1 with delay attack)

* The received trip command is delayed by 1 s; frequency falls to 57.8 Hz before recovery (vs. 58.6 Hz without attack).
* PCC voltage exhibits a deeper, longer dip (\~23 kV) with increased oscillations. The model has no protection functions, allowing these oscillations.
* DERs cover the imbalance via primary response, but delayed shedding slows frequency recovery; fast shedding remains necessary.

Stop the delay attack before proceeding:

* Open the Attack Editor, set Command Type: Stop Command; Attack Type: Modify Packets; click Launch. EXata CPS confirms in the Output Window.

### Scenario 2: islanded microgrid without data multiply attack

In steady-state islanded operation, the CHP regulates frequency near 60 Hz. PCC voltage is stable at \~24.4 kV. Load 2 measurement packets sent and received by the MGCC align, and load 3 active power remains steady near 4 MW.

A data manipulation attack alters the load 2 demand measurement observed by the MGCC. The MGCC is programmed to trip priority load 3 if generation-load mismatch exceeds 3 MW. The attack is preconfigured as Multiply\_Attack.

#### Triggering the multiply attack in EXata CPS 1.1

* Right-click node 13 (Load 2) > Attacks > Modify Packets > Multiply\_Attack.
* In Attack Editor:
  * Attack Type: Modify Packets; MODP Attack Type: Multiply
  * MAC Address: 01-0C-CD-01-00-19 (Load 2 measurements)
  * Multiply value, number of bytes, and starting byte: multiply bytes 113 and 114 by 2
  * Click Launch.

#### Triggering the multiply attack in EXata CPS 8.1.3

* Right-click node 13 (Load 2) > Attacks > Modify Packets > New.
* Set parameters:
  * Attack Type: Modify Packets; Layer Type: MAC
  * MAC Address: 01-0C-CD-01-00-19 (Load 2 measurements)
  * MODP Attack Type: Data Modification; Number of Data Modifications: 1
  * Data Modification Type: Multiply
  * Multiply Type: Value; Value Type: 16 Bit Unsigned Integer
  * Start byte: 114; Multiply value: 2
  * Click Launch.

### Results

* Load 2 measurements are manipulated before reaching the MGCC.
* MGCC intermittently trips and reconnects load 3, visible in load 3 active power.
* Power quality degrades with increased frequency and voltage oscillations.

After capturing results, stop the attack as in Scenario 1, targeting node 13.

## References

\[1] L. Zang, S. Li, L. Wihl, M. Kazemtabrizi, S. Q. Ali, J.-N. Paquin, and S. Labbé, “Cybersecurity Study of Power System Utilizing Advanced CPS Simulation Tools.”


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://www.opal-rt.com/docs/hypersim/examples/cyber-physical/cyber-physical-simulation-of-a-microgrid-subject-to-cyber-attacks.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
