Ejemplo n.º 1
0
 print("\nENTER THE SIZE OF EACH DATAWORD:")
 div = int(input())
 print("\n")
 # read the codeword and break it into dataword
 getDword(codeward, div)  #div --> size of each data frame
 # collect the dataword into a list
 L = readMsg()
 # VRC and send codeword
 L = VRCutil(L)
 # write the message to data.txt
 writeMsg(L)
 print(">>Sending........\n")
 print("IF YOU WANT TO INJECT ERRORS PRESS 'y' ELSE PRESS 'n' ")
 eflag = input()
 if eflag == 'y':
     injectError()
 else:
     print("NO ERROR IS INJECTED ")
 print("\nDATA HAS BEEN PASSED TO RECEIVER SIDE SUCCESSFULLY\n")
 print("PRESS r TO ENTER TO RECEIVER SIDE:")
 flag = input()
 print("\nloading.......\n")
 if flag == 'r':
     print("\n--------------RECEIVER----------------")
 else:
     print("THANK YOU,HAPPY CODING :)")
     exit()
 print("RECEIVED MESSAGE IS : ")
 rCodeword = getFullMsg('data.txt')  # received codeword
 print(rCodeword)
 # VRC and check
Ejemplo n.º 2
0
        temp = s.recv(1518)
        temp = unpacker(temp)
        buffer[j] = temp
        time.sleep(1)

    i = n
    counter = 0
    time1 = time.time()
    TIMEOUT = 3
    switch = 0
    while counter < f:
        # send ack for correct data frame and nack for incorrect data frame
        # 0 denotes no error 1 denotes error
        # error = random.randint(0,1)
        # Check CRC
        valid = injectError(buffer[counter % n])
        error = CRCcheck(valid, polynomial)
        # ----> 1 represent error and 0 represent no error <----#
        e = str(error)
        # send the ack

        # random time delay <-------------------------------------->
        a = random.randint(0, 3)
        time.sleep(a)
        print("Time: ", a)
        # <-------------------------------------------------------->
        # if timeout happens nothing is being sent
        if a < 3:
            s.send(e.encode())
        else:
            error = 1
Ejemplo n.º 3
0
print(s_name)
# Sender end Connection
f = s.recv(1518)
f = f.decode()
f = int(f)

while True:
    counter = 0
    message = []
    polynomial = '1011'
    while counter < f:
        # receive the data packet
        temp = s.recv(1518)
        temp = unpacker(temp)
        # Injecting error
        temp = injectError(temp)
        # Data Validation
        error = CRCcheck(temp, polynomial)
        # random time delay
        a = random.randint(0, 4)
        time.sleep(a)
        print("Time Delay Encountered is: ", a)
        # 0 for error and 1 for no error
        e = str(error)
        # if timeout happens nothing is being sent
        if a < 3:
            s.send(e.encode())
        else:
            error = 1
        if a < 3:
            if e != "1":