[ATS_IPv4_00372]组播地址不能用作源地址

Multicast address MUST NOT be used as Source address

测试目标

  • 目标:验证IUT在收到源IP地址为组播地址(Multicast Address)的ICMPv4 Echo请求时,不发送ICMPv4 Echo Reply;以避免网络混乱。

测试步骤

  1. LT(测试脚本):
  • LT发送一个ICMPv4 Echo请求给IUT。

  • 源IP地址(Source IP)设置为一个组播地址(AUTOSAR规范中未指定具体地址,我们可以选择一个常见的组播地址,例如224.0.0.1)。

  • 其他字段使用默认值。

  1. IUT:
  • 验证IUT不发送ICMPv4 Echo Reply。

  • 通过标准:IUT不回复,测试通过;如果IUT回复,测试失败

CAPL代码

cpp 复制代码
/*@!Encoding:65001*/
/*
 * This code tests if a device (IUT) correctly ignores an ICMPv4 Echo Request with a multicast source IP 
 * by sending such a request and checking for an unexpected reply.
 * 20250325 v1
 */
variables
{ 
//  const dword iutIP = 0xC0A8B239; // IUT IP: 192.168.178.57
//  const dword multicastIP = 0xE0000001; // Multicast IP: 224.0.0.1
  ethernetPacket txPacket; 

  dword gLastSequenceNumber; 
  dword SPECIAL_IDENTIFIER = 0x1234; // ICMP Echo identifier (example)

  timer testTimer; 
  byte testFailed = 0; 
}

on start
{
  // Step 1: Send ICMPv4 Echo Request with multicast source IP
  char sourceMac[18] = "00:11:22:33:44:55"; // LT MAC (example)
  char destMac[18] = "AA:BB:CC:DD:00:39";   // IUT MAC
  char sourceIP[16] = "224.0.0.1";          // Source IP: Multicast (test requirement)
  char destIP[16] = "192.168.178.57";       // Dest IP: IUT IP

  write("Starting Test ATS_IPv4_00372: Sending ICMPv4 Echo Request with multicast source IP...");

  testFailed = 0;

  sendICMPEchoRequest_Def(1, 2500, sourceMac, destMac, sourceIP, destIP);
  setTimer(testTimer, 5000);
}

void sendICMPEchoRequest_Def(
                    byte channelNum, 
                    word vlanID, 
                    char sourceMac[], 
                    char destMac[], 
                    char sourceIP[], 
                    char destIP[]
)
{
  ethernetPacket txPacket; 
  IP_Address iPaddr_Dest;  
  IP_Address iPaddr_Source; 

  txPacket.msgChannel = channelNum; 

  // Set Ethernet header
  txPacket.source = ethGetMacAddressAsNumber(sourceMac); 
  txPacket.destination = ethGetMacAddressAsNumber(destMac); 
  txPacket.type = 0x0800; 

  // Set VLAN (VLAN ID 2500, PCP=0, DEI=0)
  // 0x8100 = IEEE 802.1Q, 0x09C4 = VLAN ID 2500
  txPacket.SetVlan(0x8100, 0x09C4); 

  // Init IPv4 header
  txPacket.IPv4.Init();
  iPaddr_Source.ParseAddressFromString(sourceIP);
  iPaddr_Dest.ParseAddressFromString(destIP);   
  txPacket.IPv4.Source = iPaddr_Source.IPV4Address; 
  txPacket.IPv4.Destination = iPaddr_Dest.IPV4Address; 

  // Init ICMPv4 Echo Request
  txPacket.ICMPv4.Init();
  txPacket.ICMPv4.Echo.Init();
  gLastSequenceNumber++; // Increment sequence number
  txPacket.ICMPv4.Echo.Identifier = SPECIAL_IDENTIFIER; // Set identifier
  txPacket.ICMPv4.Echo.Sequence = gLastSequenceNumber;  // Set sequence number

  // Complete and send packet
  txPacket.CompletePacket();
  output(txPacket);
  write("Sent ICMPv4 Echo Request, Source IP: %s, Dest IP: %s", sourceIP, destIP);
}

// Listen for responses on Ethernet1
on ethernetPacket msgChannel1.*
{
  if(this.type == 0x0800 && this.Length >= 28) // IPv4 packet
  {
    if(this.Byte(9) == 0x01) // ICMP protocol
    {
      if(this.Byte(20) == 0x00) // ICMP Type: Echo Reply
      {
        if(this.source == EthGetMacAddressAsNumber("AA:BB:CC:DD:00:39")) // From IUT
        {
          write("ERROR: IUT sent ICMPv4 Echo Reply, which is NOT expected!");

          testFailed = 1;
          cancelTimer(testTimer); 
        }
      }
    }
  }
  else
  {
    write("Received packet, but not an IPv4 ICMP Echo Reply.");
  }
}

on timer testTimer
{
  if (testFailed == 0)
  {
    write("Test ATS_IPv4_00372 Passed: IUT did not send ICMPv4 Echo Reply as expected.");
  }
  else
  {
    write("Test ATS_IPv4_00372 Failed: IUT sent an unexpected ICMPv4 Echo Reply.");
  }
}
相关推荐
车软派开发学长20 小时前
零基础学习车软嵌入式AUTOSAR,以一帧CAN报文实战讲解AUTOSAR的学习
网络·stm32·车载系统·autosar·嵌入式实时数据库
龙智DevSecOps解决方案9 天前
TESSY AUTOSAR插件详解:从ARXML模型到自动化测试的完整工作流
autosar·tessy
说不得明天10 天前
网络管理:AutoarNM部分
c语言·网络·mcu·汽车·autosar
内容为空15 天前
comm网络开启流程
autosar
内容为空15 天前
comm网络关闭流程
autosar
内容为空18 天前
AUTOSAR COM 发送流程笔记:Com_SendSignal 与 Com_MainFunctionTx
autosar
嵌软小白呗21 天前
Autosar-SecOC功能详解(一)
e2e·can·autosar·crc·secoc
無斜25 天前
【CAPL实用开发】--- CAPL调用 .NET DLL
开发语言·c#·capl·canoe
内容为空25 天前
TC397 CAN 模块硬件资源与配置详解笔记
autosar
阿歪i1 个月前
EB 配置MCAL (1)
s32k144·autosar·mcal