From eb645db50e1b296e7126e7ffc0824b1dac17549c Mon Sep 17 00:00:00 2001
From: "Ion-Dorinel FILIP (25005)" <dorinel.filip@upb.ro>
Date: Tue, 11 Mar 2025 13:58:33 +0000
Subject: [PATCH] Fixed how we check that we do not flip the very same bit for
 corrupt2

---
 common/link_emulator/link.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/common/link_emulator/link.c b/common/link_emulator/link.c
index a714173..80d2417 100644
--- a/common/link_emulator/link.c
+++ b/common/link_emulator/link.c
@@ -306,10 +306,10 @@ void *run_forwarding(void *param)
 
 				if (rand() % 100 < corrupt2) {
 					// flip a second bit in the same byte
-					int random_bit2;
-					do {
-						random_bit2 = rand();
-					} while (random_bit2 == random_bit);
+					int random_bit2 = rand();
+					if(random_bit % 8 == random_bit2 % 8) {
+						random_bit2 += 1;
+					}
 					m->payload[random_byte] ^=
 						1 << (random_bit2 % 8);
 				}
-- 
GitLab