def __init__(self, N, B=1, verbose=True, dest=False):  #is pieces 1 here?
        self.verbose = verbose
        self.prevtime = time.time()
        self.N = N
        #self.A = make_A_matrix(self.N)
        self.counter = 0
        self.num_transmissions = 0
        self.current_row = 0

        ## Set up link to tos mote
        self.mif = MoteIF.MoteIF()
        self.source = self.mif.addSource("sf@localhost:9002")
        #TxSerialMsg.py is be generated by MIG class
        self.mif.addListener(self, TxSerialMsg)

        # generate random messages
        self.W = np.random.randint(
            0, 2**16, (N, B))  # each message is an array of B uint16s

        # store final received messages. goal is to "de-NaN" by the end
        self.final_messages = np.nan * np.zeros((N, B))
        # keep track of all transmitted and received messages/symbols
        self.tx_symbols = np.array([])  # [1 -by- # of transmissions]

        # keep track of number of transmissions
        self.TOTAL_TRANSMISSIONS = 0
        # for TDMA round also?
        self.TDMA_TRANSMISSIONS = 0

        # antidote matrix A
        self.A = np.diag(self.W.reshape(
            -1))  # receiver (row) i has access to the message it plans to send
        # Receiver i wants message dest[i]
        # e.g. dest = [1, 0] means R0 wants W[1] and R1 wants W[0]
        if dest == False:
            self.dest = pairingperm(N)
            if self.verbose:
                print 'Message destinations chosen by pairing'
                print 'dest:', self.dest
        else:
            self.dest = dest
        mat_dest = (np.arange(self.N), np.array(self.dest))
        signal_space = np.zeros((self.N, self.N)) > 0
        signal_space[mat_dest] = True
        self.I = compute_interferers(self.A, signal_space)
        self.J = self.I.astype(float)
        self.J[mat_dest] = -1
        self.map = np.arange(self.N)

        if self.verbose:
            print 'Interferer matrix is:'
            print self.J
Ejemplo n.º 2
0
    def reset(self):
        self.it += 1
        #reinitialize for next experiment
        # generate random messages
        self.W = np.random.randint(
            0, 2**16,
            (self.N, self.B))  # each message is an array of B uint16s
        #print 'W is :'
        #print self.W
        # store final received messages. goal is to "de-NaN" by the end
        #self.final_messages = np.nan*np.zeros((N, B))
        #not actually messages but indicator if all the pieces for the node have been received
        self.final_messages = np.nan * np.zeros((self.N, 1))
        # keep track of all transmitted and received messages/symbols
        self.tx_symbols = np.array([])  # [1 -by- # of transmissions]

        # keep track of number of transmissions
        self.TOTAL_TRANSMISSIONS = 0
        self.TDMA_TRANSMISSIONS = 0
        #make float so dont have to cast later
        self.TDMA_ERASURES = float(0)
        self.INDEX_ERASURES = float(0)
        self.TDMA_ERASURES_VEC = np.zeros((1, self.N), float)
        self.INDEX_ERASURES_VEC = np.zeros((1, self.N), float)
        self.epsIndex = float(0)
        self.epsVec = np.zeros((1, self.N), float)

        mat_dest = (np.arange(self.N), np.array(self.dest))
        signal_space = np.zeros((self.N, self.N)) > 0
        signal_space[mat_dest] = True
        self.A = np.eye(self.N)
        self.I = compute_interferers(self.A, signal_space)
        self.J = self.I.astype(float)
        self.J[mat_dest] = -1
        self.map = np.arange(self.N)
        #print 'size of I is ', np.size(self.I)
        #only print once??
        if self.verbose:
            print 'Interferer matrix is:'
            print self.J

        #return to tdma mode
        self.TDMA_MODE = 1
        #self.tm = 0; #needed?
        self.TDleft = np.arange(self.N, dtype=np.uint8)
        self.ackList = np.nan * self.TDleft
        self.ileft = 0
        #transmit the first message
        Transmitter.tdma_stage(self)
        self.ileft = 1
	def __init__(self, N, B=1, verbose=True, dest=False): #is pieces 1 here?
		self.verbose = verbose
		self.prevtime = time.time()
		self.N = N
		#self.A = make_A_matrix(self.N)
		self.counter = 0;
		self.num_transmissions = 0;
		self.current_row = 0;

		## Set up link to tos mote
		self.mif = MoteIF.MoteIF()
		self.source = self.mif.addSource("sf@localhost:9002")
		#TxSerialMsg.py is be generated by MIG class
		self.mif.addListener(self, TxSerialMsg)

		# generate random messages
		self.W = np.random.randint(0,2**16, (N,B)) # each message is an array of B uint16s

		# store final received messages. goal is to "de-NaN" by the end
		self.final_messages = np.nan*np.zeros((N, B))
		# keep track of all transmitted and received messages/symbols
		self.tx_symbols = np.array([]) # [1 -by- # of transmissions]

		# keep track of number of transmissions
		self.TOTAL_TRANSMISSIONS = 0
		# for TDMA round also?
		self.TDMA_TRANSMISSIONS = 0

		# antidote matrix A
		self.A = np.diag(self.W.reshape(-1)) # receiver (row) i has access to the message it plans to send
		# Receiver i wants message dest[i]
		# e.g. dest = [1, 0] means R0 wants W[1] and R1 wants W[0]
		if dest == False:
			self.dest = pairingperm(N)
			if self.verbose:
				print 'Message destinations chosen by pairing'
				print 'dest:', self.dest
		else:
			self.dest = dest
		mat_dest = (np.arange(self.N), np.array(self.dest))
		signal_space = np.zeros((self.N,self.N))>0
		signal_space[mat_dest] = True;
		self.I = compute_interferers(self.A, signal_space)
		self.J = self.I.astype(float)
		self.J[mat_dest] = -1
		self.map = np.arange(self.N)
	
		if self.verbose:
			print 'Interferer matrix is:'
			print self.J
Ejemplo n.º 4
0
	def reset(self):
		self.it += 1
		#reinitialize for next experiment
		# generate random messages
		self.W = np.random.randint(0,2**16, (self.N,self.B)) # each message is an array of B uint16s
		#print 'W is :'
		#print self.W
		# store final received messages. goal is to "de-NaN" by the end
		#self.final_messages = np.nan*np.zeros((N, B))
		#not actually messages but indicator if all the pieces for the node have been received
		self.final_messages = np.nan*np.zeros((self.N, 1))
		# keep track of all transmitted and received messages/symbols
		self.tx_symbols = np.array([]) # [1 -by- # of transmissions]
	
		# keep track of number of transmissions
		self.TOTAL_TRANSMISSIONS = 0
		self.TDMA_TRANSMISSIONS = 0
		#make float so dont have to cast later
		self.TDMA_ERASURES = float(0)
		self.INDEX_ERASURES = float(0)
		self.TDMA_ERASURES_VEC = np.zeros((1,self.N),float)
		self.INDEX_ERASURES_VEC = np.zeros((1,self.N),float)
		self.epsIndex = float(0)
		self.epsVec = np.zeros((1,self.N),float)
		
		mat_dest = (np.arange(self.N), np.array(self.dest))
		signal_space = np.zeros((self.N,self.N))>0
		signal_space[mat_dest] = True;
		self.A = np.eye(self.N)
		self.I = compute_interferers(self.A, signal_space)
		self.J = self.I.astype(float)
		self.J[mat_dest] = -1
		self.map = np.arange(self.N)
		#print 'size of I is ', np.size(self.I)
		#only print once??	
		if self.verbose:
			print 'Interferer matrix is:'
			print self.J

		#return to tdma mode
		self.TDMA_MODE = 1;
		#self.tm = 0; #needed?
		self.TDleft = np.arange(self.N, dtype=np.uint8)
		self.ackList = np.nan*self.TDleft
		self.ileft = 0; 
		#transmit the first message
		Transmitter.tdma_stage(self)
		self.ileft = 1
Ejemplo n.º 5
0
	def __init__(self, N, B=1, verbose=True, dest=False): #is pieces 1 here?
		self.verbose = verbose
		self.prevtime = time.time()
		self.N = N
		#self.A = make_A_matrix(self.N)
		self.counter = 0;
		self.num_transmissions = 0;
		self.current_row = 0;

		## Set up link to tos mote
		self.mif = MoteIF.MoteIF()
		self.source = self.mif.addSource("sf@localhost:9002")
		#TxSerialMsg.py is be generated by MIG class
		self.mif.addListener(self, TxSerialMsg)

		# generate random messages
		self.W = np.random.randint(0,2**16, (N,B)) # each message is an array of B uint16s
		#print 'W is :'
		#print self.W
		# store final received messages. goal is to "de-NaN" by the end
		self.final_messages = np.nan*np.zeros((N, B))
		#not actually messages but indicator if all the pieces for the node have been received
		self.final_messages = np.nan*np.zeros((N, 1))
		# keep track of all transmitted and received messages/symbols
		self.tx_symbols = np.array([]) # [1 -by- # of transmissions]

		# keep track of number of transmissions
		self.TOTAL_TRANSMISSIONS = 0
		# for TDMA round also?
		self.TDMA_TRANSMISSIONS = 0

		# antidote matrix A
		#self.A = np.diag(self.W.reshape(-1)) # receiver (row) i has access to the message it plans to send
		#rewrite so not dependent on W
		self.A = np.eye(N)
		
		# Receiver i wants message dest[i]
		# e.g. dest = [1, 0] means R0 wants W[1] and R1 wants W[0]
		if dest == False:
			self.dest = pairingperm(N)
			if self.verbose:
				print 'Message destinations chosen by pairing'
				print 'dest:', self.dest
		else:
			self.dest = dest
		mat_dest = (np.arange(self.N), np.array(self.dest))
		signal_space = np.zeros((self.N,self.N))>0
		signal_space[mat_dest] = True;
		self.I = compute_interferers(self.A, signal_space)
		self.J = self.I.astype(float)
		self.J[mat_dest] = -1
		self.map = np.arange(self.N)
		print 'size of I is ', np.size(self.I)
	
		if self.verbose:
			print 'Interferer matrix is:'
			print self.J

		#send the first tdma packet?
		self.TDMA_MODE = 1;
		#self.tm = 0; #needed?
		self.TDleft = np.arange(self.N, dtype=np.uint8)
		self.ackList = np.nan*self.TDleft
		#self.ileft = 0; 
		#transmit the first message
		Transmitter.tdma_stage(self)
		self.ileft = 1
	def __init__(self, N, B=1, verbose=True, dest=False): #is pieces 1 here?
		#CHANGE SO THAT ONLY THINGS THAT ARE CALLED ONCE!!
		self.verbose = verbose
		self.prevtime = time.time()
		self.N = N
		#self.A = make_A_matrix(self.N)
		self.counter = 0;
		self.num_transmissions = 0;
		self.current_row = 0;

		## Set up link to tos mote
		self.mif = MoteIF.MoteIF()
		self.source = self.mif.addSource("sf@localhost:9002")
		#TxSerialMsg.py is be generated by MIG class
		self.mif.addListener(self, TxSerialMsg)

		# generate random messages
		self.W = np.random.randint(0,2**16, (N,B)) # each message is an array of B uint16s
		#print 'W is :'
		#print self.W
		# store final received messages. goal is to "de-NaN" by the end
		self.final_messages = np.nan*np.zeros((N, B))
		#not actually messages but indicator if all the pieces for the node have been received
		self.final_messages = np.nan*np.zeros((N, 1))
		# keep track of all transmitted and received messages/symbols
		self.tx_symbols = np.array([]) # [1 -by- # of transmissions]

		# keep track of number of transmissions
		self.TOTAL_TRANSMISSIONS = 0
		# for TDMA round also?
		self.TDMA_TRANSMISSIONS = 0

		# antidote matrix A
		#self.A = np.diag(self.W.reshape(-1)) # receiver (row) i has access to the message it plans to send
		#rewrite so not dependent on W
		self.A = np.eye(N)
		
		# Receiver i wants message dest[i]
		# e.g. dest = [1, 0] means R0 wants W[1] and R1 wants W[0]
		if dest == False:
			self.dest = pairingperm(N)
			if self.verbose:
				print 'Message destinations chosen by pairing'
				print 'dest:', self.dest
		else:
			self.dest = dest
		mat_dest = (np.arange(self.N), np.array(self.dest))
		signal_space = np.zeros((self.N,self.N))>0
		signal_space[mat_dest] = True;
		#rewrite A so not dependent on W
		self.A = np.eye(N)
		self.I = compute_interferers(self.A, signal_space)
		self.J = self.I.astype(float)
		self.J[mat_dest] = -1
		self.map = np.arange(self.N)
		print 'size of I is ', np.size(self.I)
	
		if self.verbose:
			print 'Interferer matrix is:'
			print self.J

		self.TDMA_MODE = 1;
		#self.tm = 0; #needed?
		self.TDleft = np.arange(self.N, dtype=np.uint8)
		self.ackList = np.nan*self.TDleft
		self.ileft = 0; 
		#transmit the first message
		Transmitter.tdma_stage(self)
		self.ileft = 1