Revision c0eac366 lib/experiment.py

View differences:

lib/experiment.py
30 30
		#print "hostname for addr "+addr+": "+str(hostname)
31 31
		return hostname
32 32

  
33
	def getPeer(self,hostname):
34
		for session in self.sessions:
35
				peer = session.getPeer(hostname)
36
				if peer:
37
						return peer
38
		return None
39

  
33 40
class Session:
34 41
	def __init__(self,time):
35 42
		self.time=int(time)
......
66 73
		self.hostname = hostname
67 74
		self.is_source = source
68 75
		self.published = dataframe
76
		self.neighbours = None
69 77
		received = dataframe[dataframe['action'] == 'RECEIVED']
70 78
		sent = dataframe[dataframe['action'] == 'SENT']
71 79
		if len(received) > 0:
72
			self.address = ''.join(received['receiver'][0])
80
			i = received.first_valid_index()
81
			self.address = ''.join(received['receiver'][i])
73 82
		else:
74 83
			if len(sent) > 0:
75
				self.address = ''.join(sent['sender'][0])
84
				i = sent.first_valid_index()
85
				self.address = ''.join(sent['sender'][i])
76 86
			else:
77 87
				self.address = 'unkwnon'
78 88

  
89
	def setNeighbours(self,neighs):
90
		self.neighbours = neighs
91

  
79 92
	def published_interval(self,begin_time,end_time):
80 93
		return self.published[(self.published['logTime'] > begin_time) & \
81 94
				      						 (self.published['logTime'] < end_time)]
......
84 97
		return self.published[(self.published['logTime'] > (begin_time*1000000)) & \
85 98
				      						 (self.published['logTime'] < (end_time*1000000))]
86 99

  
100
	def neighbours_interval_sec(self,begin_time,end_time):
101
		return self.neighbours[(self.neighbours['logTime'] > (begin_time*1000000)) & \
102
			(self.neighbours['logTime'] < (end_time*1000000))]

Also available in: Unified diff