Ejemplo n.º 1
0
def main():
    print("\nNetworkID and HostID of IPv4 Address:")
    InputIPAddress = input("Enter a valid IPv4 address: \n")
    try:
        NetworkAndHostIDFinder(InputIPAddress)
        print('\n')
    except CE.NoInputError:
        print(CE.NoInputError())
        print("Try again")
        main()
    except CE.InputOutOfRangeError:
        print(CE.InputOutOfRangeError())
        print("Try again")
        main()
    except CE.InputNotANumberError:
        print(CE.InputNotANumberError())
        print("Try again")
        main()
    except CE.InvalidInputError:
        print(CE.InvalidInputError())
        print("Try again")
        main()
    finally:
        print("Main Function executed successfully")
    return 0
Ejemplo n.º 2
0
def main():
    print('\nCyclic Redundancy Check:\n')
    print("Sample input Polynomial:")
    print("x3+x2+1")
    print("x7+x4+x2+x1")
    print("\nCoefficient of all non zero terms of polynomial must be 1")
    print("Constant term must be 1\n")
    InputDividendPolynomial = input(
        "Enter Message Polynomial (Dividend Polynomial):\n").strip()
    InputDivisorPolynomial = input(
        "Enter Check Polynomial (Divisor Polynomial):\n").strip()
    try:
        ValidityChecker(InputDividendPolynomial, InputDivisorPolynomial)
        print('\n')
    except CE.NoInputError:
        print(CE.NoInputError())
        print("Try again")
        main()
    except CE.InputLengthMismatchError:
        print(CE.InputLengthMismatchError())
        print("Try again")
        main()
    except CE.InputNotANumberError:
        print(CE.InputNotANumberError())
        print("Try again")
        main()
    except CE.InvalidInputError:
        print(CE.InvalidInputError())
        print("Try again")
        main()
    finally:
        print("Main Function executed successfully")
    return 0
Ejemplo n.º 3
0
def main():
    print("\nDistance Vector Routing Algorithm")
    NumberOfNodes = input("Enter the number of nodes in the network: \n")
    for char in NumberOfNodes:
        if char not in list("0123456789"):
            raise CE.InputNotANumberError
    NumberOfNodes = int(NumberOfNodes)
    try:
        CostMatrixOfNodes = MinCostMatrixFinder(NumberOfNodes)
        print('\n')
        for startingNode in range(NumberOfNodes):
            for endingNode in range(NumberOfNodes):
                print(
                    f"Min distance between {startingNode + 1} and {endingNode + 1} is {CostMatrixOfNodes[startingNode][endingNode]}")
            print('\n')
        print('\n')
    except CE.NoInputError:
        print(CE.NoInputError())
        print("Try again")
        main()
    except CE.InputLengthMismatchError:
        print(CE.InputLengthMismatchError())
        print("Try again")
        main()
    except CE.InputNotANumberError:
        print(CE.InputNotANumberError())
        print("Try again")
        main()
    except CE.InvalidInputError:
        print(CE.InvalidInputError())
        print("Try again")
        main()
    finally:
        print("Main Function executed successfully")
    return 0
def main():
    print('\nHamming Distance Calculator: \n')
    InputString1 = input("Enter a binary data string: \n")
    InputString2 = input("Enter another binary data string: \n")
    try:
        CalculateHammingDistance(InputString1, InputString2)
        print('\n')
    except CE.InputNotANumberError:
        print(CE.InputNotANumberError())
        print("Try again")
        main()
    except CE.InputLengthMismatchError:
        print(CE.InputLengthMismatchError())
        print("Try again")
        main()
    except CE.InvalidInputError:
        print(CE.InvalidInputError())
        print("Try again")
        main()
    except CE.NoInputError:
        print(CE.NoInputError())
        print("Try again")
        main()
    finally:
        print("Main Function executed successfully")
    return 0
def main():
    print("\nLink State Routing Algorithm: ")
    NumberOfNodes = input("Enter the number of nodes in the network: \n")
    for char in NumberOfNodes:
        if char not in list("0123456789"):
            raise CE.InputNotANumberError
    NumberOfNodes = int(NumberOfNodes)

    StartNode = input(
        f"Enter a Start Node in the range 0 to {NumberOfNodes}: \n")
    for char in StartNode:
        if char not in list("0123456789"):
            raise CE.InputNotANumberError
    StartingNode = int(StartNode)
    if not 0 <= StartingNode < NumberOfNodes:
        print("Invalid Start Node")
        raise CE.InvalidInputError
    try:
        MinCostMatrixFinder(NumberOfNodes, StartingNode)
        print('\n')
    except CE.NoInputError:
        print(CE.NoInputError())
        print("Try again")
        main()
    except CE.InputLengthMismatchError:
        print(CE.InputLengthMismatchError())
        print("Try again")
        main()
    except CE.InputNotANumberError:
        print(CE.InputNotANumberError())
        print("Try again")
        main()
    except CE.InvalidInputError:
        print(CE.InvalidInputError())
        print("Try again")
        main()
    finally:
        print("Main Function executed successfully")
    return 0
Ejemplo n.º 6
0
def main():
    print('\nBit stuffing and destuffing:\n')
    InputString = input("Enter a binary data string:\n")
    try:
        StuffedBitString = BitStuffing(InputString)
        BitDestuffing(StuffedBitString)
        print('\n')
    except CE.InputNotANumberError:
        print(CE.InputNotANumberError())
        print("Try again")
        main()
    except CE.InvalidInputError:
        print(CE.InvalidInputError())
        print("Try again")
        main()
    except CE.NoInputError:
        print(CE.NoInputError())
        print("Try again")
        main()
    finally:
        print("Main Function executed successfully")
    return 0