#does not maintain data about the rest of the network myLink = {str(myID): []} #Maybe, need function here to setup particular host as the #broadcast node or not #create hello packet pkttype = 0x01 src = myID #print("src is : ".format(src)) seq = 0x01 hello = struct.pack('BBB', pkttype, seq, src) #hello = hostFunctions.createHelloPacket() #Sends hello on its broadcast IP address data, addr, myLink = hostFunctions.sendHelloPacket(commonFunctions.convertID(myID), hello, '192.168.1.255', myLink, myID) hostFunctions.broadcastLinkState(myID, '192.168.1.255', myLink) while True: """ #**** for testing, remove before flights ****** #create hello packet pkttype = 0x08 src = myID #print("src is : ".format(src)) seq = 0x01 hello = struct.pack('BBB', pkttype, seq, src) my_socket = socket(AF_INET, SOCK_DGRAM) my_socket.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
import sys sys.path.append('../') import idMap import hostFunctions import time import struct if __name__ == "__main__": #read the hosts's ID from the command line input -id myID = hostFunctions.getID(sys.argv) myID = int(myID) #Maybe, need function here to setup particular host as the #broadcast node or not #create hello packet pkttype = 0x01 src = myID seq = 0x01 hello = struct.pack('BBB', pkttype, seq, src) #hello = hostFunctions.createHelloPacket() #Sends hello on its broadcast IP address data, addr = hostFunctions.sendHelloPacket(idMap.code_to_IP(myID), hello, '192.168.1.255') while True: data = hostFunctions.receive_packet('0.0.0.0', 8888)