Example #1
0
    def addTCPPacket(self, data):
        if not data.ack:
            self.tcp_packet_count += 1
        local = config.localIP(data.ip_source)

        # Determine inbound/outbound traffic
        if local:
            if not data.ack:
                self.tcp_out_pkt_count += 1
            if self.tcp_max_out_pkt_size < data.length:
                self.tcp_max_out_pkt_size = data.length
            ip = data.ip_source
        else:
            if not data.ack:
                self.tcp_in_pkt_count += 1
            if self.tcp_max_in_pkt_size < data.length:
                self.tcp_max_in_pkt_size = data.length
            ip = data.ip_dest

            # Add a new client if necessary
        if not self.peer_list.has_key(ip):
            self.peer_list[ip] = PeerManager()
            self.peer_list[ip].initialize(ip)

        self.active_peers.add(ip)
        self.peer_list[ip].addTCPPacket(data)
        self.latest_packet_time = data.time
        return
Example #2
0
	start_time = datetime.datetime.now()
	while len(line) < 1:
		if (datetime.datetime.now() - start_time).seconds > config.INPUT_TIMEOUT_S:
			client.send('Input Timeout ' + str(datetime.datetime.now()))
			sys.exit('Error: Input Timeout ' + str(datetime.datetime.now()))
		line = sys.stdin.readline()
	ret = line_parser.parse(line)
	protocol = ret[0]
	
	# Skip bad lines
	if protocol == '':
		continue

	packet = ret[1]

	# Skip local -> local connections
	# print 'Protocol: ', protocol
	# if re.match(re_local_ip, packet.ip_source) and re.match(re_local_ip, packet.ip_dest):
	if config.localIP(packet.ip_source) and config.localIP(packet.ip_dest):
		continue
	# if (not re.match(re_local_ip, packet.ip_source)) and (not re.match(re_local_ip, packet.ip_dest)):
	if (not config.localIP(packet.ip_source)) and (not config.localIP(packet.ip_dest)):
		continue

	with config.ROUTER_LOCK:
		if protocol == 'tcp':
			router.addTCPPacket(packet)
		elif protocol == 'udp':
			router.addUDPPacket(packet)