#!/usr/bin/perl # # SCTP Conformance Test Suite Implementation # (C) Copyright Fujitsu Ltd. 2008, 2009 # # This file is part of the SCTP Conformance Test Suite implementation. # # The SCTP Conformance Test Suite implementation is free software; # you can redistribute it and/or modify it under the terms of # the GNU General Public License version 2 as published by # the Free Software Foundation. # # The SCTP Conformance Test Suite implementation is distributed in the # hope that it will be useful, but WITHOUT ANY WARRANTY; without even # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with GNU CC; see the file COPYING. If not, write to # the Free Software Foundation, 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # # Please send any bug reports or fixes you make to the # email address(es): # networktest sctp # # Or submit a bug report through the following website: # http://networktest.sourceforge.net/ # # Written or modified by: # Hiroaki Kago # Wei Yongjun # # Any bugs reported given to us we will try to fix... any fixes shared will # be incorporated into the next SCTP release. # ############################################################################## BEGIN { $V6evalTool::TestVersion = '$Name: REL_1_0_0 $'; } use lib "../common"; use V6evalTool; use SCTP; %pktdesc = ( sctp_chunk_data_1 => "Recv SCTP CHUNK_DATA (segment 1st)", sctp_chunk_data_2 => "Recv SCTP CHUNK_DATA (segment 2nd)", sctp_chunk_data_3 => "Recv SCTP CHUNK_DATA (segment 3rd)", sctp_chunk_data_4 => "Recv SCTP CHUNK_DATA (segment 4th)", sctp_chunk_sack_seg => "Send SCTP CHUNK_SACK", ); $IF0 = Link0; vCapture($IF0); sctpCheckEnv($IF0); sctpStartClient($IF0, 1, ($SCTP::CONF{ENABLE_IPV6} == 0) ? 1452 * 4 : 1432 * 4); vListen($IF0); vAccept($IF0); vLogHTML('================ Main Test ================='); %ret = vWarpRecv($IF0, 10, 0, 0, sctp_chunk_data_1); if($ret{status} != 0 || $ret{recvFrame} ne sctp_chunk_data_1) { vLogHTML('Cannot receive SCTP CHUNK_DATA
'); vLogHTML('NG'); exit $V6evalTool::exitFail; } $TSN = $ret{sctpGetFieldName("CHUNK_DATA.TSN")}; vWarpCPP("-DSACK=$TSN"); vSend($IF0, sctp_chunk_sack_seg); %ret = vWarpRecv($IF0, 10, 0, 0, sctp_chunk_data_2); if($ret{status} != 0 || $ret{recvFrame} ne sctp_chunk_data_2) { vLogHTML('Cannot receive SCTP CHUNK_DATA
'); vLogHTML('NG'); exit $V6evalTool::exitFail; } %ret = vWarpRecv($IF0, 10, 0, 0, sctp_chunk_data_3); if($ret{status} != 0 || $ret{recvFrame} ne sctp_chunk_data_3) { vLogHTML('Cannot receive SCTP CHUNK_DATA
'); vLogHTML('NG'); exit $V6evalTool::exitFail; } %ret = vWarpRecv($IF0, 10, 0, 0, sctp_chunk_data_4); if($ret{status} != 0 || $ret{recvFrame} ne sctp_chunk_data_4) { vLogHTML('Cannot receive SCTP CHUNK_DATA
'); vLogHTML('NG'); exit $V6evalTool::exitFail; } vWarpCPP("-DSACK=$TSN+3"); vSend($IF0, sctp_chunk_sack_seg); vShutdown($IF0); vLogHTML(OK); exit $V6evalTool::exitPass; ###################################################################### __END__ =head1 NAME FM_SegmentData.seq - Fragment DATA is send if the data size exceeding MTU =head1 PURPOSE To check that if the data size exceeding the current MTU then the endpoint should send segmented user message. =head1 SYNOPSIS =begin html
  ./FM_SegmentData.seq [-tooloption ...] -pkt ./FM_SegmentData.def
    -tooloption : v6eval tool option
  See Also: ../common/STD_PKT_COMMON.def
            ../common/SCTP_COMMON.def
=end html =head1 PRE-TEST CONDITION Association established between endpoint A and B. Also arrange the data in endpoint B such that DATA message with data size exceeding the current MTU is sent to endpoint A. =head1 TEST PROCEDURE Endpoint A Endpoint B ULP (ESTABLISHED) (ESTABLISHED) <----- Send SACK -----------------> <----------------- DATA [TSN=1,B bit=1,E bit=0] (First peace of a segmented data) SACK -----------------> [TSN ACK=1,Frag=0] <----------------- DATA [TSN=2,B bit=0,E bit=0] (Middle peace of a segmented data) <----------------- DATA [TSN=3,B bit=0,E bit=0] (Repeat Data as per MTU size) <----------------- DATA [TSN=4,B bit=0,E bit=1] (Last peace of segmented data) TEST DESCRIPTION: 1.Check that segmentation is performed by the endpoint B as per MTU size. 2.Check that the B bit =1 , E bit =0 first peace of segmented data. 3.Check that the B bit and E bit is 0 middle peace of a segmented data. 4.Check that the E bit =1, B bit =0 last peace of segmented data. =head1 NOTE None =head1 REFERENCE RFC 4960 6.9. Fragmentation and Reassembly =begin html
    An endpoint MAY support fragmentation when sending DATA chunks, but
    it MUST support reassembly when receiving DATA chunks.  If an
    endpoint supports fragmentation, it MUST fragment a user message if
    the size of the user message to be sent causes the outbound SCTP
    packet size to exceed the current MTU.  If an implementation does not
    support fragmentation of outbound user messages, the endpoint MUST
    return an error to its upper layer and not attempt to send the user
    message.
=end html Note: If an implementation that supports fragmentation makes available to its upper layer a mechanism to turn off fragmentation, it may do so. However, in so doing, it MUST react just like an implementation that does NOT support fragmentation, i.e., it MUST reject sends that exceed the current Path MTU (P-MTU). IMPLEMENTATION NOTE: In this error case, the Send primitive discussed in Section 10.1 would need to return an error to the upper layer. If its peer is multi-homed, the endpoint shall choose a size no larger than the association Path MTU. The association Path MTU is the smallest Path MTU of all destination addresses. Note: Once a message is fragmented, it cannot be re-fragmented. Instead, if the PMTU has been reduced, then IP fragmentation must be used. Please see Section 7.3 for details of PMTU discovery. When determining when to fragment, the SCTP implementation MUST take into account the SCTP packet header as well as the DATA chunk header(s). The implementation MUST also take into account the space required for a SACK chunk if bundling a SACK chunk with the DATA chunk. Fragmentation takes the following steps: 1) The data sender MUST break the user message into a series of DATA chunks such that each chunk plus SCTP overhead fits into an IP datagram smaller than or equal to the association Path MTU. 2) The transmitter MUST then assign, in sequence, a separate TSN to each of the DATA chunks in the series. The transmitter assigns the same SSN to each of the DATA chunks. If the user indicates that the user message is to be delivered using unordered delivery, then the U flag of each DATA chunk of the user message MUST be set to 1. 3) The transmitter MUST also set the B/E bits of the first DATA chunk in the series to '10', the B/E bits of the last DATA chunk in the series to '01', and the B/E bits of all other DATA chunks in the series to '00'. An endpoint MUST recognize fragmented DATA chunks by examining the B/E bits in each of the received DATA chunks, and queue the fragmented DATA chunks for reassembly. Once the user message is reassembled, SCTP shall pass the reassembled user message to the specific stream for possible reordering and final dispatching. Note: If the data receiver runs out of buffer space while still waiting for more fragments to complete the reassembly of the message, it should dispatch part of its inbound message through a partial delivery API (see Section 10), freeing some of its receive buffer space so that the rest of the message may be received.