2. Initial Assignments: Input blocks A and B are
aggregated with subkeys S[0] and S[1], respectively:
A=A+S[0],B=B+S[1]A = A + S[0], \quad B = B + S[1]A
= A + S[0], \quad B = B + S[1] (1)
3. Loop Operations: In each iteration (i=1 to r),
blocks A and B are updated using XOR, left shift
(<<<), and subkey addition operations:
A=((A⊕B)≪B)+S[2i],B=((B⊕A)≪A)+S[2i+1]A = ((A
\oplus B) \ll B) + S[2i], \quad B = ((B \oplus A) \ll A) +
S[2i+1]A = ((A \oplus B) \ll B) + S[2i], \quad B = ((B
\oplus A) \ll A) + S[2i+1] (2)
The decryption process reverses these steps to
produce the original text. The encrypt.m function,
developed in the Matlab R2023a simulation
environment, encrypted a random plaintext (e.g.,
Plaintext: 90411A9F, F4E98004) to produce
Ciphertext (097A726A, 34022CB7); the decrypt.m
function correctly decrypted the ciphertext. These
operations verify the reliability and accuracy of the
algorithm.
RC5's encryption performance is enhanced by the
Offset Codebook Mode (OCB) operation mode.
OCB, an authenticated encryption mode developed
by Phil Rogaway, combines encryption and message
authentication into a single process. This ensures both
confidentiality and integrity with low computational
cost. The operation of the OCB mode is shown in
Figure 2. This section must be in one column.
M1
E
K
⊕
C1
⊕
Δ
Δ
M2
E
K
⊕
C2
⊕
Δ
Δ
M3
E
K
⊕
C3
⊕
Δ
Δ
Checksum
E
K
⊕
T
⊕
Auth
Δ
Final
Tag
Figure 2: OCB operation mode.
The process involves the following components:
• Nonce (N): A 96-bit random value provides a
unique starting point for each encryption operation.
• Message Blocks (M): The plaintext is processed
by dividing it into 128-bit blocks.
• Checksum: The XOR sum of the message blocks
(Checksum = M1 ⊕ … ⊕ Mm) is used to verify data
integrity.
• Tag Length (τ): A parameter in the range 0 ≤ τ ≤
128 determines the verification tag of the ciphertext.
Encryption in OCB mode was performed with the
RC5 algorithm, and the ciphertext (CT = C1 C2 …
Cm T) was generated as a string of 128m + τ bits.
Simulation results showed that OCB provides high
security with low overhead. For example, the
plaintext ECB044E4 F78D173B was encrypted and
correctly decrypted as 57385970 286D1213.
2.2 Wireless Sensor Network
Simulation Environment
The WSN simulation was developed in the MATLAB
R2023a environment to model smart grids' data
collection and transmission processes. The simulation
is based on a scenario where 100 sensors are
randomly distributed over a 100x100 m² area. The
sensors are organized into clusters, with a cluster head
selected for every 10 sensors. The cluster heads
transmit the data collected from the sensors to the
base station (location: bs_x=50, bs_y=200). The basic
parameters of the simulation environment are as
follows:
• Number of Sensors (n): 100
• Cluster Size (a): 10
• Initial Energy (Eo): 1 Joule
• Transmission Parameters:
o Electronic energy (Eelec): 50 nJ/bit
o Amplification energy (Eamp): 100 pJ/bit/m²
o Data acquisition energy (EDA): 5 nJ/bit
Data transmission was performed securely using
the RC5 encryption algorithm. For example, for
transmitting a 1024-bit data packet, the average
energy consumption was measured as 0.11 Joules, the
transmission time was 0.01 bit/s, and the encryption
time was 0.25 seconds. These results demonstrate that
the system meets the requirements for energy
efficiency and low latency. The simulation provided
a model close to real-world scenarios thanks to the
random positioning of the sensors and the cluster-
based organization.
2.3 Intrusion Detection and Prevention
System
WSNs in smart grids must be protected against
various cyber threats. This study uses a parameter-
based system to detect and prevent Hello Flood,
Sinkhole, Blackhole, and Sybil attacks. The system
consists of a detection unit that monitors network
performance and a defense unit that neutralizes
threats.