Exemplo n.º 1
0
    def sequence1(self):
        self.captureForSequence(1)
        if len(self.input_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        self.sendRSET()
        for port in self.input_ports:
            rrpc = RRPC( port)
            if port.port_characteristic == PORT_SAP:
                continue

            for count in range(0, 4):
                message = "Message %d" % count
                message = buildShortMessage(port, message)
                self.send(message, port)
                self.logger.info("Filling the port %s" % port.RX_AFDX_port_id)
                if count == 0 or count == 3:
                    self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
                    self.logger.info("Sending an RRPC")
                if count <= 1:
                    self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
                    self.logger.info("Sending an RRPC")
                elif count == 2:
                    continue
                pollForResponse('RRPC')
Exemplo n.º 2
0
    def run(self):
        self.logger.info("Starting sequence 1")
        if len(self.output_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        self.sendRSET()
        
        for port in self.output_ports:
            eipc = EIPC(port)
            message = "PortId = %s" % port.tx_AFDX_port_id
            offset_size = eipc.command_size
            command = eipc.buildCommand(command = 'HOLD',
                                        message = buildShortMessage(port, 
                                                                message, 
                                                                offset_size))
            self.send(command, Factory.GET_TX_Port())
            if not pollForResponse('EIPC'):
                self.logger.error("The ES has not responded to EIPC")

        tcrq = TCRQ()
        self.send(tcrq.buildCommand(10), Factory.GET_TX_Port())
        if not pollForResponse('TCRQ'):
                self.logger.error("The ES has not responded to TCRQ")
        raw_input("Press any key to continue.")
Exemplo n.º 3
0
    def sequence1(self, capture = True):
        if capture:
            self.captureForSequence(1)
        if len(self.input_ports) == 0:
            self.logger.error("The ICD has no ports satisfying the scripts "\
                              "criteria")
            return
        self.sendRSET()
        port = self.input_ports[0]
        skews = [port.skew_max, port.skew_max + 1000,  port.skew_max - 1000]
        for skew in skews:
            message = buildShortMessage(port, "Skew = %d" % skew)
            sleep_time_micros = float(skew)/1000
            self.logger.info("Sending packet with skew of %d ms" % \
                             sleep_time_micros)
            networks = [NETWORK_A, NETWORK_B]
            if sleep_time_micros < 65.5:
                networks.reverse()

            for network in networks:
                self.network = network
                self.send(message, port)
                time.sleep(float(sleep_time_micros)/1000)

            self.logger.info("Sending an RRPC")
            rrpc = RRPC(port)
            self.network = NETWORK_A
            self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
Exemplo n.º 4
0
    def run(self):
        self.logger.info("Starting sequence 1")
        if len(self.output_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        self.sendRSET()
        for port in self.output_ports:
            if port.port_characteristic == PORT_SAP:
                cmd = ESAP(port)
                setattr(port, "ip_dst", get("TE_IP"))
                setattr(port, "udp_dst", int(get("TE_UDP")))
            else:
                #cmd = EIPC(port)
                cmd = ESAP(port)
            command_size = cmd.command_size
            message = "Short message"
            messages = []
            messages.append(buildShortMessage(port, message, command_size))
            messages.append(buildMessage(port, 
                                     (int(port.buffer_size)/2) - command_size, 
                                     message))
            messages.append(buildMessage(port,
                                        int(port.buffer_size) - command_size,
                                        message))
            for message in messages:
                command = cmd.buildCommand(command = 'SEND', message = message)
                self.send(command, Factory.GET_TX_Port())

                if not pollForResponse(("OK", "ERR")):
                    self.logger.info("The ES did not respond to EIPC command")
Exemplo n.º 5
0
    def sendOnDisconnectedInterface(self, rx_port, tx_port):
        self.sendRSET()
        self.network = NETWORK_AB
        self.logger.info("Checking the transmission port")
        eipc = EIPC(tx_port)
        message = "PortId = %s" % tx_port.tx_AFDX_port_id
        message = buildShortMessage(tx_port, message)      
        self.send(eipc.buildCommand(message = message), Factory.GET_TX_Port())
        pollForResponse('EIPC')

        self.logger.info("Checking the reception port")
        message = "PortId = %s" % rx_port.RX_AFDX_port_id
        message = buildShortMessage(rx_port, message)
        self.send(message, rx_port)
        rrpc = RRPC(rx_port)
        self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
        pollForResponse('RRPC')
Exemplo n.º 6
0
    def doOperation(self, port, snmp_port):
        eipc = EIPC(port)
        message = buildStaticMessage(port.max_frame_size + 1, "Big message")

        self.sendSNMP(snmp_port)
        self.send(eipc.buildCommand(message), Factory.GET_TX_Port())

        self.sendSNMP(snmp_port)

        message = buildShortMessage(port, "Short message", eipc.command_size)
        self.send(eipc.buildCommand(message), Factory.GET_TX_Port())
Exemplo n.º 7
0
 def sequence5(self):
     self.captureForSequence(5)
     self.sendRSET()
     for port in self.input_ports:
         if port.port_characteristic != PORT_SAP:
             continue
         message = buildShortMessage(port, "PortId = %s" % \
                                     port.RX_AFDX_port_id)
         setattr(port, "ip_dst", get("TE_IP"))
         setattr(port, "udp_dst", int(get("TE_UDP")))
         esap = ESAP(port)
         self.send(esap.buildCommand(message = message))
         pollForResponse('ESAP')
Exemplo n.º 8
0
 def sequence3(self):
     self.captureForSequence(3)
     self.sendRSET()
     for port in self.input_ports:
         if port.port_characteristic != PORT_QUEUING:
             continue
         rrpc = RRPC(port)
         self.send(rrpc.buildCommand(), port)
         for count in range(0, 3):
             message = buildShortMessage(port, "Message = %s" % count)
             self.send(message, port)
         for count in range(0, 3):
             self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
             pollForResponse('RRPC')
Exemplo n.º 9
0
 def sequence2(self):
     if len(self.input_port) == 0:
         self.logger.info("There are no ports in the ICD satisfying the " \
                          "scripts criteria")
         return
     self.captureForSequence(2)
     index = 0
     self.network = 'A'
     for port in self.input_port:
         message = buildShortMessage(port, "Background message")
         self.send(message, port)
         if index % 3 == 0:
             for icmp_port in self.icmp_ports:
                 setattr(icmp_port, 'buffer_size', icmp_port.rx_vl_buff_size)
                 message = buildMessage(icmp_port, 64)
                 self.__sendicmp(icmp_port, message, poll = False)
         index += 1
Exemplo n.º 10
0
 def sequence2(self):
     self.captureForSequence(2)
     self.sendRSET()
     for port in self.input_ports:
         if port.port_characteristic != PORT_SAMPLING:
             continue
         self.logger.info("Testing port %s" % port.RX_AFDX_port_id)
         rrpc = RRPC( port)
         message = "PortId = %d" % port.RX_AFDX_port_id
         message = buildShortMessage(port, message)
         self.send(message, port)
         time.sleep(1) 
         self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
         self.logger.info("Sending RRPC command")
         self.logger.info("Sleeping for 10 seconds")
         time.sleep(10)
         self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
Exemplo n.º 11
0
    def sequence1(self):
        if len(self.input_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        self.captureForSequence(1)
        self.sendRSET()
        for port in self.input_ports:
            self.logger.info("Filling rx port : %s" % port.RX_AFDX_port_id)
            for network in [NETWORK_AB, NETWORK_A, NETWORK_B]:
                message = "PortId = %s %s" % (port.RX_AFDX_port_id, network)
                message = buildShortMessage(port, message)
                self.network = network
                self.send(message, port)

                rrpc = RRPC(port)
                self.network = NETWORK_A
                self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
                self.logger.info("Sending an RRPC on network %s" % network)
                pollForResponse('RRPC')
Exemplo n.º 12
0
    def send_modified_snpackets(self, ports, networks):
        if len(ports) == 0:
            self.logger.error("There are no ports in the icd file satisfying" \
                              " this criteria. Hence quitting the sequence")
            return
        self.sendRSET()
        for port in ports:
            for network in networks:
                message = "PortId = %s %s" % (port.RX_AFDX_port_id, network)
                message = buildShortMessage(port, message)

                outport = Factory.WRITE(port.RX_AFDX_port_id, message)
                setattr(outport, 'sn_func', self.sn_modifier)
                self.application.transmitter.transmit(outport, network)
                self.logger.info("Filling rx port : %s" % port.RX_AFDX_port_id)
                rrpc = RRPC(port)
                self.network = NETWORK_A
                self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
                self.logger.info("Sending an RRPC on network %s" % self.network)
                pollForResponse('RRPC')
Exemplo n.º 13
0
    def run(self):
        if len(self.output_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        self.sendRSET()
        for port in self.output_ports:
            eipc = EIPC(port)
            self.logger.info("Sending EIPC HOLD on %s" % \
                             port.tx_AFDX_port_id)
            self.send(eipc.buildCommand(command = 'HOLD',\
                                        message = buildShortMessage(port,
                                                    "RM test",
                                                    eipc.command_size)), 
                                        Factory.GET_TX_Port())
            pollForResponse("EIPC")

        tcrq = TCRQ()
        self.logger.info("Seding a TCRQ for %d times" % 2)
        self.send(tcrq.buildCommand(2), Factory.GET_TX_Port())
        raw_input("Press enter key to continue.....")
Exemplo n.º 14
0
 def sequence3(self):
     if len(self.sap_ports) == 0 or len(self.input_ports) == 0:
         self.logger.error("The ICD has no ports satisfying the sequence" \
                           " criteria")
         return
     self.captureForSequence(3)
     self.sendRSET()
     message = "Traffic"
     sap_ports = copy.deepcopy(self.sap_ports)
     while True:
         if len(sap_ports) == 0:
             break
         for _ in range(0, 10):
             port = self.input_ports[random.randint(0, 
                                                 len(self.input_ports) - 1)]
             message = buildShortMessage(port, message)
             self.send(message, port)
             if _%5 == 0:
                 sap_port = sap_ports.pop()
 
                 oid_4kb = getMIBOIDBySize(220)
                 self.sendSNMP(sap_port, oid_4kb, 1)
Exemplo n.º 15
0
    def run(self):
        if len(self.input_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " "scripts criteria")
            return
        self.sendRSET()
        for port in self.input_ports:
            message = buildShortMessage(port, "PortId = %s" % port.RX_AFDX_port_id)
            size = len(self.sns)

            while size > 0:
                outport = Factory.WRITE(port.RX_AFDX_port_id, message)
                setattr(port, "sn_func", self.sn_func)
                self.application.transmitter.transmit(outport, self.network)
                delattr(port, "sn_func")
                rrpc = RRPC(port)
                self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
                pollForResponse("RRPC")
                size -= 1

        erpq = ERPQ(port)
        self.logger.info("Sending an ERPQ command")
        self.send(erpq.buildCommand(), port)
        pollForResponse("ERPQ")
Exemplo n.º 16
0
    def run(self):
        if len(self.input_ports) == 0:
            self.logger.error("The ICD has no ports satisfying the scripts "\
                              "criteria")
        self.sendRSET()
        port = self.input_ports[0]
        erpq = ERPQ(port)
        self.send(erpq.buildCommand(), Factory.GET_TX_Port())
        feature_index = 0
        pollForResponse('ERPQ')

        def sendRRPC():
            rrpc = RRPC(port)
            self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
            pollForResponse('RRPC')

        while feature_index < 20:
            if feature_index in (0, 1, 15, 17, 19): 
                message = buildShortMessage(port, message = "Normal Frame")
                self.send(message, port)
                sendRRPC()
            elif feature_index == 2:
                message = buildShortMessage(port, message = "Wrong ip version")
                packet = self.get_packet(port, message)
                packet[IP].version = 15
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 3:
                message = buildShortMessage(port, message = "Wrong ihl")
                packet = self.get_packet(port, message)
                packet[IP].ihl = 5
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 4:
                message = buildShortMessage(port, message = "Wrong tos")
                packet = self.get_packet(port, message)
                packet[IP].tos = 4
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 5:
                message = buildShortMessage(port, message = "Wrong ctrl flag")
                packet = self.get_packet(port, message)
                packet[IP].flags = 0x03
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 6:
                message = buildShortMessage(port, message = "Wrong ttl field")
                packet = self.get_packet(port, message)
                packet[IP].ttl = 0
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 7:
                message = buildShortMessage(port, message = "Wrong ttl field")
                packet = self.get_packet(port, message)
                packet[IP].ttl = 2
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 8:
                message = buildShortMessage(port, message = "Wrong checksum "\
                                            "field")
                packet = self.get_packet(port, message)
                packet[IP].chksum = 0x01
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 9:
                message = buildShortMessage(port, message = "Wrong ip  dest")
                packet = self.get_packet(port, message)
                packet[IP].dst = '1.2.3.4'
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 10:
                message = buildShortMessage(port, message = "Wrong ip  dest")
                packet = self.get_packet(port, message)
                packet[IP].dst = '255.255.255.255'
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 11:
                message = buildShortMessage(port, message = "Wrong ip dest cst")
                packet = self.get_packet(port, message)
                dst = packet[IP].dst
                if str(dst).startswith('10.'):
                    dst = str(dst).replace('10.', '120.')
                elif str(dst).startswith('224.224'):
                    dst = str(dst).replace('224.224', '234.234')
                packet[IP].dst = dst
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 12:
                message = buildShortMessage(port, message = "Wrong mac cst")
                packet = self.get_packet(port, message)
                dst = packet[Ether].dst
                if str(dst).startswith('03:00:00'):
                    dst = dst.replace('03:00:00', '03:01:01')
                packet[Ether].dst = dst
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 13:
                message = buildShortMessage(port, message = "Wrong mac type "\
                                            "field")
                packet = self.get_packet(port, message)
                packet[Ether].type = 0x0002
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 14:
                message = buildShortMessage(port, message = "Wrong IP options "\
                                            "in header")
                packet = self.get_packet(port, message)
                packet[IP].options = 'dummy'
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 16:
                message = buildShortMessage(port, message = "Wrong udp "\
                                            "checksum field")
                packet = self.get_packet(port, message)
                packet[UDP].chksum = 0x03
                self.send_packet(packet)
                sendRRPC()
            elif feature_index == 18:
                packet = self.get_packet(port, message)
                mac_dst = packet[Ether].dst
                mac_src = packet[Ether].src
                ip_dst = packet[IP].dst
                ip_src = packet[IP].src
                pckt = Ether(dst = mac_dst, src = mac_src) \
                       /IP(dst = ip_dst,  src = ip_src) \
                       /TCP(sport = 50205, dport = port.udp_dst) \
                       /"TCP fragment"
                self.send_packet(pckt)
                sendRRPC()
            feature_index += 1