Commit 19fd92a3 authored by garciay's avatar garciay
Browse files

Implement TC_DSLITE_AFTR_ALG_BV_001

parent 6debfabc
Loading
Loading
Loading
Loading
+26 −0
Original line number Diff line number Diff line
@@ -79,6 +79,32 @@ module AtsDSLite_Pixits {
        // TODO Could be extended 
    } // End of modulepar PX_HOST_V4_LIST_AFTR
    
    /**
     * @desc Defines a list of IPv4 host services
     * @see TC_DSLITE_AFTR_BF_BV_001
     */
    modulepar HostV4Descriptions PX_HOST_V4_LIST_FTP := {
        {
            srcAddress  := '91fea0fd'O, // Containing source address indicating a private IPv4 address
            srcPort     := 51201,
            dstAddress  := '41d0e4ef'O, // Containing destination address indicating a public IPv4 address (FTP server address)
            dstPort     := 21,          // FTP port
            payload     := {
                rawPayload := ''O 
            }
        }, // Host #0
        {
            srcAddress  := '91fea0dd'O, // Containing source address indicating a private IPv4 address
            srcPort     := 51201,
            dstAddress  := '41d0e4cf'O, // containing destination address indicating a public IPv4 address (FTP server address)
            dstPort     := 21,          // FTP port
            payload     := {
                rawPayload := ''O 
            }
        } // Host #1
        // TODO Could be extended 
    } // End of modulepar PX_HOST_V4_LIST_FTP
    
    modulepar integer PX_DS_MTU := 1500;
    
} // End of module AtsDSLite_Pixits
 No newline at end of file
+38 −9
Original line number Diff line number Diff line
@@ -10,9 +10,7 @@ module AtsDSLite_Templates {
    
    // LibIPv6
    import from LibIpv6_Interface_TypesAndValues all;
    import from LibIpv6_CommonRfcs_TypesAndValues {
        type Ipv6Address 
    };
    import from LibIpv6_CommonRfcs_TypesAndValues all;
    import from LibIpv6_Interface_Templates all;
    import from LibIpv6_CommonRfcsDhcp_TypesAndValues all;
    import from LibIpv6_Rfc3315Dhcp_TypesAndValues all;
@@ -20,11 +18,8 @@ module AtsDSLite_Templates {
    import from LibIpv6_Rfc6334Dhcp_TypesAndValues all;
    
    // AtsCommon
    import from AtsCommon_DNS_CommonRfcs_TypesAndValues {
        type 
            DnsMsg, DnsHeader, DnsData, 
            Flags, Question, OpCode
    };
    import from AtsCommon_DNS_CommonRfcs_TypesAndValues all;
    import from AtsCommon_Tcp_Rfc793_TypesAndValues all;
    import from AtsCommon_Templates all;
    
    group dhcpv6MessageTemplates {
@@ -228,7 +223,7 @@ module AtsDSLite_Templates {
            } // End of template mw_dnsData_query
            
            template (present) Question mw_question_aftr(
                                                         in template (present) DomainName p_aftrName
                                                         in template (present) AtsCommon_DNS_CommonRfcs_TypesAndValues.DomainName p_aftrName
            ) := {
                name    := p_aftrName,
                rrType  := e_AAAA,
@@ -275,4 +270,38 @@ module AtsDSLite_Templates {
        
    } // End of group dnsMessageTemplates
    
    group ipPackets {
        
        /**
         *  @param  p_src Binary IPv4 address associated with the
         *          test component.
         *  @param  p_dst Binary IPv6 address associated with NUT.
         *  @param  p_ipv6Packet Tunneled IPv6 packet
        */
        template (present) Ipv4Packet mw_ipv4Packet_tcp(
            UInt8 p_protocol,
            template (present) Ipv4Address p_src,
            template (present) Ipv4Address p_dst
        ) := {
            ipv4Hdr := mw_ipv4Hdr_protocol_srcDst(p_protocol, p_src, p_dst),
            ipv4Payload := {
                rawPacket := ?
            }
        } // End of template mw_ipv4Packet_tcp
        
    } // End of group ipPackets 
    
    group tcpPackets {
        
        template (present) TcpPacket mw_ipv4TcpPacket_ports(
                                                            in template (present) UInt16 p_srcPort,
                                                            in template (present) UInt16 p_dstPort
        ) modifies mw_tcp_packet_dummy := {
            srcPort             := p_srcPort,
            dstPort             := p_dstPort
        } // End of template mw_ipv4TcpPacket_ports
        
    } // End of group tcpPackets 
    
    
} // End of module AtsDSLite_Templates
+121 −1
Original line number Diff line number Diff line
@@ -1545,16 +1545,28 @@ module AtsDSLite_TestCases {
                testcase TC_DSLITE_AFTR_ALG_BV_001() runs on DSLiteComponent system TestAdapter {
                    
                    // Local variables
                    var integer v_hostNum := lengthof(PX_HOST_V4_LIST_FTP);     /** Expected number of IPv6 packets to be forwarded */
                    var Ipv4Packet v_ipv4Packet;                                /** IPv4 packets */
                    var Ipv6Packet v_ipv6Packet;                                /** IPv6 packets address to IPv4 */
                    var integer v_host;                                         /** 'for' statement counter */
                    
                    // Test control
                    
                    // Test component configuration
                   // vc_dhcpv6Component := DHCPv6Component.create(c_COMP_DHCP);
                    vc_aftrComponent := AFTRComponent.create(c_COMP_AFTR);
                    for (v_host := 0; v_host < v_hostNum; v_host := v_host + 1) {
                        vc_hostComponents[v_host] := HostComponent.create(c_COMP_HOST & int2str(v_host));
                    } // End of 'for' statement 
                    f_cf01Up_B4();
                    
                    // Test adapter configuration
                    
                    // Start all components
                    vc_aftrComponent.start(f_TC_DSLITE_AFTR_ALG_BV_001_aftr(v_hostNum));
                    for (v_host := 0; v_host < v_hostNum; v_host := v_host + 1) {
                        vc_hostComponents[v_host].start(f_TC_DSLITE_AFTR_ALG_BV_001_host(v_host));
                    } // End of 'for' statement 
                    
                    // Test Body
                    // Clause 'when': 
@@ -1562,7 +1574,7 @@ module AtsDSLite_TestCases {
                    
                    // Clause 'then': Nothing to do, refer to a_default
                    
                    f_serverSyncNClientsAndStop(1, { c_prDone, c_tbDone, c_poDone });
                    f_serverSyncNClientsAndStop(v_hostNum, { c_prDone, c_tbDone, c_poDone });
                    
                    // Postamble
                    f_down();
@@ -1571,6 +1583,114 @@ module AtsDSLite_TestCases {
                
                group f_TC_DSLITE_AFTR_ALG_BV_001 {
                    
                    function f_TC_DSLITE_AFTR_ALG_BV_001_host(in integer p_hostId) runs on HostComponent {
                        
                        // Local variables
                        var Ipv6Packet                  v_ipv6Packet;         /** IPv6 packets address to IPv4 */
                        
                        // Preamble
                        // Clause 'Initial conditions'
                        f_preamble_host();
                        action("Initiate FTP transfert for the host #" & int2str(p_hostId)); // Start FTP transfert between hosts and FTP server
                        f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                        log("*** " & __SCOPE__ & ": INFO: Preamble done. ***");
                        
                        // Test Body
                        // Clause 'when': the IUT receives an IPv6 packet
                        tc_ac.start;
                        alt { 
                            [] ipv6Port.receive(
                                mdw_generalIpv6_extHdr_dst_ipv4Payload(
                                    c_ipv4Hdr,
                                    PX_AFTR_GW_ADDRESS,
                                    ?,
                                    ?                                                       // containing an IPv4 packet as payload
                            )) -> value v_ipv6Packet {
                                tc_ac.stop;
                                if (match(
                                        v_ipv6Packet.ipv6Payload.ipv4Packet, 
                                        mw_ipv4Packet_tcp(
                                            c_tunneledIpHdr,
                                            PX_HOST_V4_LIST_FTP[p_hostId].srcAddress,       // containing source address indicating a private IPv4 address
                                            PX_HOST_V4_LIST_FTP[p_hostId].dstAddress        // containing destination address indicating a public IPv4 address
                                )) ==  true) {
                                    log("*** " & __SCOPE__ & ": PASS: FTP packet was sent by host #", p_hostId, ". ***");
                                } else {
                                    tc_ac.start;
                                    repeat;
                                }
                            }
                            [] tc_ac.timeout {
                                f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                                log("*** " & __SCOPE__ & ": INCONC: Message was not received in time. ***");
                            }
                        } // End of 'alt' statement
                        
                        // Clause 'then': the IUT forwards the FTP packet to the FTP server 
                        f_selfOrClientSyncAndVerdict(c_tbDone, e_success); // Nothing to do
                        
                        // Postamble
                        f_postamble_host();
                        f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                        log("*** " & __SCOPE__ & ": INFO: Postamble done. ***");
                        
                    } // End of function f_TC_DSLITE_AFTR_ALG_BV_001_host
                    
                    function f_TC_DSLITE_AFTR_ALG_BV_001_aftr(in integer p_hostNum) runs on AFTRComponent {
                        
                        // Local variables
                        var integer v_hostNum := p_hostNum;  /** Expected number of IPv6 packets to be forwarded */
                        var ResultsList v_results;           /** List of flags indicating the linked IPv6 packet was forwarded */
                        var Ipv4Packet v_ipv4Packet;         /** Received IPv4 packet */
                        var integer v_host;                  /** 'for' statement counter */
                        
                        // Preamble
                        // Clause 'Initial conditions'
                        f_preamble_aftr();
                        f_selfOrClientSyncAndVerdict(c_prDone, e_success);
                        log("*** " & __SCOPE__ & ": INFO: Preamble done. ***");
                        
                        // Test Body
                        // Clause 'when': the IUT receives multiple HTML IPv4 packets 
                        
                        // Clause 'then': the IUT forwards the FTP packet to the FTP server
                        v_host := 0;
                        tc_ac.start;
                        alt {
                            [] ipv4Port.receive(Ipv4Packet:?) -> value v_ipv4Packet { 
                                tc_ac.stop;
                                for (v_host := 0; v_host < v_hostNum; v_host := v_host + 1) { 
                                    if ( // the IUT forwards packets to the destination with the same public IPv4 source address
                                        (v_ipv4Packet.ipv4Hdr.sourceAddress == PX_HOST_V4_LIST_FTP[v_host].srcAddress) and 
                                        (v_ipv4Packet.ipv4Hdr.destinationAddress == PX_HOST_V4_LIST_FTP[v_host].dstAddress) and             // containing destination address indicating a public IPv4 address (FTP server address)
                                        (oct2int(substr(v_ipv4Packet.ipv4Payload.rawPacket, 2, 2)) == PX_HOST_V4_LIST_FTP[v_host].dstPort)  // containing TCP payload indicating port number 20
                                    ) {
                                        log("*** " & __SCOPE__ & ": INFO: Receives IPv6 packet #", v_host, ". ***");
                                        v_results[v_host] := true;
                                        break;
                                    }
                                } // End of 'for' statement 
                                if (lengthof(v_results) == v_hostNum) { // Check current result
                                    log("*** " & __SCOPE__ & ": PASS: All IPv6 packets were forwarded. ***");
                                    f_selfOrClientSyncAndVerdict(c_tbDone, e_success);
                                } else {
                                    tc_ac.start;
                                    repeat;
                                }
                            }
                            [] tc_ac.timeout {
                                f_selfOrClientSyncAndVerdict(c_tbDone, e_timeout);
                                log("*** " & __SCOPE__ & ": INCONC: Message was not received in due time. ***");
                            }
                        } // End of 'altstep' statement
                        
                        // Postamble
                        f_postamble_aftr();
                        f_selfOrClientSyncAndVerdict(c_poDone, e_success);
                        log("*** " & __SCOPE__ & ": INFO: Postamble done. ***");
                        
                    } // End of function f_TC_DSLITE_AFTR_ALG_BV_001_aftr
                    
                } // End of group f_TC_DSLITE_AFTR_ALG_BV_001
                
            } // End of group validBehaviour