Skip to content

Commit

Permalink
Corruption will affect any byte in the packet
Browse files Browse the repository at this point in the history
Signed-off-by: Olivier Tilmans <[email protected]>
  • Loading branch information
oliviertilmans committed Nov 24, 2015
1 parent bbb3c4a commit 44a0549
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions link_sim.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,9 @@ static inline int simulate_link(char *buf, int len)
len = 4;
/* or do we corrupt it? */
} else if (err_rate && RAND_PERCENT < err_rate) {
LOG_PKT(buf, "Corrupting packet");
buf[len - 1] = ~buf[len - 1]; /* invert last byte of the CRC */
int idx = rand() % len;
LOG_PKT_FMT(buf, "Corrupting packet: inverted byte #%d\n", idx);
buf[idx] = ~buf[idx];
}
/* Do we want to simulate delay? */
if (delay) {
Expand Down

0 comments on commit 44a0549

Please sign in to comment.