forked from trailofbits/publications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsender.py
51 lines (43 loc) · 1.64 KB
/
sender.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'''
TRANSMITTER
sophia.re
07/06/15
'''
from time import time,sleep
import os
# takes a binary string as input
def send (Message, roundLength):
for x in Message:
# Run a single busy loop to represent a 0
if( x == '0'):
print('sending', x)
# change the time of this busy loop to match receiver round length
start_time = time()
end_time = time() + roundLength #this number is loop time in seconds
while( start_time < end_time):
start_time = time() #do nothing
else:
# send a 'hi' bit in a given time frame
# by reducing the received out of order executions
# this is done using the sender exe
print('sending', x)
start_time = time()
end_time = time() + roundLength
while( start_time < end_time):
os.system("C:\\CPUSender.exe")
# do nothing until sending c process terminates
start_time = time()
def main():
# measured receiver time frame length in seconds - (for one bit)
roundLength = 1.08
message = ''
# enter binary string
while( message != 'exit'):
message = raw_input('Enter Binary String: ')
start_t = time()
if( message != 'exit'):
send(message,roundLength)
print "\nTotal execution time: "
print time() - start_t
if __name__ == "__main__":
main()