Esempio 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')
Esempio n. 2
0
    def run(self):
        self.logger.info("Starting the script")
        smallest_bag = None
        needed_port = None
        if len(self.output_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        for port in self.output_ports:
            bag = port.bag
            if smallest_bag == None:
                smallest_bag = bag

            if bag <= smallest_bag:
                smallest_bag = bag
                needed_port = port
        if needed_port == None:
            self.logger.error("The ICD has no entries")
            return

        self.sendRSET()
        self.logger.info("Smallest BAG chosen is %s" % smallest_bag)
        self.logger.info("Sending an EIPC HOLD on %s" % \
                         needed_port.tx_AFDX_port_id)
        eipc = EIPC(needed_port)
        self.send(eipc.buildCommand(command = 'HOLD', message = "SN Test"),
                  Factory.GET_TX_Port())
        pollForResponse('EIPC')

        tcrq = TCRQ()
        self.send(tcrq.buildCommand(257), Factory.GET_TX_Port())
        self.logger.info("Sending a TCRQ command.")
        pollForResponse('TCRQ')
        raw_input("Press enter/return key to continue......")
Esempio n. 3
0
    def run(self):
        self.logger.info("Starting the sequence 1")

        if len(self.output_ports) == 0:
            self.logger.error("There are no ports which satisfy the scripts" \
                              " criteria.")
            return

        self.sendRSET()
        for port in self.output_ports:
            eipc = EIPC(port)
            message = "Port Id = %s" % port.tx_AFDX_port_id
            offset_size = eipc.command_size
            command = eipc.buildCommand(command = 'HOLD', 
                                    message = buildBigMessage(port, message,
                                                offset_size = offset_size))
            self.send(command, Factory.GET_TX_Port())
            if not pollForResponse("EIPC", timeout = 2):
                self.logger.error("The ES has not responded to EIPC")

        tcrq = TCRQ()
        self.send(tcrq.buildCommand(1), Factory.GET_TX_Port())

        if not pollForResponse("TCRQ", timeout = 10):
            self.logger.error("The ES has not responded to TCRQ")

        self.logger.info("Completed sequence 1")
        raw_input("Press any key to continue.")
Esempio 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:
            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.")
Esempio n. 5
0
 def sequence4(self):
     self.captureForSequence(4)
     self.sendRSET()
     for port in self.input_ports:
         if port.port_characteristic != PORT_QUEUING:
             continue
         message = buildBigMessage(port, "Big message")
         self.send(message, port)
         rrpc = RRPC(port)
         self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
         pollForResponse('RRPC')
Esempio n. 6
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')
Esempio n. 7
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')
Esempio n. 8
0
    def do_operation(self, networks):
        if len(self.input_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        for port in self.input_ports:
            message = buildFragmentedMessage(port, len(networks), "Big message")
            outport = Factory.WRITE(port.RX_AFDX_port_id, message)

            self.application.transmitter.transmit(outport, networks)

            rrpc = RRPC(port)
            self.send(rrpc.buildCommand(), port)
            pollForResponse('RRPC')
Esempio n. 9
0
 def send_modified_snfragments(self, ports, networks):
     self.sendRSET()
     for port in ports:
         message = "PortId = %s" % port.RX_AFDX_port_id
         message = buildFragmentedMessage(port, len(networks), message)
         outport = Factory.WRITE(port.RX_AFDX_port_id, message)
         setattr(outport, 'sn_func', self.sn_modifier)
         self.application.transmitter.transmit(outport, networks)
         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')
Esempio n. 10
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")
Esempio n. 11
0
    def sequence2(self):
        ports = {}
        atleast_one = False
        if len(self.input_ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        for port in self.input_ports:
            key = (port.udp_dst, port.ip_dst)

            if ports.has_key(key):
                port.ip_src = "10.1.33.1"
                ports[key].append(port)
                atleast_one = True
            else:
                port.ip_src = "10.1.33.2"
                ports[key] = [port]
        if not atleast_one:
            self.logger.info("Sequence 2 cannot proceed. ICD has no ports "\
                             "satisfying the script requirements")
            return
        self.captureForSequence(2)
        self.sendRSET()

        for key in ports.keys():
            sel_ports = ports[key]
            if len(sel_ports) > 1:
                self.__fillRxPorts(sel_ports)

                for port in sel_ports:
                    rrpc = RRPC(port)
                    self.send(rrpc.buildCommand(), Factory.GET_TX_Port())

                    if not pollForResponse("RRPC"):
                        self.logger.error("The ES has not responded for RRPC")
Esempio n. 12
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')
Esempio n. 13
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.output_ports:
         if port.ip_frag_allowed:
             continue
         eipc = EIPC(port)
         message = buildStaticMessage(int(port.max_frame_size), \
                                      "MFS + 1")
         self.send(eipc.buildCommand(message = message), \
                   Factory.GET_TX_Port())
         self.logger.info("Sending an EIPC command on port : %s" % \
                          port.tx_AFDX_port_id)
         pollForResponse('EIPC')
Esempio n. 14
0
    def sendMessage(self, seqNo, ports, networks):
        if len(ports) == 0 :
            self.logger.error("This sequence cannot proceed as there are no" \
                              " ports in the ICD satisfying the sequence" \
                              " requirements")
            return

        self.captureForSequence(seqNo)
        self.sendRSET()
        pollForResponse('OK')

        for port in ports:
            message = buildFragmentedMessage(port, 6, message = "Fragmented")
            outPort = Factory.WRITE(port.RX_AFDX_port_id, message)
            self.application.transmitter.transmit(outPort, \
                                          network = networks)
            rrpc = RRPC(port)
            self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
            pollForResponse('RRPC')
Esempio n. 15
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')
Esempio n. 16
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')
Esempio n. 17
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.....")
Esempio n. 18
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")
Esempio n. 19
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()
        self.__fillRxPorts(self.input_ports)

        for port in self.input_ports:
            rrpc = RRPC(port)
            self.logger.info("Sending RRPC for port = %s" % \
                             port.RX_AFDX_port_id)
            self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
        
            if not pollForResponse("RRPC"):
                self.logger.error("The ES has not responded for RRPC")
Esempio n. 20
0
    def run(self):

        if len(self.ports) == 0:
            self.logger.info("There are no ports in the ICD satisfying the " \
                             "scripts criteria")
            return
        self.sendRSET()

        for port in self.ports:
            eipc = EIPC(port)
            message = "PortId = %s" % port.tx_AFDX_port_id
            command = eipc.buildCommand(messagetype = 'U', message = message)

            self.logger.info("Sending an EIPC request on port : %s" % \
                             port.tx_AFDX_port_id)

            self.send(command, Factory.GET_TX_Port())

            if not pollForResponse("EIPC"):
                self.logger.error("The ES has not responded for EIPC")
Esempio n. 21
0
 def sendRRPC():
     rrpc = RRPC(port)
     self.send(rrpc.buildCommand(), Factory.GET_TX_Port())
     pollForResponse('RRPC')
Esempio n. 22
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
Esempio n. 23
0
 def __sendicmp(self, port, message, poll = True):
     self.logger.info("Sending an ICMP message on %s" % port.rx_vl_id)
     port = Factory.WRITE_ICMP(port.rx_vl_id, message)
     self.application.transmitter.transmit(port, self.network)
     if poll:
         pollForResponse(message, timeout = 1)