Demo entry 6641044

run.py

   

Submitted by Tim Lumb on Sep 15, 2017 at 04:46
Language: Python 3. Code size: 918 Bytes.

import os

"""
    Run file for executing the sender, receiver and channel programs.
"""

# terminal commands
CMD = "%s & %s & %s"
READ_FILE = "Pet_UML.pdf"
WRITE_FILE = "Pet_UML_copy.pdf"
SENDER = "python3 sender.py %s %s %s %s"
RECEIVER = "python3 receiver.py %s %s %s %s"
CHANNEL = "python3 channel.py %s %s %s %s %s %s %s --seed %s"
SEED = -1       # random seed value
P = 0.0         # probability of packet loss

# ports used:
s_in, s_out = [2001, 2002]                              # sender ports
r_in, r_out = [3001, 3002]                              # receiver ports
c_sin, c_sout, c_rin, c_rout = [6000, 6001, 6002, 6003] # channel ports

if __name__ == '__main__':

    sender = SENDER % (s_in, s_out, c_sin, READ_FILE)
    receiver = RECEIVER % (r_in, r_out, c_rin, WRITE_FILE)
    channel = CHANNEL % (c_sin, c_sout, c_rin, c_rout, s_in, r_in, P, SEED)
    os.system(CMD % (sender, receiver, channel))

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).