Пример #1
0
def prepare_receiver(chans=[0x0f, 0x14, 0x19]):
    ccs = map(CC2531, get_CC2531())
    #
    if len(ccs) == 0:
        LOG(' no CC2531 dongles found')
        return []
    #
    # split the chans' list into separate lists for all receivers
    e, r = len(chans)//len(ccs), len(chans)%len(ccs)
    cl = []
    start, stop = 0, 0
    for i in range(len(ccs)):
        if stop > 0:
            start = stop
        if i < r:
            stop = start + e + 1
        else:
            stop = start + e
        cl.append(chans[start:stop])
    #
    ss = [receiver(cc) for cc in ccs]
    for i in range(len(cl)):
        # configure channels' list of each CC2531 receiver
        ss[i].CHAN_LIST = cl[i]
    #
    return ss
Пример #2
0
    def initSimulator(self, maxMsgs, loss, corrupt, delay, seed, trace):
        self.maxMessages = maxMsgs

        self.lossProb = loss
        self.corruptProb = corrupt

        self.avgMessageDelay = delay

        self.rand = random.seed(seed)
        # instantiate Random number generator with provided seed

        self.nMsgSim = 0
        # initialise number of simulated messages to 0
        self.time = 0.0
        # initialise simulation time to 0

        self.trace = trace

        self.eventList = EventList(
        )  # instantiate event list (initially empty)

        self.sender = sender(
            A, self)  # initialise sender entity (the respective class)

        self.receiver = receiver(
            B, self)  # initialise receiver entity (the respective class)
Пример #3
0
def test_receiver(x=0):
    cc = CC2531(get_CC2531()[x])
    receiver.DEBUG = 1
    receiver.SOCK_ADDR = ('localhost', 2154)
    receiver.CHAN_LIST = [0x0f, 0x14, 0x19]
    receiver.CHAN_PERIOD = 10
    serv = create_udp_serv(receiver.SOCK_ADDR)
    s = receiver(cc)
    s.listen()
Пример #4
0
def receive(hostAddr, dstAddr, filePath):
    receiver(hostAddr, dstAddr, filePath, 'server').createReceiver()
Пример #5
0
from receiver import *
from machine import Pin

s = Pin(15, Pin.OUT)
s.on()

if s.value() == 1:
    receiver()
else:
    pass
    #download
Пример #6
0
# -*- coding:utf-8 -*-

import sys
from sender import *
from receiver import *

# data : 'LFTP lget myserver mylargefile'
# data : 'LFTP lsend myserver mylargefile'

if __name__ == "__main__":
    # 客户端向服务端发送数据
    hostPort = int(input('input client port: '))  # 指定客户端的端口
    dstAddr = (sys.argv[3], 21567)

    if sys.argv[2] == 'lget':
        receiver(('', hostPort), dstAddr, sys.argv[4],
                 'client').createReceiver()
    elif sys.argv[2] == 'lsend':
        sender(('', hostPort), dstAddr, sys.argv[4], 'client').createSender()
Пример #7
0
	def __init__(self):
		self.queue_enable = True
		s=socket.socket()
		s.connect(('127.0.0.1',10000))
		self.sender = sender(s)
		self.receiver = receiver(s)
Пример #8
0
 def __init__(self):
     self.queue_enable = True
     s = socket.socket()
     s.connect(('127.0.0.1', 10000))
     self.sender = sender(s)
     self.receiver = receiver(s)
Пример #9
0
        self.portnumber = DEFAULT_PORT  # server port number (well-known port number)
        self.filename = ''  # name of written file
        self.p = 0  # packet loss probability

        if (len(sys.argv) != 4):  # incorrect number of input arguments
            sys.exit(
                "\nERROR: Please provide 3 arguments: p2mpserver <server port #> <filename> <packet loss probability>\n"
            )

        else:  # correct number of input arguments
            self.portnumber = sys.argv[1]
            self.filename = sys.argv[2]
            self.p = float(sys.argv[3])
            if (self.p < 0 or self.p > 1):
                sys.exit('\nERROR: packet loss probability must be [0,1]\n')


# instantiate p2mpserver
server = P2MPServer()
print('\n#############################################\n')
print('\nHostname: ' + str(server.hostname))
print('\nIP address: ' + str(gethostbyname(server.hostname)))
print('\nPort number: ' + str(server.portnumber))
print('\nFilename: ' + str(server.filename))
print('\nPacket Loss Probability: ' + str(server.p))
print('\n#############################################\n')
#sys.exit('\nSTOP\n')

# Create UDP Socket
rcv = receiver(server.hostname, server.portnumber, server.filename, server.p)
rcv.listen()