Example #1
0
 def test_PrepMsg(self):
     msg1 = np.array([34, 20, 5, 42, 26, 9, 3, 5, 60, 6, 24, 22])
     msg2 = np.array([34, 16, 49, 31, 2, 9, 16, 22, 41, 38, 24, 22])
     expectedresult1 = np.array(
         [39, 19, 16, 44, 29, 13, 58, 19, 13, 14, 20, 44, 17, 20, 25, 31, 46, 2, 29, 35, 56, 17, 11, 20, 39,
          51, 7, 30, 26, 11, 17, 27, 21, 11, 30, 34, 46, 48, 15, 53, 14, 26, 12, 7, 5, 8, 42, 41, 37, 19,
          16, 35, 63, 20, 3, 12, 38, 26, 8, 37, 22, 23, 29])
     expectedresult2 = np.array(
         [1, 22, 21, 42, 33, 8, 40, 58, 13, 54, 19, 19, 58, 6, 5, 10, 29, 24, 34, 1, 53, 33, 30, 43, 17,
          51, 29, 38, 52, 58, 55, 9, 49, 50, 24, 61, 0, 52, 51, 20, 25, 58, 15, 41, 53, 48, 6, 57, 10, 25,
          11, 30, 16, 20, 47, 6, 0, 43, 6, 18, 38, 3, 29])
     result1 = jt.prepmsg(msg1)
     result2 = jt.prepmsg(msg2)
     self.assertEqual(len(result1), len(expectedresult1))
     self.assertEqual(len(result2), len(expectedresult2))
     self.assertEqual(result1.tolist(), expectedresult1.tolist())
     self.assertEqual(result2.tolist(), expectedresult2.tolist())
Example #2
0
def jt65encodemessages(jt65msgs, verbose=False):
# Encode valid text into array of JT65 data
    jt65data = []

    for index, value in enumerate(jt65msgs):
        legitjt = jt.encode(value)
        legitpacket = jt.prepmsg(legitjt)

        if verbose:
            print "JT65 legit message " + str(index) + " : " + value
            print "Encoded as : " + str(legitjt)
            print "Legit channel symbols with RS :" + str(legitpacket)

        jt65data.append(legitpacket)

    return jt65data
Example #3
0
def getgoodconfidence(packets, verbose=False):
# takes in a list of packets
# returns a list of all the confidence values for correct symbols
    confidences = []
    for packet in packets:
        symbols = packet[0]
        confidence = packet[1]

        symboltrydecode = copy.deepcopy(symbols)
        testdecode = jt65wrapy.unprepmsg(symboltrydecode)
        realmessage = jt65wrapy.prepmsg(testdecode)
        symbolmap = map(eq, realmessage, symbols)

        for i in range(0, 63):
            if symbolmap[i]:
                confidences.append(confidence[i])

    return confidences
Example #4
0
def getgoodconfidence(packets, verbose=False):
    # takes in a list of packets
    # returns a list of all the confidence values for correct symbols
    confidences = []
    for packet in packets:
        symbols = packet[0]
        confidence = packet[1]

        symboltrydecode = copy.deepcopy(symbols)
        testdecode = jt65wrapy.unprepmsg(symboltrydecode)
        realmessage = jt65wrapy.prepmsg(testdecode)
        symbolmap = map(eq, realmessage, symbols)

        for i in range(0, 63):
            if symbolmap[i]:
                confidences.append(confidence[i])

    return confidences
Example #5
0
def validatesteg(jt65msg, rxsymbols, hidekey, errordetectionthreshold, verbose=False):
# Determines if a given set of symbols contain steganography or are a
# normal JT65 message

    errorcount = 0

    # Determine what the symbols would be if there were no errors
    truesymbols = jt.prepmsg(jt.encode(jt65msg))

    # Determine how many symbols where steg should be hidden contain errors
    for i in hidekey:
        if rxsymbols[i] != truesymbols[i]:
            errorcount += 1

    if errorcount >= errordetectionthreshold:
        return True

    return False
Example #6
0
def checkpacket(packet, verbose=False):
# packet is a two dimensional array of symbols and confidence
# returns diffs list of [diff position, packet symbol, clean encode symbol, confidence]
# if verbose prints <number of diffs>,<average confidence of diffs> to stdout
    symbols = packet[0]
    confidence = packet[1]

    symboltrydecode = copy.deepcopy(symbols)
    testdecode = jt65wrapy.unprepmsg(symboltrydecode)
    realmessage = jt65wrapy.prepmsg(testdecode)
    symbolmap = map(eq, realmessage, symbols)

    diffs = []
    for i in range(0, 63):
        if not symbolmap[i]:
            diffs.append([i, symbols[i], realmessage[i], confidence[i]])

    if verbose:
        print diffs
        print realmessage
        print symbols

    return diffs
Example #7
0
def checkpacket(packet, verbose=False):
    # packet is a two dimensional array of symbols and confidence
    # returns diffs list of [diff position, packet symbol, clean encode symbol, confidence]
    # if verbose prints <number of diffs>,<average confidence of diffs> to stdout
    symbols = packet[0]
    confidence = packet[1]

    symboltrydecode = copy.deepcopy(symbols)
    testdecode = jt65wrapy.unprepmsg(symboltrydecode)
    realmessage = jt65wrapy.prepmsg(testdecode)
    symbolmap = map(eq, realmessage, symbols)

    diffs = []
    for i in range(0, 63):
        if not symbolmap[i]:
            diffs.append([i, symbols[i], realmessage[i], confidence[i]])

    if verbose:
        print diffs
        print realmessage
        print symbols

    return diffs