Skip to content

Instantly share code, notes, and snippets.

@jbn
Created April 30, 2020 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbn/a717c18ecd3cfabad8e8330224d44d79 to your computer and use it in GitHub Desktop.
Save jbn/a717c18ecd3cfabad8e8330224d44d79 to your computer and use it in GitHub Desktop.
import numpy as np
n, syn, ack = 240, "SYN", "ACK"
k = n//4
idx = sorted(zip(np.random.randint(0, n, k), np.random.choice([syn, ack], k)))
corruption = []
for i in range(n):
while idx and idx[0][0] <= i:
corruption.append(list(idx.pop(0)[1]))
new_buf = []
for msg in corruption[:]:|
print(msg.pop(0), end="")
if msg:
new_buf.append(msg)
else:
print("|", end="")
corruption = new_buf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment