Example #1
0
def main():
    send = sender()
    send.set_key("ahanushppassword")
    #set_key must be 16
    send.encode("DHanush")
    send.create_keys()
    rec = receiver()
    rec.load_key("D://Programs/AES/ahanushppassword.csv")
    rec.decode()
def goodsDetail(session,):
    """
    进入商详
    :param session:
    :return:
    """
    receiver(session)
    getGoodsDetailUrls = copy.copy(urls["getGoodsDetail"])
    getGoodsDetailUrls["req_url"] = getGoodsDetailUrls["req_url"].format(session.pid)
    t = threading.Thread(target=getVcode, args=(session,))  # 验证码线程
    t.setDaemon(True)
    t.start()
    t2 = threading.Thread(target=searchOrderInfo, args=(session,))  # 查询订单线程
    t2.setDaemon(True)
    t2.start()

    goodsDetailRsp = session.httpClint.send(getGoodsDetailUrls)

    data = goodsDetailRsp.get("data", {})
    session.sku = data["product"]["bn"]
    product_id = data["product"]["product_id"]
    goodsProducts(session, product_id)
Example #3
0
transmitSignal_X1, transmitSignal_X2 = transmitter(digitalInput_X1,
                                                   digitalInput_X2, inputSize)

#Output after impulse convolution
#hValue = random.randn(2,2)
hValue = array([[0.4, 0.9], [0.5, 0.8]])
convolved_X1, convolved_X2 = multiplethreading(transmitSignal_X1,
                                               transmitSignal_X2, hValue)

# Output after noise addition
noisedSignal_X1, noisedSignal_X2 = NoiseChannel(convolved_X1, convolved_X2,
                                                inputSize, snrArray, snrSize)

# Signal received at receiver and demodulated
receivedSignal_X1, receivedSignal_X2 = receiver(noisedSignal_X1,
                                                noisedSignal_X2,
                                                len(noisedSignal_X1),
                                                len(noisedSignal_X2), hValue)

t = []
for i in xrange(len(receivedSignal_X1) / inputSize):
    t.append(receivedSignal_X1[i * inputSize:((i + 1) * inputSize)])
receivedSignal_X1 = t

t1 = []
for i in xrange(len(receivedSignal_X2) / inputSize):
    t1.append(receivedSignal_X2[i * inputSize:((i + 1) * inputSize)])
receivedSignal_X2 = t1

#print '\n', receivedSignal_X1, '\n', receivedSignal_X2
#print '\n', digitalInput_X1, '\n', digitalInput_X2
# Error per SNR calculations
for i in range(inputSize):
	digitalInput_X2.append(randint(0,1))

# Output of Transmitter
transmitSignal_X1, transmitSignal_X2 = transmitter(digitalInput_X1, digitalInput_X2, inputSize)

#Output after impulse convolution
#hValue = random.randn(2,2)
hValue = array([[0.4,0.9],[0.5,0.8]])
convolved_X1, convolved_X2 = multiplethreading(transmitSignal_X1, transmitSignal_X2, hValue)

# Output after noise addition
noisedSignal_X1, noisedSignal_X2 = NoiseChannel(convolved_X1, convolved_X2, inputSize, snrArray, snrSize)

# Signal received at receiver and demodulated
receivedSignal_X1, receivedSignal_X2 = receiver(noisedSignal_X1, noisedSignal_X2, len(noisedSignal_X1), len(noisedSignal_X2), hValue)

t = []
for i in xrange(len(receivedSignal_X1)/inputSize):
	t.append(receivedSignal_X1[i*inputSize:((i+1)*inputSize)])
receivedSignal_X1 = t

t1 = []
for i in xrange(len(receivedSignal_X2)/inputSize):
	t1.append(receivedSignal_X2[i*inputSize:((i+1)*inputSize)])
receivedSignal_X2 = t1

#print '\n', receivedSignal_X1, '\n', receivedSignal_X2
#print '\n', digitalInput_X1, '\n', digitalInput_X2
# Error per SNR calculations
digitalInput = []
for i in range(inputSize):
	digitalInput.append(randint(0,1))

# Output of Transmitter
transmitSignal = transmitter(digitalInput, inputSize)

#Output after impulse convolution
convolved = h(transmitSignal, hValue)

# Output after noise addition
noisedSignal = NoiseChannel(convolved, inputSize, 				snrArray, snrSize)
#print noisedSignal

# Signal received at receiver and demodulated
receivedSignal = receiver(noisedSignal, len(noisedSignal),hValue)
#print receivedSignal, len(receivedSignal)
#print digitalInput
# Error per SNR calculations
err = []
for i in range(len(noisedSignal)):
    l = [0]*inputSize
    for j in range(len(digitalInput)):
    	l[j] = abs(receivedSignal[i][j] - digitalInput[j])
    err.append(sum(l))

# Error per bit calculations
for i in range(len(err)):
	err[i] /= float(inputSize)
#print err
# Theoritical bit error rate calculation