Skip to content

Commit df964a1

Browse files
authored
Merge pull request #6 from zededa/mm/codesys-hde2e
add codesys hde2e demo: Dockerfile, PLC data bundles, configs, hde2e …
2 parents a682aa2 + 233099d commit df964a1

427 files changed

Lines changed: 535241 additions & 19 deletions

File tree

Some content is hidden

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

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@ wheels/
1212

1313
# OS-X files
1414
.DS_Store
15+
16+
# Docker image tarballs
17+
*.tar

DEMO_AND_ANALYSIS.md

Lines changed: 285 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,285 @@
1+
# HDE2E Demo and Analysis Guide
2+
3+
This document describes how to run the High Density End-2-End (HDE2E) demo benchmark and analyze the results.
4+
5+
## Prerequisites
6+
7+
- `uv` package manager installed
8+
- Network proxy configured (if behind corporate firewall)
9+
- Docker installed and running
10+
- `sudo` access for hardware-level operations
11+
12+
## Quick Start
13+
14+
### 1. Run the HDE2E Demo
15+
16+
```bash
17+
# If NOT behind a proxy:
18+
sudo $(which uv) run main.py
19+
20+
# If behind a proxy, set environment variables:
21+
sudo http_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT https_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT $(which uv) run main.py
22+
```
23+
24+
Replace `YOUR_PROXY_HOST` and `YOUR_PROXY_PORT` with your proxy settings (e.g., `proxy.company.com:8080`).
25+
26+
**What this does:**
27+
- Collects system information
28+
- Applies PQOS cache and memory bandwidth optimizations (if enabled)
29+
- Launches CODESYS control and IO PLC instances
30+
- Sets up Docker networking and port forwarding
31+
- Runs the HDE2E latency and jitter benchmark
32+
33+
**Expected output:**
34+
- System info saved to `outputs/YYYY-MM-DD/HH-MM-SS/sysinfo.json`
35+
- Docker containers running:
36+
- `Control_PLC_01` on cores 3,5
37+
- `Control_PLC_02` on cores 7,9
38+
- `IO_PLC_01` and `IO_PLC_02` on remote system (10.34.106.119)
39+
- Port forwarding configured:
40+
- Control web UI: ports 30080, 30081
41+
- IO web UI: ports 30090, 30091
42+
- CODESYS gateway: ports 11741, 11742
43+
44+
### 2. Retrieve Results from IO System
45+
46+
The benchmark generates result files on the remote IO system. Copy them to your local machine:
47+
48+
```bash
49+
# Create results directory
50+
mkdir -p ~/Results_testing
51+
52+
# Copy result files from IO system (10.34.106.119)
53+
# Results are stored in: ~/dockerMount/IO_PLC_01/data/codesyscontrol/PlcLogic/Results/
54+
scp intel@10.34.106.119:~/dockerMount/IO_PLC_01/data/codesyscontrol/PlcLogic/Results/*.csv ~/Results_testing/
55+
```
56+
57+
**Note:** You may need to use the same SSH password from `conf/config.yaml` or set up key-based authentication.
58+
59+
### 3. Analyze Results
60+
61+
```bash
62+
# If NOT behind a proxy:
63+
sudo $(which uv) run hde2e-analyze /path/to/results [options]
64+
65+
# If behind a proxy:
66+
sudo http_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT https_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT $(which uv) run hde2e-analyze /path/to/results [options]
67+
```
68+
69+
**Options:**
70+
- `-v, --verbose` - Print detailed statistics
71+
- `-d, --debug` - Print debug information
72+
- `--save` - Save plots as PNG files
73+
- `--show` - Display plots interactively (use only with single instance for testing)
74+
- `--rows N` - Read only first N rows of input data
75+
- `--version` - Show version
76+
77+
**Example with output:**
78+
```bash
79+
sudo http_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT https_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT $(which uv) run hde2e-analyze /home/intel/Results_testing -v --save
80+
```
81+
82+
**Output files generated:**
83+
- `stat_Latency.csv` - Latency statistics
84+
- `stat_Jitter.csv` - Jitter statistics
85+
- `box_Latency.png` - Box plot for latency
86+
- `box_Jitter.png` - Box plot for jitter
87+
- `bar_Latency.png` - Bar chart for latency statistics
88+
- `bar_Jitter.png` - Bar chart for jitter statistics
89+
- `scatter_*.png` - Scatter plots for each latency component and jitter
90+
91+
## Configuration
92+
93+
### Demo Mode Settings
94+
95+
Edit `conf/config.yaml` to customize the demo:
96+
97+
```yaml
98+
demo:
99+
demo_mode: true # Enable demo mode
100+
t_core: [9,11] # Target cores
101+
io_system:
102+
ip: 10.34.106.119 # Remote IO system IP
103+
nic: enp3s0 # Network interface
104+
ssh_user: intel # SSH username
105+
ssh_password: "..." # SSH password
106+
ssh_port: 22 # SSH port
107+
t_cpus: "1,3" # IO system target CPUs
108+
control_system:
109+
ip: localhost # Control system IP
110+
nic: eno12399np0 # Network interface
111+
t_cpus: "3,5,7,9" # Control CPUs
112+
```
113+
114+
### PQOS Optimizations
115+
116+
PQOS settings are automatically applied when running the demo. Configure them in `conf/config.yaml`:
117+
118+
```yaml
119+
pqos:
120+
interface: "os" # Use Linux resctrl interface
121+
reset_before_apply: true # Reset before applying
122+
123+
classes:
124+
- id: 1
125+
description: "real-time workload"
126+
l3_mask: "0x00ff" # L3 cache mask (8 ways)
127+
l2_mask: "0x00ff" # L2 cache mask (8 ways)
128+
mba: 100 # Memory bandwidth 100%
129+
pids: [] # PIDs (empty for demo)
130+
cores: [] # Cores (empty for demo)
131+
132+
- id: 0
133+
description: "background worker"
134+
l3_mask: "0x7f00" # L3 cache mask (7 ways)
135+
l2_mask: "0xff00" # L2 cache mask (8 ways)
136+
mba: 10 # Memory bandwidth 10%
137+
cores: [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
138+
pids: [115, 118]
139+
```
140+
141+
## Complete Workflow Example
142+
143+
```bash
144+
# Set proxy variables (if behind a proxy)
145+
export http_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT
146+
export https_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT
147+
148+
# 1. Run the demo (takes ~5-10 minutes)
149+
sudo $(which uv) run main.py
150+
151+
# 2. The benchmark completes - result files are generated on IO system
152+
153+
# 3. Copy results from remote IO system to local machine
154+
mkdir -p ~/Results_testing
155+
scp intel@10.34.106.119:~/dockerMount/IO_PLC_01/data/codesyscontrol/PlcLogic/Results/*.csv ~/Results_testing/
156+
157+
# 4. Verify results were copied
158+
ls -lh ~/Results_testing/Codesys-*.csv
159+
160+
# 5. Analyze results with statistics and plots
161+
sudo $(which uv) run hde2e-analyze ~/Results_testing -v --save
162+
163+
# 6. View generated files
164+
ls -lh ~/Results_testing/*.{csv,png}
165+
```
166+
167+
## Cleaning Up
168+
169+
### Stop Running Containers
170+
171+
```bash
172+
sudo docker stop Control_PLC_01 Control_PLC_02
173+
sudo docker rm Control_PLC_01 Control_PLC_02
174+
```
175+
176+
### Kill Port Forwarding
177+
178+
```bash
179+
sudo pkill -f socat
180+
```
181+
182+
### Full Cleanup (if containers are stuck)
183+
184+
```bash
185+
sudo systemctl restart docker
186+
```
187+
188+
## Troubleshooting
189+
190+
### SSH / SCP Issues
191+
192+
**Error: `Permission denied (publickey,password)`**
193+
- Ensure you have the correct SSH password from `conf/config.yaml`
194+
- Try with explicit password prompt:
195+
```bash
196+
scp -P 22 intel@10.34.106.119:/home/intel/dockerMount/IO_PLC_01/data/codesyscontrol/PlcLogic/Results*.csv ~/Results_testing/
197+
```
198+
- If using key-based auth, ensure your public key is on the IO system
199+
200+
**Error: `No such file or directory`**
201+
- Verify the results directory path on the IO system
202+
- Connect to IO system to check: `ssh intel@10.34.106.119 ls -la /home/intel/dockerMount/IO_PLC_01/data/codesyscontrol/PlcLogic/Results`
203+
- Results may be in a different location; check the benchmark output logs
204+
205+
**Slow SCP Transfer**
206+
- Results files can be large (20MB+)
207+
- Use compression: `scp -C intel@10.34.106.119:/path/to/results/*.csv ~/Results_testing/`
208+
209+
### Network Issues
210+
211+
**Error: `Failed to connect to github.com`**
212+
- Ensure proxy is configured: `git config --global http.proxy http://YOUR_PROXY_HOST:YOUR_PROXY_PORT`
213+
- Or set environment variables: `export http_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT`
214+
215+
**Error: `Failed to fetch from pypi.org`**
216+
- Run with proxy environment variables:
217+
```bash
218+
sudo http_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT https_proxy=http://YOUR_PROXY_HOST:YOUR_PROXY_PORT $(which uv) ...
219+
```
220+
- Or configure permanently in git: `git config --global http.proxy http://YOUR_PROXY_HOST:YOUR_PROXY_PORT`
221+
222+
### SSH Authentication
223+
224+
**Error: `Authentication failed` for IO system**
225+
- Check SSH credentials in `conf/config.yaml`
226+
- Verify network connectivity to 10.34.106.119 (IO system IP Address)
227+
- Ensure SSH password is correct
228+
229+
### PQOS Issues
230+
231+
**Error: `pqos tool is not installed`**
232+
- The demo will skip PQOS if not available
233+
- Install with: `sudo apt-get install intel-cmt-cat`
234+
235+
**Error: `ROOT ACCESS REQUIRED`**
236+
- All operations require `sudo` for hardware access
237+
238+
### Docker Issues
239+
240+
**Error: `Container stuck in exited state`**
241+
- Restart Docker: `sudo systemctl restart docker`
242+
- Force remove: `sudo docker rm -f <container_id>`
243+
244+
## Output Format
245+
246+
### Statistics Output
247+
248+
The analysis script produces statistics in multiple formats:
249+
250+
**Console Output (verbose mode):**
251+
```
252+
#### T2-T1 ############################
253+
mean std min max
254+
IO_01 355.4 144.5 195.0 754.0
255+
```
256+
257+
**CSV Files:**
258+
- Statistics at percentiles: 0.9, 0.99, 0.999, 0.9999, 0.99999
259+
- One row per instance
260+
- Columns: mean, std, min, max, and percentiles
261+
262+
### Latency Components
263+
264+
- **T2-T1**: IO to Control transmission time
265+
- **T3-T2**: Control processing time
266+
- **T4-T3**: Control to IO transmission time
267+
- **T4-T1**: Total end-to-end latency
268+
- **Jitter**: PubSub cycle time variation
269+
270+
## Performance Metrics
271+
272+
The HDE2E benchmark measures:
273+
- **Latency**: Time for data to traverse from IO → Control → IO (in microseconds)
274+
- **Jitter**: Variation in PubSub task cycle time (in microseconds)
275+
276+
With PQOS optimizations enabled:
277+
- Real-time workload (Class 1) gets priority cache access
278+
- Background workers (Class 0) are isolated with limited bandwidth
279+
- Results in lower latency and reduced jitter variance
280+
281+
## References
282+
283+
- [CODESYS Documentation](https://help.codesys.com/)
284+
- [Intel CAT/MBA Documentation](https://www.intel.com/content/www/us/en/developer/articles/technical/intel-rdt-cat-mba-linux-rtos-support.html)
285+
- [Docker Documentation](https://docs.docker.com/)
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
###############################################################################
2+
# Copyright CODESYS Development GmbH
3+
###############################################################################
4+
5+
# The referenced base image in this file can be downloaded from the Homepage of OSADL. The base image is a binary-only image for delayed source code delivery.
6+
# https://www.osadl.org/OSADL-Container-Base-Image.osadl-container-base-image.0.html?&no_cache=1&sword_list%5B0%5D=docker
7+
# Add it to your own registry and replace the FROM statement with your URL.
8+
# Alteratively you can directly pull the base image for immediate source code delivery with all sources directly from docker-hub.
9+
# To do that replace the FROM statement with:
10+
FROM osadl/debian-docker-base-image:bookworm-amd64-latest
11+
12+
#FROM repoman.codesys.com:50000/config/standard/osadl-bin/debian/amd64/bookworm:develop
13+
14+
ENV CONTAINER=true
15+
16+
USER root
17+
ENV USER=root
18+
19+
EXPOSE 443
20+
EXPOSE 4840
21+
EXPOSE 8080
22+
EXPOSE 11740
23+
24+
RUN apt-get update && apt-get install -y procps libcap2-bin libpciaccess0 \
25+
intel-cmt-cat python3 python3-pip python3-yaml \
26+
&& apt-get source --download-only libcap2 procps libpciaccess 2>/dev/null \
27+
&& rm -rf /var/lib/apt/lists/*
28+
29+
ARG CODESYSCONTROL_DEB=codesyscontrol_virtuallinux_4.18.0.0*_amd64.deb
30+
ADD ${CODESYSCONTROL_DEB} /tmp/
31+
ADD Docker_copyright_* /
32+
33+
RUN cd /tmp; cd /tmp; dpkg -i ${CODESYSCONTROL_DEB}; rm ${CODESYSCONTROL_DEB};
34+
35+
WORKDIR /var/opt/codesys/
36+
ENTRYPOINT [ "/opt/codesys/scripts/startup.sh" ]
37+
CMD []
15.2 MB
Binary file not shown.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
;virtuallinux
2+
[CmpLog]
3+
Logger.0.Filter=0x0000000F
4+
5+
[ComponentManager]
6+
Component.1=CmpBACnet
7+
Component.2=CmpBACnet2
8+
Component.3=CmpPLCHandler
9+
Component.4=CmpGwClient
10+
Component.5=CmpXMLParser
11+
Component.6=CmpGwClientCommDrvTcp
12+
Component.7=CmpRetain
13+
;Component.8=CmpGwClientCommDrvShm ; enable only if necessary, can result in higher cpu load
14+
;Component.9=SysPci ; enable when using Hilscher CIFX
15+
;Component.10=CmpHilscherCIFX ; enable when using Hilscher CIFX
16+
17+
[CmpApp]
18+
Bootproject.RetainMismatch.Init=1
19+
;RetainType.Applications=InSRAM
20+
Application.1=Control
21+
22+
[CmpRedundancyConnectionIP]
23+
24+
[CmpRedundancy]
25+
26+
[CmpSrv]
27+
28+
[IoDrvEtherCAT]

0 commit comments

Comments
 (0)