def tcp_echo_client(): socket = Sock(N, N.net[1]) s1 = socket.socket(AF_INET, SOCK_STREAM) ip = ip_to_str(0) print "t:", xtime.time(), "waiting" xtime.swait(70) print "t:", xtime.time(), "connecting to " + ip s1.connect((ip, 51423)) r = randint(0, 256) s1.send('Hallo, ' + str(r)) s1.send('How are you?') message = s1.recv(8192) print "t:", xtime.time(), "tcp server replied:", message
def tcp_echo_client(): socket=Sock(N, N.net[1]) s1=socket.socket(AF_INET, SOCK_STREAM) ip = ip_to_str(0) print "t:", xtime.time(), "waiting" xtime.swait(70) print "t:", xtime.time(), "connecting to "+ip s1.connect((ip, 51423)) r=randint(0, 256) s1.send('Hallo, '+str(r)) s1.send('How are you?') message = s1.recv(8192) print "t:", xtime.time(), "tcp server replied:", message
def run_sim(): # Fill the options to pass to the nodes. s = Settings() s.SIMULATED = True s.IP_VERSION = 4 s.NICS = [] s.EXCLUDE_NICS = [] # Add the node N.net[0], and N.net[1] to the simulation. They are the # nodes loaded by N.net_file_load(). micro(NtkNode(N, N.net[0], Sock, xtime, s).run) # Wait 10 time units before adding N.net[1] xtime.swait(10) micro(NtkNode(N, N.net[1], Sock, xtime, s).run)