.. Copyright (c) 2025 Vinicius Tadeu Zein See the NOTICE file(s) distributed with this work for additional information regarding copyright ownership. This program and the accompanying materials are made available under the terms of the Apache License Version 2.0 which is available at https://www.apache.org/licenses/LICENSE-2.0 SPDX-License-Identifier: Apache-2.0 ============================== Service Discovery Requirements ============================== This section defines Software Low-Level Requirements (SW-LLR) for the SOME/IP Service Discovery (SOME/IP-SD) module. SD is used to locate service instances, detect their availability, and implement Publish/Subscribe. Overview ======== The Service Discovery module handles: 1. SD message parsing and generation 2. Service offer and find operations 3. Eventgroup subscription management 4. TTL-based service availability tracking 5. Reboot detection SD Message Format ================= Header Requirements ------------------- .. requirement:: SD Service ID :id: REQ_SD_001 :satisfies: feat_req_someipsd_141 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize SD message, verify bytes 0-1 (Service ID) are 0xFF 0xFF. Parse received SD, verify Service ID == 0xFFFF. The software shall use Service ID 0xFFFF for all SOME/IP-SD messages. **Rationale**: Service ID 0xFFFF is reserved for Service Discovery. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: SD Method ID :id: REQ_SD_002 :satisfies: feat_req_someipsd_142 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize SD message, verify bytes 2-3 (Method ID) are 0x81 0x00. Parse received SD, verify Method ID == 0x8100. The software shall use Method ID 0x8100 for all SOME/IP-SD messages. **Rationale**: Method ID 0x8100 is defined for SD messages. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: SD Client ID :id: REQ_SD_003 :satisfies: feat_req_someipsd_144 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize SD message, verify bytes 8-9 (Client ID) are 0x00 0x00. Parse received SD, verify Client ID == 0x0000. The software shall use Client ID 0x0000 for all SOME/IP-SD messages. **Rationale**: Client ID 0x0000 is reserved for SD. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: SD Protocol Version :id: REQ_SD_004 :satisfies: feat_req_someipsd_147 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize SD message, verify byte 12 (Protocol Version) is 0x01. Parse with PV != 0x01, verify rejection. The software shall use Protocol Version 0x01 for all SOME/IP-SD messages. **Rationale**: SOME/IP-SD uses Protocol Version 1. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: SD Interface Version :id: REQ_SD_005 :satisfies: feat_req_someipsd_148 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize SD message, verify byte 13 (Interface Version) is 0x01. Parse with IV != 0x01, verify rejection. The software shall use Interface Version 0x01 for all SOME/IP-SD messages. **Rationale**: SOME/IP-SD uses Interface Version 1. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: SD Message Type :id: REQ_SD_006 :satisfies: feat_req_someipsd_205 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize SD message, verify byte 14 (Message Type) is 0x02 (NOTIFICATION). Parse with wrong type, verify rejection. The software shall use Message Type 0x02 (NOTIFICATION) for all SOME/IP-SD messages. **Rationale**: SD messages are notifications. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: SD Return Code :id: REQ_SD_007 :satisfies: feat_req_someipsd_208, feat_req_someipsd_209 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize SD message, verify byte 15 (Return Code) is 0x00 (E_OK). Parse with RC != 0x00, verify rejection. The software shall use Return Code 0x00 (E_OK) for all SOME/IP-SD messages. **Rationale**: SD messages always use E_OK return code. **Code Location**: ``src/sd/sd_message.cpp`` SD Flags Parsing ---------------- .. requirement:: Parse SD Flags Byte :id: REQ_SD_010 :satisfies: feat_req_someipsd_100, feat_req_someipsd_209, feat_req_someipsd_213 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse SD flags byte 0b10000000, verify Reboot Flag = 1, Unicast Flag = 0. Test 0b01000000, verify Unicast = 1. The software shall parse the SD Flags byte from the first byte (byte 0) of the SOME/IP-SD payload. **Rationale**: Flags byte contains control flags for SD processing. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract Reboot Flag :id: REQ_SD_011 :satisfies: feat_req_someipsd_213 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Reboot flag is extracted from bit 7 of Flags byte. The software shall extract the Reboot flag from bit 7 (most significant bit) of the SD Flags byte. **Rationale**: Reboot flag indicates ECU reboot for session management. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract Unicast Flag :id: REQ_SD_012 :satisfies: feat_req_someipsd_100, feat_req_someipsd_213 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Unicast flag is extracted from bit 6 of Flags byte. The software shall extract the Unicast flag from bit 6 of the SD Flags byte. **Rationale**: Unicast flag indicates unicast-capable endpoint. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Validate Reserved Flags :id: REQ_SD_013 :satisfies: feat_req_someipsd_213 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Verify reserved flag bits 5-0 are zero on transmit. The software shall set reserved flag bits (bits 5-0) to zero when generating SD messages. **Rationale**: Reserved bits must be zero per specification. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Ignore Reserved Flags on Receive :id: REQ_SD_014 :satisfies: feat_req_someipsd_148, feat_req_someipsd_213 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Verify reserved flag bits are ignored during parsing. The software shall ignore reserved flag bits (bits 5-0) when parsing received SD messages. **Rationale**: Forward compatibility with future flag definitions. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Invalid SD Header :id: REQ_SD_001_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify messages not matching SD header requirements are rejected. The software shall reject messages that do not match the required SD header values (Service ID 0xFFFF, Method ID 0x8100). **Rationale**: Invalid SD header indicates malformed message. **Error Handling**: Discard message and log error. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Malformed SD Flags :id: REQ_SD_010_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify error when SD payload is too short for Flags byte. The software shall return an error when the SD payload is too short to contain the Flags byte. **Rationale**: Minimum SD payload must contain Flags and Reserved bytes. **Error Handling**: Return MALFORMED_MESSAGE error. **Code Location**: ``src/sd/sd_message.cpp`` Entry Parsing ============= Entries Array ------------- .. requirement:: Parse Entries Length Field :id: REQ_SD_020 :satisfies: feat_req_someipsd_575 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse SD message with 2 entries (32 bytes), verify entries_length = 32 and both entries are extracted. The software shall parse the Entries Length field as a 4-byte Big Endian value from bytes 4-7 of the SOME/IP-SD payload. **Rationale**: Entries Length indicates the size of the entries array. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Entry Type :id: REQ_SD_021 :satisfies: feat_req_someipsd_575, feat_req_someipsd_625, feat_req_someipsd_626 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse SD message with 1 option (12 bytes), verify options_length = 12 and option is extracted. The software shall parse the Entry Type from the first byte of each SD entry. **Rationale**: Entry Type determines the entry format and semantics. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Entry Size Calculation :id: REQ_SD_022 :satisfies: feat_req_someipsd_575, feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify entry size is 16 bytes for service entries. The software shall use an entry size of 16 bytes for service-type entries (Type 0, Type 1). **Rationale**: Fixed entry size per specification. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Type 0 Find Service Entry :id: REQ_SD_023 :satisfies: feat_req_someipsd_626 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Type 0 (Find Service) entries are correctly parsed. The software shall parse Entry Type 0 as a Find Service entry, extracting Service ID, Instance ID, Major Version, and TTL. **Rationale**: Find Service is used by clients to discover services. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Type 1 Offer Service Entry :id: REQ_SD_024 :satisfies: feat_req_someipsd_626 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Type 1 (Offer Service) entries are correctly parsed. The software shall parse Entry Type 1 as an Offer Service entry, extracting Service ID, Instance ID, Major Version, Minor Version, and TTL. **Rationale**: Offer Service announces service availability. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Type 6 Subscribe Eventgroup Entry :id: REQ_SD_025 :satisfies: feat_req_someipsd_629 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Type 6 (Subscribe Eventgroup) entries are correctly parsed. The software shall parse Entry Type 6 as a Subscribe Eventgroup entry, extracting Service ID, Instance ID, Eventgroup ID, Major Version, and TTL. **Rationale**: Subscribe Eventgroup requests event notifications. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Type 7 Subscribe Eventgroup Ack Entry :id: REQ_SD_026 :satisfies: feat_req_someipsd_630 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Type 7 (Subscribe Eventgroup Ack) entries are correctly parsed. The software shall parse Entry Type 7 as a Subscribe Eventgroup Ack entry, extracting Service ID, Instance ID, Eventgroup ID, and Reserved/Counter. **Rationale**: Subscribe Eventgroup Ack confirms or denies subscription. **Code Location**: ``src/sd/sd_message.cpp`` Entry Fields ------------ .. requirement:: Parse Service ID in Entry :id: REQ_SD_030 :satisfies: feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create OfferService entry (type=0x01), verify Type1 format: service_id, instance_id, major_version, TTL, minor_version. The software shall parse the Service ID from bytes 4-5 of each SD entry in Big Endian byte order. **Rationale**: Service ID identifies the service. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Instance ID in Entry :id: REQ_SD_031 :satisfies: feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create FindService entry (type=0x00), verify Type1 format with TTL=3 for active find. The software shall parse the Instance ID from bytes 6-7 of each SD entry in Big Endian byte order. **Rationale**: Instance ID identifies the service instance. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Instance ID Wildcard :id: REQ_SD_032 :satisfies: feat_req_someipsd_625, feat_req_someipsd_734 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create StopOfferService entry, verify same format as OfferService but with TTL=0. The software shall interpret Instance ID 0xFFFF as a wildcard matching all service instances. **Rationale**: Wildcard for discovering any instance of a service. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Major Version and TTL :id: REQ_SD_033 :satisfies: feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Major Version (1 byte) and TTL (3 bytes) are parsed correctly. The software shall parse the combined Major Version (1 byte) and TTL (3 bytes) from bytes 8-11 of each SD entry in Big Endian byte order. **Rationale**: Major Version and TTL share a 4-byte field. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Minor Version :id: REQ_SD_034 :satisfies: feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Minor Version is parsed from bytes 12-15 of Offer entry. The software shall parse the Minor Version from bytes 12-15 of Offer Service entries in Big Endian byte order. **Rationale**: Minor Version indicates compatible version range. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Eventgroup ID :id: REQ_SD_035 :satisfies: feat_req_someipsd_629 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Eventgroup ID is parsed from bytes 14-15 of subscription entry. The software shall parse the Eventgroup ID from bytes 14-15 of Subscribe Eventgroup entries in Big Endian byte order. **Rationale**: Eventgroup ID identifies the subscribed event group. **Code Location**: ``src/sd/sd_message.cpp`` Entry Error Handling -------------------- .. requirement:: Error - Unknown Entry Type :id: REQ_SD_021_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Verify unknown entry types are skipped with warning. The software shall skip entries with unknown Entry Type values and log a warning, continuing to process remaining entries. **Rationale**: Forward compatibility with new entry types. **Error Handling**: Log warning and skip entry. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Truncated Entry :id: REQ_SD_022_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify error when entry extends beyond Entries Length. The software shall return an error when an entry would extend beyond the declared Entries Length boundary. **Rationale**: Prevents buffer overread. **Error Handling**: Return MALFORMED_MESSAGE error. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Invalid Entries Length :id: REQ_SD_020_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify error when Entries Length exceeds remaining payload. The software shall return an error when the Entries Length field exceeds the remaining SD payload size. **Rationale**: Prevents buffer overread. **Error Handling**: Return MALFORMED_MESSAGE error. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Entries Length Not Multiple of Entry Size :id: REQ_SD_020_E02 :status: implemented :priority: medium :category: error_path :verification: Unit test: Verify warning when Entries Length is not a multiple of entry size. The software shall log a warning when the Entries Length is not an exact multiple of the entry size. **Rationale**: May indicate malformed message or version mismatch. **Error Handling**: Log warning and process complete entries. **Code Location**: ``src/sd/sd_message.cpp`` TTL Processing ============== .. requirement:: Store Service Offer TTL :id: REQ_SD_040 :satisfies: feat_req_someipsd_748 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create SubscribeEventgroup entry (type=0x06), verify Type2 format with eventgroup_id and TTL. The software shall store the TTL value for each service offer received, associated with the Service ID and Instance ID. **Rationale**: TTL tracks service availability duration. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Decrement TTL Periodically :id: REQ_SD_041 :satisfies: feat_req_someipsd_748 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create SubscribeEventgroupAck (type=0x07), verify eventgroup_id matches subscription and TTL > 0. The software shall decrement the stored TTL value for each active service offer every second. **Rationale**: TTL countdown for service expiration. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Remove Service on TTL Expiry :id: REQ_SD_042 :satisfies: feat_req_someipsd_748 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create SubscribeEventgroupNack, verify same format as Ack but with TTL=0. The software shall remove a service from the available services list when its TTL value reaches zero. **Rationale**: Expired services are no longer considered available. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Infinite TTL Value :id: REQ_SD_043 :satisfies: feat_req_someipsd_748 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create StopSubscribeEventgroup, verify same format as Subscribe but with TTL=0. The software shall interpret TTL value 0xFFFFFF (16777215 seconds) as an infinite lifetime that shall not be decremented. **Rationale**: Special value for permanent service availability. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Stop Offer TTL Zero :id: REQ_SD_044 :satisfies: feat_req_someipsd_748 :status: implemented :priority: high :category: happy_path :verification: Unit test: Receive OfferService with TTL=0, verify service is immediately removed from cache. Verify removal callback is invoked. The software shall interpret TTL value 0 as an immediate Stop Offer, removing the service from the available list without delay. **Rationale**: TTL 0 signals service is no longer available. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Reset TTL on New Offer :id: REQ_SD_045 :satisfies: feat_req_someipsd_748 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify new offer resets TTL for existing service entry. The software shall reset the TTL to the new value when a new Offer is received for an already-known service instance. **Rationale**: Refreshes service availability on repeated offers. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Notify Application on Service Availability Change :id: REQ_SD_046 :satisfies: feat_req_someipsd_14 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify callback is invoked when service becomes available/unavailable. The software shall notify the application layer when a service becomes available (offer received) or unavailable (TTL expired or stop offer). **Rationale**: Application needs to know service availability. **Code Location**: ``src/sd/sd_server.cpp`` TTL Error Handling ------------------ .. requirement:: Error - TTL Underflow Protection :id: REQ_SD_041_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Receive TTL=1, wait 1 second, verify TTL expires. Verify no underflow to 0xFFFFFFFF. The software shall prevent TTL underflow by not decrementing TTL values that are already zero. **Rationale**: Prevents unsigned integer underflow. **Error Handling**: Skip decrement for TTL = 0. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Error - Service List Full :id: REQ_SD_040_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Verify error when maximum service entries is reached. The software shall return an error or drop oldest entry when the maximum number of tracked services is reached. **Rationale**: Resource management for memory-constrained systems. **Error Handling**: Return RESOURCE_EXHAUSTED or apply eviction policy. **Code Location**: ``src/sd/sd_server.cpp`` Reboot Detection ================ .. requirement:: Track Session ID per Endpoint :id: REQ_SD_050 :satisfies: feat_req_someipsd_795 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse IPv4EndpointOption (type=0x04), verify length=9, IPv4 address, protocol byte, port number extraction. The software shall store the Session ID from SD messages, associated with the source endpoint (IP address and port). **Rationale**: Session ID tracking enables reboot detection. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Compare Session ID for Reboot Detection :id: REQ_SD_051 :satisfies: feat_req_someipsd_795 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse IPv4MulticastOption (type=0x14), verify multicast IPv4 address and protocol=UDP. The software shall compare the Session ID in newly received SD messages against the stored Session ID for the source endpoint. **Rationale**: Session ID regression indicates reboot. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Detect Reboot on Session ID Regression :id: REQ_SD_052 :satisfies: feat_req_someipsd_795 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse ConfigurationOption (type=0x01), verify key-value data extraction. The software shall detect a reboot condition when the new Session ID is less than the stored Session ID (not within wrap-around threshold). **Rationale**: Lower Session ID indicates ECU restarted. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Detect Reboot on Reboot Flag :id: REQ_SD_053 :satisfies: feat_req_someipsd_795 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify reboot is detected when Reboot flag is set. The software shall detect a reboot condition when the Reboot flag (bit 7 of SD Flags) is set in a received SD message. **Rationale**: Explicit reboot indication from sender. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Trigger Reboot Detection Event :id: REQ_SD_054 :satisfies: feat_req_someipsd_795 :status: implemented :priority: high :category: happy_path :verification: Unit test: Detect sender reboot (session ID reset from 100 to 1), verify reboot detection callback is invoked with sender address. The software shall trigger a reboot detection event when a reboot condition is detected for a remote endpoint. **Rationale**: Application may need to handle reconnection. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Clear Cached Services on Reboot :id: REQ_SD_055 :satisfies: feat_req_someipsd_795 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify all cached services from rebooted endpoint are cleared. The software shall clear all cached service instances associated with a remote endpoint when a reboot is detected. **Rationale**: Services from rebooted ECU are no longer valid. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Update Stored Session ID :id: REQ_SD_056 :satisfies: feat_req_someipsd_795 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify stored Session ID is updated after processing. The software shall update the stored Session ID to the new value after successfully processing an SD message. **Rationale**: Enables detection of subsequent reboots. **Code Location**: ``src/sd/sd_server.cpp`` Reboot Detection Error Handling ------------------------------- .. requirement:: Error - Session ID Wrap-Around Handling :id: REQ_SD_052_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify wrap-around from 0xFFFF to 0x0001 is not detected as reboot. The software shall correctly handle Session ID wrap-around (0xFFFF to 0x0001) and not falsely detect it as a reboot. **Rationale**: Normal Session ID progression should not trigger reboot. **Error Handling**: Use wrap-around detection threshold. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Error - First Session ID Storage :id: REQ_SD_050_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Verify first Session ID from new endpoint is stored without reboot detection. The software shall store the Session ID from a new endpoint without triggering reboot detection. **Rationale**: First contact cannot be a reboot. **Error Handling**: Store Session ID and skip reboot check. **Code Location**: ``src/sd/sd_server.cpp`` Options Parsing =============== Options Array ------------- .. requirement:: Parse Options Length Field :id: REQ_SD_060 :satisfies: feat_req_someipsd_1096 :status: implemented :priority: high :category: happy_path :verification: Unit test: Register service, verify OfferService entry is generated with correct Service ID, Instance ID, and TTL. The software shall parse the Options Length field as a 4-byte Big Endian value from the position immediately after the Entries Array. **Rationale**: Options Length indicates the size of the options array. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Option Type :id: REQ_SD_061 :satisfies: feat_req_someipsd_1096, feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Unregister service, verify StopOfferService (TTL=0) is sent for the specific instance. The software shall parse the Option Type from byte 2 of each SD option (after length field). **Rationale**: Option Type determines the option format. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Option Length :id: REQ_SD_062 :satisfies: feat_req_someipsd_1096, feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Option Length is parsed from bytes 0-1 of option. The software shall parse the Option Length from bytes 0-1 of each SD option in Big Endian byte order. **Rationale**: Option Length indicates the option data size. **Code Location**: ``src/sd/sd_message.cpp`` IPv4 Endpoint Option -------------------- .. requirement:: Parse IPv4 Endpoint Option Type :id: REQ_SD_063 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Option Type 0x04 is parsed as IPv4 Endpoint. The software shall recognize Option Type 0x04 as an IPv4 Endpoint option. **Rationale**: IPv4 Endpoint provides service endpoint information. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract IPv4 Address :id: REQ_SD_064 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify IPv4 address is extracted from bytes 4-7 of option. The software shall extract the IPv4 address from bytes 4-7 of the IPv4 Endpoint option. **Rationale**: IP address is needed for service communication. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract IPv4 Port Number :id: REQ_SD_065 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify port number is extracted from bytes 9-10 of IPv4 option. The software shall extract the port number from bytes 9-10 of the IPv4 Endpoint option in Big Endian byte order. **Rationale**: Port number is needed for service communication. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract IPv4 Protocol :id: REQ_SD_066 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify protocol is extracted from byte 8 of IPv4 option. The software shall extract the L4 protocol from byte 8 of the IPv4 Endpoint option (UDP=0x11, TCP=0x06). **Rationale**: Protocol type determines transport layer. **Code Location**: ``src/sd/sd_message.cpp`` IPv6 Endpoint Option -------------------- .. requirement:: Parse IPv6 Endpoint Option Type :id: REQ_SD_067 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Option Type 0x06 is parsed as IPv6 Endpoint. The software shall recognize Option Type 0x06 as an IPv6 Endpoint option. **Rationale**: IPv6 Endpoint provides service endpoint information. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract IPv6 Address :id: REQ_SD_068 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify IPv6 address is extracted from bytes 4-19 of option. The software shall extract the IPv6 address from bytes 4-19 of the IPv6 Endpoint option (16 bytes). **Rationale**: IPv6 address is needed for service communication. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract IPv6 Port Number :id: REQ_SD_069 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify port number is extracted from bytes 21-22 of IPv6 option. The software shall extract the port number from bytes 21-22 of the IPv6 Endpoint option in Big Endian byte order. **Rationale**: Port number is needed for service communication. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Extract IPv6 Protocol :id: REQ_SD_070 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Client calls find_service(0x1234), verify FindService entry is sent with Service ID=0x1234 via multicast. The software shall extract the L4 protocol from byte 20 of the IPv6 Endpoint option (UDP=0x11, TCP=0x06). **Rationale**: Protocol type determines transport layer. **Code Location**: ``src/sd/sd_message.cpp`` Configuration Option -------------------- .. requirement:: Parse Configuration Option Type :id: REQ_SD_071 :satisfies: feat_req_someipsd_1163 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Client receives OfferService for requested service, verify service is added to local service table. The software shall recognize Option Type 0x01 as a Configuration option. **Rationale**: Configuration option provides additional service parameters. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Configuration String :id: REQ_SD_072 :satisfies: feat_req_someipsd_1163 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Detect reboot (session ID drops), verify all cached state for that endpoint is purged and re-discovery triggered. The software shall extract the configuration string from the Configuration option payload. **Rationale**: Configuration data for service parameters. **Code Location**: ``src/sd/sd_message.cpp`` Multicast Endpoint Options -------------------------- .. requirement:: Parse IPv4 Multicast Option Type :id: REQ_SD_073 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Option Type 0x14 is parsed as IPv4 Multicast. The software shall recognize Option Type 0x14 as an IPv4 Multicast Endpoint option. **Rationale**: Multicast endpoint for event distribution. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse IPv6 Multicast Option Type :id: REQ_SD_074 :satisfies: feat_req_someipsd_1112 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Option Type 0x16 is parsed as IPv6 Multicast. The software shall recognize Option Type 0x16 as an IPv6 Multicast Endpoint option. **Rationale**: Multicast endpoint for event distribution. **Code Location**: ``src/sd/sd_message.cpp`` Option Index References ----------------------- .. requirement:: Parse First Option Index :id: REQ_SD_075 :satisfies: feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse entry with 1st_options_run index=2, num=1, verify option at index 2 is associated with the entry. The software shall parse the First Option Index (1st options run) from byte 1 of each SD entry. **Rationale**: Links entry to its endpoint options. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Second Option Index :id: REQ_SD_076 :satisfies: feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse entry with 2nd_options_run index=4, num=2, verify options at indices 4 and 5 are associated. The software shall parse the Second Option Index (2nd options run) from byte 2 of each SD entry. **Rationale**: Links entry to additional endpoint options. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Parse Option Counts :id: REQ_SD_077 :satisfies: feat_req_someipsd_625 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify option counts are parsed from byte 3 of entry. The software shall parse the option counts (number of options in each run) from byte 3 of each SD entry. **Rationale**: Determines how many options to read for each run. **Code Location**: ``src/sd/sd_message.cpp`` Options Error Handling ---------------------- .. requirement:: Error - Invalid Option Type :id: REQ_SD_061_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Verify unknown option types are skipped with warning. The software shall skip options with unknown Option Type values and log a warning, continuing to process remaining options. **Rationale**: Forward compatibility with new option types. **Error Handling**: Log warning and skip option. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Truncated Option :id: REQ_SD_062_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify error when option extends beyond Options Length. The software shall return an error when an option would extend beyond the declared Options Length boundary. **Rationale**: Prevents buffer overread. **Error Handling**: Return MALFORMED_MESSAGE error. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Invalid Options Length :id: REQ_SD_060_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify error when Options Length exceeds remaining payload. The software shall return an error when the Options Length field exceeds the remaining SD payload size. **Rationale**: Prevents buffer overread. **Error Handling**: Return MALFORMED_MESSAGE error. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Invalid IP Address :id: REQ_SD_064_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Verify warning for invalid IP addresses (0.0.0.0, broadcast). The software shall log a warning when an endpoint option contains an invalid IP address (0.0.0.0 or broadcast address). **Rationale**: Invalid addresses may indicate configuration errors. **Error Handling**: Log warning but process option. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - Option Index Out of Range :id: REQ_SD_075_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Verify error when option index exceeds available options. The software shall return an error when an entry's option index refers to a non-existent option. **Rationale**: Invalid option reference detection. **Error Handling**: Return MALFORMED_MESSAGE error. **Code Location**: ``src/sd/sd_message.cpp`` Service State Machine ===================== .. requirement:: Service Find State :id: REQ_SD_080 :satisfies: feat_req_someipsd_632 :status: implemented :priority: high :category: happy_path :verification: Unit test: Client subscribes to eventgroup, server ACKs, verify ACK TTL matches subscription TTL. The software shall transition a service to the Find state when an application requests to find a service. **Rationale**: State machine for service discovery. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Send Find Service Message :id: REQ_SD_081 :satisfies: feat_req_someipsd_632 :status: implemented :priority: high :category: happy_path :verification: Unit test: Server NACKs subscription for unknown eventgroup, verify NACK has TTL=0 and correct eventgroup_id. The software shall generate and send a Find Service (Type 0) entry when in the Find state. **Rationale**: Initiates service discovery. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Service Available State :id: REQ_SD_082 :satisfies: feat_req_someipsd_632 :status: implemented :priority: high :category: happy_path :verification: Unit test: Subscription TTL expires, verify subscription state transitions to EXPIRED and events stop. The software shall transition a service to the Available state when a matching Offer Service entry is received. **Rationale**: Service has been discovered. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Offer Service Generation :id: REQ_SD_083 :satisfies: feat_req_someipsd_633 :status: implemented :priority: high :category: happy_path :verification: Unit test: Client renews subscription before TTL expires, verify TTL is refreshed and events continue. The software shall generate and send an Offer Service (Type 1) entry when a local service becomes available. **Rationale**: Announces service availability. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Stop Offer Generation :id: REQ_SD_084 :satisfies: feat_req_someipsd_634 :status: implemented :priority: high :category: happy_path :verification: Unit test: Client unsubscribes (StopSubscribe TTL=0), verify server stops sending events immediately. The software shall generate and send an Offer Service entry with TTL=0 when a local service becomes unavailable. **Rationale**: Announces service unavailability. **Code Location**: ``src/sd/sd_server.cpp`` Subscription Management ======================= .. requirement:: Subscribe Eventgroup Request :id: REQ_SD_090 :satisfies: feat_req_someipsd_629 :status: implemented :priority: high :category: happy_path :verification: Unit test: Receive OfferService with TTL=10, verify service is available. Wait 10s, verify service becomes unavailable. The software shall generate and send a Subscribe Eventgroup (Type 6) entry when an application requests to subscribe to an eventgroup. **Rationale**: Initiates event subscription. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Subscribe Eventgroup Acknowledgment :id: REQ_SD_091 :satisfies: feat_req_someipsd_630 :status: implemented :priority: high :category: happy_path :verification: Unit test: Receive OfferService again before TTL expires, verify TTL is refreshed from the new offer. The software shall generate and send a Subscribe Eventgroup Ack (Type 7) entry when a subscription request is accepted. **Rationale**: Confirms subscription to client. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Subscribe Eventgroup Negative Acknowledgment :id: REQ_SD_092 :satisfies: feat_req_someipsd_630 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Subscribe Eventgroup Nack entry is generated on subscription rejection. The software shall generate and send a Subscribe Eventgroup Ack entry with TTL=0 when a subscription request is rejected. **Rationale**: Rejects subscription to client. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Subscription Renewal :id: REQ_SD_093 :satisfies: feat_req_someipsd_748 :status: implemented :priority: high :category: happy_path :verification: Unit test: Subscribe with TTL=10s, verify renewal is triggered before expiry (e.g., at 80% = 8s). Verify TTL refreshes. The software shall automatically renew subscriptions by sending a new Subscribe Eventgroup entry before the subscription TTL expires. **Rationale**: Maintains continuous event subscription. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Stop Subscribe Generation :id: REQ_SD_094 :satisfies: feat_req_someipsd_629 :status: implemented :priority: high :category: happy_path :verification: Unit test: Verify Stop Subscribe entry is generated on unsubscribe request. The software shall generate and send a Subscribe Eventgroup entry with TTL=0 when an application requests to unsubscribe. **Rationale**: Terminates event subscription. **Code Location**: ``src/sd/sd_client.cpp`` Timing and Repetition ===================== .. requirement:: Initial Offer Delay :id: REQ_SD_100 :satisfies: feat_req_someipsd_425 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Start SD server, measure time to first OfferService, verify it falls within [INITIAL_DELAY_MIN, INITIAL_DELAY_MAX]. The software shall wait for a configurable initial delay before sending the first Offer Service message after startup. **Rationale**: Allows network to stabilize. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Offer Repetition :id: REQ_SD_101 :satisfies: feat_req_someipsd_425 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Verify offer is repeated with increasing intervals. The software shall repeat Offer Service messages with exponentially increasing intervals during the repetition phase. **Rationale**: Ensures discovery while reducing network traffic. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Cyclic Offer :id: REQ_SD_102 :satisfies: feat_req_someipsd_425 :status: implemented :priority: medium :category: happy_path :verification: Unit test: After repetition phase, measure offer interval, verify it equals CYCLIC_OFFER_DELAY (e.g., 1000ms +/- 5%). The software shall send Offer Service messages at a configurable cyclic interval during the main phase. **Rationale**: Periodic refresh of service availability. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Find Repetition :id: REQ_SD_103 :satisfies: feat_req_someipsd_632 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Verify find is repeated until service is found or timeout. The software shall repeat Find Service messages with increasing intervals until the service is found or maximum attempts reached. **Rationale**: Persistent service discovery. **Code Location**: ``src/sd/sd_client.cpp`` SD Communication Phases ======================= .. requirement:: SD Initial Wait Phase :id: REQ_SD_110 :satisfies: feat_req_someipsd_63, feat_req_someipsd_64, feat_req_someipsd_65, feat_req_someipsd_773 :status: implemented :priority: high :category: happy_path :verification: Unit test: Start SD server, verify initial wait phase delays first OfferService by configured initial_delay_ms (e.g., 100ms +/- 10%). The software shall implement the Initial Wait Phase where SD messages are delayed by a configurable random time between INITIAL_DELAY_MIN and INITIAL_DELAY_MAX before the first message is sent. **Rationale**: Initial wait phase prevents network storms at startup. **Code Location**: ``src/sd/sd_server.cpp`` (start_offer_timer, initial_delay), ``include/sd/sd_types.h`` (SdConfig) .. requirement:: SD Repetition Phase :id: REQ_SD_111 :satisfies: feat_req_someipsd_67, feat_req_someipsd_73, feat_req_someipsd_76, feat_req_someipsd_867 :status: implemented :priority: high :category: happy_path :verification: Unit test: After initial phase, verify OfferService is repeated with exponential backoff (base * 2^n) up to repetition_max. The software shall implement the Repetition Phase where SD messages are sent with exponentially increasing intervals (base delay times 2^repetition) for a configurable number of repetitions. **Rationale**: Exponential backoff during repetition reduces collision probability. **Code Location**: ``src/sd/sd_server.cpp`` (offer timer repetition logic) .. requirement:: SD Main Phase :id: REQ_SD_112 :satisfies: feat_req_someipsd_79, feat_req_someipsd_80, feat_req_someipsd_81, feat_req_someipsd_425, feat_req_someipsd_866 :status: implemented :priority: high :category: happy_path :verification: Unit test: After repetition phase completes, verify OfferService is sent at stable interval (main phase period). The software shall implement the Main Phase where SD messages are sent at a configurable cyclic interval (CYCLIC_OFFER_DELAY). **Rationale**: Stable main phase rate provides predictable service availability announcements. **Code Location**: ``src/sd/sd_server.cpp`` (main phase stable offer) .. requirement:: SD Shutdown Behavior :id: REQ_SD_113 :satisfies: feat_req_someipsd_820, feat_req_someipsd_821, feat_req_someipsd_830 :status: implemented :priority: high :category: happy_path :verification: Unit test: Call shutdown(), verify StopOffer (TTL=0) is sent for each registered service within 100ms. The software shall send StopOffer entries with TTL=0 for all offered services during shutdown. **Rationale**: Explicit stop-offer on shutdown enables immediate cleanup of cached service state. **Code Location**: ``src/sd/sd_server.cpp`` (shutdown, send_stop_offer_messages) SD Entry Processing =================== .. requirement:: FindService Entry Processing :id: REQ_SD_114 :satisfies: feat_req_someipsd_238, feat_req_someipsd_239, feat_req_someipsd_626, feat_req_someipsd_632 :status: implemented :priority: high :category: happy_path :verification: Unit test: Client sends FindService for Service ID 0x1234, server responds with OfferService containing matching Service ID. The software shall process FindService entries (Type 0) by responding with OfferService entries for matching services. A FindService with Service ID 0xFFFF and Instance ID 0xFFFF shall match all services. **Rationale**: FindService enables on-demand service discovery. **Code Location**: ``src/sd/sd_client.cpp`` (find_service), ``src/sd/sd_server.cpp`` (handle_find_service) .. requirement:: OfferService Entry Processing :id: REQ_SD_115 :satisfies: feat_req_someipsd_252, feat_req_someipsd_253, feat_req_someipsd_633 :status: implemented :priority: high :category: happy_path :verification: Unit test: Server calls offer_service(), verify OfferService entry is broadcast via multicast with TTL > 0. The software shall process OfferService entries (Type 1) by storing the service endpoint information and notifying subscribed clients of service availability. **Rationale**: OfferService proactively announces service availability. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service), ``src/sd/sd_client.cpp`` (process_offer_entry) .. requirement:: StopOfferService Entry Processing :id: REQ_SD_116 :satisfies: feat_req_someipsd_634, feat_req_someipsd_681 :status: implemented :priority: high :category: happy_path :verification: Unit test: Client sends SubscribeEventgroup for eventgroup_id=0x01, server processes and returns ACK with same eventgroup_id. The software shall process StopOfferService entries (Type 1 with TTL=0) by removing the service from the known services list and notifying clients of service unavailability. **Rationale**: Subscription management enables selective event delivery. **Code Location**: ``src/sd/sd_client.cpp`` (subscribe_eventgroup), ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription_request) .. requirement:: SubscribeEventgroup Entry Processing :id: REQ_SD_117 :satisfies: feat_req_someipsd_321, feat_req_someipsd_322, feat_req_someipsd_629 :status: implemented :priority: high :category: happy_path :verification: Unit test: Client subscribes to valid eventgroup, verify ACK entry with TTL > 0. Subscribe to invalid eventgroup, verify NACK with TTL = 0. The software shall process SubscribeEventgroup entries (Type 6) by validating the subscription and responding with an Ack or Nack. **Rationale**: ACK/NACK provides explicit feedback to subscribers. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription, acknowledge=true/false) .. requirement:: StopSubscribeEventgroup Processing :id: REQ_SD_118 :satisfies: feat_req_someipsd_433, feat_req_someipsd_629 :status: implemented :priority: high :category: happy_path :verification: Unit test: Server receives subscription for non-existent eventgroup, verify NACK response (acknowledge=false, TTL=0). The software shall process StopSubscribeEventgroup entries (Type 6 with TTL=0) by removing the subscription. **Rationale**: NACK enables the server to reject invalid subscriptions. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription, NACK response) .. requirement:: SubscribeEventgroupAck Processing :id: REQ_SD_119 :satisfies: feat_req_someipsd_613, feat_req_someipsd_614, feat_req_someipsd_630 :status: implemented :priority: high :category: happy_path :verification: Unit test: Parse SD message with 3 entries (Find, Offer, Subscribe), verify each is dispatched to correct handler. The software shall process SubscribeEventgroupAck entries (Type 7 with TTL>0) by activating event reception for the subscribed eventgroup. **Rationale**: Entry type dispatch enables parallel processing of mixed SD messages. **Code Location**: ``src/sd/sd_server.cpp`` (process_sd_entries, entry type dispatch) .. requirement:: SubscribeEventgroupNack Processing :id: REQ_SD_120 :satisfies: feat_req_someipsd_618, feat_req_someipsd_630 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize IPv4EndpointOption with IP=10.0.0.1 port=30001, deserialize, verify round-trip accuracy. The software shall process SubscribeEventgroupNack entries (Type 7 with TTL=0) by marking the subscription as rejected. **Rationale**: Options provide flexible endpoint and configuration metadata. **Code Location**: ``src/sd/sd_message.cpp`` (SdOption, IPv4EndpointOption, IPv4MulticastOption) SD Option Handling ================== .. requirement:: Load Balancing Option :id: REQ_SD_121 :satisfies: feat_req_someipsd_145, feat_req_someipsd_174, feat_req_someipsd_175 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Create LoadBalancingOption with priority=1 weight=100, serialize, deserialize, verify values preserved. The software shall support the Load Balancing Option (Type 0x02) containing priority and weight fields for load distribution. **Rationale**: Load balancing distributes traffic across equivalent service instances. **Code Location**: ``include/sd/sd_types.h`` (OptionType::LOAD_BALANCING) .. requirement:: IPv4 SD Endpoint Option :id: REQ_SD_122 :satisfies: feat_req_someipsd_1081, feat_req_someipsd_1086 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize IPv4EndpointOption (type=0x04) with address/port, verify 12-byte output with correct type code. The software shall support the IPv4 SD Endpoint Option (Type 0x24) for specifying the SD communication endpoint. **Rationale**: IPv4 endpoint options carry the transport address for service communication. **Code Location**: ``src/sd/sd_message.cpp`` (IPv4EndpointOption::serialize/deserialize) .. requirement:: IPv6 SD Endpoint Option :id: REQ_SD_123 :satisfies: feat_req_someipsd_1135 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize IPv4MulticastOption with group 239.0.0.1:30490, deserialize, verify address and port. The software shall support the IPv6 SD Endpoint Option (Type 0x26) for specifying the SD communication endpoint. **Rationale**: Multicast options specify the group address for multicast event delivery. **Code Location**: ``src/sd/sd_message.cpp`` (IPv4MulticastOption::serialize/deserialize) .. requirement:: Option Run Referencing :id: REQ_SD_124 :satisfies: feat_req_someipsd_335, feat_req_someipsd_336, feat_req_someipsd_341 :status: implemented :priority: high :category: happy_path :verification: Unit test: Create ConfigurationOption with key-value data, serialize, deserialize, verify data preserved. The software shall support referencing options from entries using option index and run length fields. **Rationale**: Configuration options carry key-value service metadata. **Code Location**: ``include/sd/sd_types.h`` (OptionType::CONFIGURATION) .. requirement:: Handling Missing Options :id: REQ_SD_125 :satisfies: feat_req_someipsd_1142 :status: implemented :priority: high :category: error_path :verification: Unit test: Register server state machine, transition through INITIAL→REPETITION→MAIN phases, verify correct entry types sent in each phase. The software shall handle missing mandatory options by rejecting the entry that references them. **Rationale**: State machines ensure correct SD behavior through defined phase transitions. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: Handling Redundant Options :id: REQ_SD_126 :satisfies: feat_req_someipsd_1143, feat_req_someipsd_1144, feat_req_someipsd_1085 :status: implemented :priority: medium :category: error_path :verification: Unit test: Server transitions from DOWN to READY, verify OfferService sent. Transition to DOWN, verify StopOffer sent. The software shall handle redundant (duplicate) options gracefully by using the first valid option. **Rationale**: Server state machine governs offer/stop-offer lifecycle. **Code Location**: ``src/sd/sd_server.cpp`` (offer/stop-offer flow) .. requirement:: Handling Conflicting Options :id: REQ_SD_127 :satisfies: feat_req_someipsd_1145, feat_req_someipsd_1146 :status: implemented :priority: high :category: error_path :verification: Unit test: Client starts FindService, receives OfferService, subscribes to eventgroup, verify full discovery lifecycle. The software shall handle conflicting options by rejecting the entry containing the conflicting options. **Rationale**: Client state machine governs find/subscribe lifecycle. **Code Location**: ``src/sd/sd_client.cpp`` (find_service, subscribe_eventgroup flow) SD State Machines ================= .. requirement:: Server Service State Machine :id: REQ_SD_130 :satisfies: feat_req_someipsd_627, feat_req_someipsd_628, feat_req_someipsd_629 :status: implemented :priority: high :category: happy_path :verification: Unit test: Receive subscription with IPv4EndpointOption, extract client endpoint, verify IP and port match sender. The software shall implement the server service state machine with states: Down, InitialWait, Repetition, and Main. Transitions shall follow the specification state machine. **Rationale**: Client endpoint extraction from subscription determines event delivery target. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription_request, client_endpoint extraction) .. requirement:: Client Service State Machine :id: REQ_SD_131 :satisfies: feat_req_someipsd_627, feat_req_someipsd_628, feat_req_someipsd_630 :status: implemented :priority: high :category: happy_path :verification: Unit test: Server encounters SD processing error, verify SdResult error callback is invoked with error details. The software shall implement the client service state machine with states: Down, InitialWait, Repetition, Main, and Stopped. Transitions shall follow the specification state machine. **Rationale**: Error reporting via SdResult enables application-level error handling. **Code Location**: ``include/sd/sd_types.h`` (SdResult), ``src/sd/sd_server.cpp`` .. requirement:: Eventgroup Subscription State Machine :id: REQ_SD_132 :satisfies: feat_req_someipsd_632, feat_req_someipsd_633, feat_req_someipsd_634 :status: implemented :priority: high :category: happy_path :verification: Unit test: Construct SD message with entries and options, serialize to bytes, deserialize, verify all fields match. The software shall implement the eventgroup subscription state machine for managing subscription lifecycle. **Rationale**: Serialization/deserialization enables SD message exchange over the network. **Code Location**: ``src/sd/sd_message.cpp`` (SdMessage::serialize/deserialize) SD Endpoint Handling ==================== .. requirement:: Service Endpoint Association :id: REQ_SD_140 :satisfies: feat_req_someipsd_810, feat_req_someipsd_815 :status: implemented :priority: high :category: happy_path :verification: Unit test: Server offers 3 instances of same service, verify 3 distinct OfferService entries with different Instance IDs. The software shall associate offered services with their transport endpoints (IP address, port, protocol) from the Endpoint Options. **Rationale**: Per-instance offers allow fine-grained service instance management. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service per instance) .. requirement:: Multicast Endpoint Association :id: REQ_SD_141 :satisfies: feat_req_someipsd_722, feat_req_someipsd_723 :status: implemented :priority: high :category: happy_path :verification: Unit test: Subscribe to multicast eventgroup, verify IPv4MulticastOption is included in ACK and client joins correct multicast group. The software shall associate subscribed eventgroups with their multicast endpoints from the Multicast Options. **Rationale**: Multicast endpoint association enables multicast event delivery per eventgroup. **Code Location**: ``src/sd/sd_server.cpp`` (start_offer_timer, initial_delay), ``include/sd/sd_types.h`` (SdConfig) .. requirement:: Initial Event Sending :id: REQ_SD_142 :satisfies: feat_req_someipsd_789, feat_req_someipsd_833 :status: implemented :priority: high :category: happy_path :verification: Unit test: Server ACKs subscription, verify initial field values are sent via unicast to the new subscriber within 100ms. The software shall send initial events of fields via unicast to newly subscribed clients. **Rationale**: Unicast initial events ensure new subscribers receive current field values immediately. **Code Location**: ``src/sd/sd_server.cpp`` (offer timer repetition logic) SD Error Handling ================= .. requirement:: SD Malformed Message Handling :id: REQ_SD_150 :satisfies: feat_req_someipsd_900, feat_req_someipsd_1220 :status: implemented :priority: high :category: error_path :verification: Unit test: Configure SD with initial_delay=50ms, repetition_base=100ms, repetition_max=3, verify timing sequence. The software shall silently discard malformed SD messages that cannot be parsed. **Rationale**: Configurable timing adapts SD behavior to network characteristics. **Code Location**: ``src/sd/sd_server.cpp``, ``include/sd/sd_types.h`` (SdConfig) .. requirement:: SD Invalid Entry Handling :id: REQ_SD_151 :satisfies: feat_req_someipsd_1141, feat_req_someipsd_1233 :status: implemented :priority: high :category: error_path :verification: Unit test: Parse SD message with 1 valid and 1 malformed entry, verify valid entry is processed and malformed is skipped. The software shall skip invalid entries within a valid SD message and continue processing remaining entries. **Rationale**: Skipping invalid entries prevents one malformed entry from disrupting an entire SD message. **Code Location**: ``src/sd/sd_server.cpp`` (main phase stable offer) .. requirement:: SD TTL Expiry Handling :id: REQ_SD_152 :satisfies: feat_req_someipsd_681, feat_req_someipsd_682, feat_req_someipsd_748 :status: implemented :priority: high :category: error_path :verification: Unit test: Offer service with TTL=5, verify client removes service from registry after 5 seconds without renewal. The software shall remove services and subscriptions when their TTL expires without renewal. **Rationale**: TTL-based expiry ensures stale services and subscriptions are cleaned up automatically. **Code Location**: ``src/sd/sd_server.cpp`` (shutdown, send_stop_offer_messages) SD Multicast Communication ========================== .. requirement:: SD Multicast Transmission :id: REQ_SD_160 :satisfies: feat_req_someipsd_100, feat_req_someipsd_105 :status: implemented :priority: high :category: happy_path :verification: Unit test: Serialize ServiceEntry with Type1=OfferService, verify entry_type field, Service ID, Instance ID, Major Version, TTL, Minor Version. The software shall use multicast for SD OfferService and FindService messages by default. **Rationale**: Standardized entry format enables interoperability between SOME/IP implementations. **Code Location**: ``src/sd/sd_message.cpp`` (SdEntry, ServiceEntry) .. requirement:: SD Unicast Response :id: REQ_SD_161 :satisfies: feat_req_someipsd_90, feat_req_someipsd_91, feat_req_someipsd_826 :status: implemented :priority: high :category: happy_path :verification: Unit test: Send FindService with Unicast Flag set, verify server responds via unicast instead of multicast. The software shall send unicast SD responses when the Unicast Flag is set in the requesting message. **Rationale**: Unicast responses reduce multicast traffic when the requester supports unicast. **Code Location**: ``src/sd/sd_client.cpp`` (find_service), ``src/sd/sd_server.cpp`` (handle_find_service) SD Session Handling =================== .. requirement:: SD Session ID Management :id: REQ_SD_170 :satisfies: feat_req_someipsd_150, feat_req_someipsd_97 :status: implemented :priority: high :category: happy_path :verification: Unit test: Test full discovery workflow: server offers → client finds → client subscribes → server ACKs → event delivered. The software shall increment the Session ID for each SD message sent and use it for reboot detection. **Rationale**: End-to-end discovery workflow validates the complete SD protocol implementation. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Reboot Detection Response :id: REQ_SD_171 :satisfies: feat_req_someipsd_764, feat_req_someipsd_765, feat_req_someipsd_872 :status: implemented :priority: high :category: happy_path :verification: Unit test: Simulate remote reboot (session ID reset), verify all cached services and subscriptions for that endpoint are cleared. Upon detecting a remote reboot, the software shall clear all cached service and subscription state for the rebooted endpoint. **Rationale**: Reboot detection prevents communication with stale cached endpoints. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service), ``src/sd/sd_client.cpp`` (process_offer_entry) SD Minor Version Handling ========================= .. requirement:: Minor Version Matching :id: REQ_SD_180 :satisfies: feat_req_someipsd_238, feat_req_someipsd_736 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Set session_id increment mode, verify SD message Session IDs increment per message. The software shall support Minor Version matching in FindService entries. Minor Version 0xFFFFFFFF shall match any minor version. **Rationale**: Session handling enables SD message deduplication and ordering. **Code Location**: ``include/sd/sd_types.h`` (SdConfig::initial_delay, repetition_base) SD General Message Format ========================= .. requirement:: SD Message Structure - Flags and Reserved :id: REQ_SD_200a :satisfies: feat_req_someipsd_38, feat_req_someipsd_39, feat_req_someipsd_40 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize SD message, verify Flags byte at offset 0, Reserved bytes at offsets 1-3 are zero. Parse and verify Reboot/Unicast flags. The software shall parse and construct SD message header with Flags (1 byte) and Reserved (3 bytes) fields according to SOME/IP-SD format. **Rationale**: Flags and reserved bytes are required by the AUTOSAR SOME/IP-SD specification for message-level metadata. **Code Location**: ``src/sd/sd_message.cpp`` (SdMessage structure) .. requirement:: SD Entries Array Format :id: REQ_SD_200b :satisfies: feat_req_someipsd_41, feat_req_someipsd_42, feat_req_someipsd_44 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Construct SD message with 2 entries (OfferService, FindService), serialize, verify 4-byte length prefix and entry layout per spec. The software shall parse and construct the SD Entries Array with length field and entry layout according to SOME/IP-SD format. **Rationale**: The entries array carries service offers, finds, and subscriptions; format compliance ensures interoperability. **Code Location**: ``src/sd/sd_message.cpp`` (SdMessage structure) .. requirement:: SD Options Array Format :id: REQ_SD_200c :satisfies: feat_req_someipsd_1, feat_req_someipsd_2, feat_req_someipsd_13 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Add IPv4EndpointOption and IPv6EndpointOption to SD message, serialize, verify option length, type, and payload layout per spec. The software shall parse and construct the SD Options Array with length field and option layout (IPv4, IPv6, etc.) according to SOME/IP-SD format. **Rationale**: Options provide endpoint and configuration data; format compliance ensures correct address resolution. **Code Location**: ``src/sd/sd_message.cpp`` (SdMessage structure) .. requirement:: SD Transport Requirements :id: REQ_SD_201 :satisfies: feat_req_someipsd_46, feat_req_someipsd_47 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Parse SD header, verify Flags byte at offset 0, Reserved bytes at offsets 1-3 are zero, entries length at offset 4. The software shall transport SD messages over UDP using the configured SD port (default 30490) with multicast for general announcements. **Rationale**: Header fields provide message-level metadata (flags, reserved bytes). **Code Location**: ``src/sd/sd_message.cpp`` (flags, reserved bytes) .. requirement:: SD ECU Internal Interface :id: REQ_SD_202 :satisfies: feat_req_someipsd_22, feat_req_someipsd_23, feat_req_someipsd_24, feat_req_someipsd_25, feat_req_someipsd_26, feat_req_someipsd_27, feat_req_someipsd_16, feat_req_someipsd_17, feat_req_someipsd_18 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize entries array with 2 entries, verify 4-byte length prefix equals 2*16 bytes, followed by entry data. The software shall provide an ECU-internal interface for applications to register services, request services, subscribe to eventgroups, and receive service availability notifications. **Rationale**: The entries array carries service and subscription announcements. **Code Location**: ``src/sd/sd_message.cpp`` (entries_array serialization) SD Header Details ================= .. requirement:: SD Header Field Parsing :id: REQ_SD_210 :satisfies: feat_req_someipsd_59, feat_req_someipsd_61, feat_req_someipsd_62 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Construct FindService entry (type=0x00) for Service ID 0x1234, TTL=3, verify serialized entry fields. The software shall parse and validate the complete SD header including Message ID (0xFFFF8100), Length, Request ID, Protocol Version, Interface Version, Message Type, and Return Code. **Rationale**: FindService entries trigger service discovery responses from servers. **Code Location**: ``src/sd/sd_client.cpp`` (find_service entry construction) .. requirement:: SD Session ID Handling :id: REQ_SD_211 :satisfies: feat_req_someipsd_96, feat_req_someipsd_94, feat_req_someipsd_863 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Construct OfferService entry (type=0x01) with TTL=10, Minor Version=0x01, verify serialization. The software shall maintain separate Session IDs for multicast and unicast SD messages. Session IDs shall be incremented for each message sent. **Rationale**: OfferService entries announce available service instances. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service entry construction) .. requirement:: SD Reboot Flag Management :id: REQ_SD_212 :satisfies: feat_req_someipsd_83, feat_req_someipsd_84, feat_req_someipsd_85, feat_req_someipsd_87, feat_req_someipsd_89 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Construct SubscribeEventgroup entry (type=0x06) with eventgroup_id=0x01, TTL=10, verify serialization. The software shall manage the Reboot Flag in SD messages. The flag shall be set after reboot until the Session ID wraps around. TCP connections shall be reset on reboot detection. **Rationale**: SubscribeEventgroup entries register client interest in events. **Code Location**: ``src/sd/sd_client.cpp`` (subscribe_eventgroup entry construction) SD Entry Format Details ======================= .. requirement:: SD Entry Common Fields :id: REQ_SD_220 :satisfies: feat_req_someipsd_122, feat_req_someipsd_126, feat_req_someipsd_127, feat_req_someipsd_128, feat_req_someipsd_129, feat_req_someipsd_212, feat_req_someipsd_214 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Configure SD multicast port 30490, verify all SD messages are sent to this port. Test custom multicast group address. The software shall parse common entry fields: Type (1 byte), Index First/Second Options Run (1 byte each), Number of Options (1 byte), Service ID (2 bytes), Instance ID (2 bytes), Major Version/TTL (4 bytes combined), and type-specific fields (4 bytes). **Rationale**: Configurable multicast enables deployment-specific network topology. **Code Location**: ``src/sd/sd_server.cpp`` (multicast_port config), ``include/sd/sd_types.h`` .. requirement:: SD Service Entry Format :id: REQ_SD_221 :satisfies: feat_req_someipsd_133, feat_req_someipsd_137, feat_req_someipsd_138, feat_req_someipsd_139, feat_req_someipsd_140 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Send FindService via multicast, receive OfferService via unicast, verify correct addressing. The software shall parse service entries (Type 0 FindService, Type 1 OfferService) with Minor Version in the type-specific field. Service entries are 16 bytes each. **Rationale**: Multicast for discovery, unicast for responses optimizes bandwidth. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Eventgroup Entry Format :id: REQ_SD_222 :satisfies: feat_req_someipsd_149, feat_req_someipsd_151, feat_req_someipsd_152, feat_req_someipsd_157, feat_req_someipsd_158 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Subscribe with TTL=10s, verify subscription expires after 10s. Re-subscribe before expiry, verify renewal. The software shall parse eventgroup entries (Type 6 Subscribe, Type 7 SubscribeAck) with Reserved, Initial Data Flag, Counter, and Eventgroup ID in the type-specific field. **Rationale**: TTL-based subscriptions enable automatic cleanup without explicit unsubscribe. **Code Location**: ``src/sd/sd_server.cpp`` (subscription TTL handling) .. requirement:: SD Entry Multiple Entries per Message :id: REQ_SD_223 :satisfies: feat_req_someipsd_159, feat_req_someipsd_160, feat_req_someipsd_161, feat_req_someipsd_162, feat_req_someipsd_163, feat_req_someipsd_164 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Offer service with TTL=5, verify client removes service from cache after 5 seconds without re-offer. The software shall support multiple entries per SD message, combining entries to reduce the number of SD messages sent. **Rationale**: TTL-based service availability prevents stale service entries. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` (TTL management) SD Option Format Details ======================== .. requirement:: SD Configuration Option :id: REQ_SD_230 :satisfies: feat_req_someipsd_182, feat_req_someipsd_183, feat_req_someipsd_184 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server receives SubscribeEventgroup, extracts endpoint from IPv4EndpointOption, verify client IP and port. The software shall parse Configuration Options (Type 0x01) containing key-value configuration strings for service instances. **Rationale**: Endpoint extraction enables the server to know where to send events. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription_request) .. requirement:: SD Load Balancing Option Format :id: REQ_SD_231 :satisfies: feat_req_someipsd_146, feat_req_someipsd_770 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Client processes OfferService with IPv4EndpointOption, extracts server address, verify address matches option data. The software shall parse Load Balancing Options (Type 0x02) containing Priority and Weight fields for server selection. **Rationale**: Server address resolution enables the client to know where to send requests. **Code Location**: ``src/sd/sd_client.cpp`` (process_offer_entry endpoint extraction) .. requirement:: SD IPv4 Endpoint Option Format :id: REQ_SD_232 :satisfies: feat_req_someipsd_197, feat_req_someipsd_199, feat_req_someipsd_200, feat_req_someipsd_201 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize IPv4EndpointOption with IP=10.0.0.1 port=30001 proto=UDP, verify type=0x04, length=9, and correct byte layout. The software shall parse IPv4 Endpoint Options (Type 0x04) containing IPv4 address (4 bytes), reserved byte, protocol (1 byte: 0x06=TCP, 0x11=UDP), and port number (2 bytes). **Rationale**: Correct IPv4 option format ensures interoperability. **Code Location**: ``src/sd/sd_client.cpp`` (subscribe_eventgroup), ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription_request) .. requirement:: SD IPv6 Endpoint Option Format :id: REQ_SD_233 :satisfies: feat_req_someipsd_203, feat_req_someipsd_204 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize IPv6EndpointOption with valid IPv6 address and port, verify type=0x06 and 16-byte address field. The software shall parse IPv6 Endpoint Options (Type 0x06) containing IPv6 address (16 bytes), reserved byte, protocol, and port number. **Rationale**: IPv6 support enables SD in IPv6 networks. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription, acknowledge=true/false) .. requirement:: SD IPv4 Multicast Option Format :id: REQ_SD_234 :satisfies: feat_req_someipsd_724, feat_req_someipsd_725, feat_req_someipsd_733, feat_req_someipsd_749 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize IPv4MulticastOption with group=239.0.0.1 port=30490 proto=UDP, verify type=0x14 and correct layout. The software shall parse IPv4 Multicast Options (Type 0x14) containing multicast IPv4 address, protocol (UDP only), and port number. **Rationale**: IPv4 multicast option format enables multicast event delivery. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription, NACK response) .. requirement:: SD IPv6 Multicast Option Format :id: REQ_SD_235 :satisfies: feat_req_someipsd_737, feat_req_someipsd_738, feat_req_someipsd_739, feat_req_someipsd_750 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize IPv6MulticastOption with valid multicast IPv6 address, verify type=0x16 and 16-byte address field. The software shall parse IPv6 Multicast Options (Type 0x16) containing multicast IPv6 address, protocol (UDP only), and port number. **Rationale**: IPv6 multicast support enables SD in IPv6 networks. **Code Location**: ``src/sd/sd_server.cpp`` (process_sd_entries, entry type dispatch) .. requirement:: SD IPv4 SD Endpoint Option Format :id: REQ_SD_236 :satisfies: feat_req_someipsd_1080, feat_req_someipsd_1082, feat_req_someipsd_1083, feat_req_someipsd_1084, feat_req_someipsd_1087 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Serialize IPv4 SD EndpointOption (type=0x24), verify it is not referenced by entries. The software shall parse IPv4 SD Endpoint Options (Type 0x24) containing the SD communication endpoint. This option is not referenced by entries. **Rationale**: SD endpoint option carries the SD communication endpoint independently of entries. **Code Location**: ``src/sd/sd_message.cpp`` (SdOption, IPv4EndpointOption, IPv4MulticastOption) SD Option Referencing Details ============================= .. requirement:: SD Option Index and Run Length :id: REQ_SD_240 :satisfies: feat_req_someipsd_332, feat_req_someipsd_333, feat_req_someipsd_342, feat_req_someipsd_343 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Call offer_service() with Service ID, Instance ID, and endpoint, verify SD broadcasts OfferService entry. The software shall reference options from entries using the First and Second Option Index and their respective run lengths. Options are referenced as contiguous runs. **Rationale**: Service registration makes services discoverable via SD. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service, service registration) .. requirement:: SD Option Run Processing :id: REQ_SD_241 :satisfies: feat_req_someipsd_346, feat_req_someipsd_347, feat_req_someipsd_348, feat_req_someipsd_351 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Start find_service() for Service ID 0x1234, receive OfferService, verify service is added to service registry. The software shall process option runs by iterating from the starting index for the given count. Empty runs (count=0) shall be valid. Unknown option types shall be skipped. **Rationale**: Service discovery enables clients to find available services dynamically. **Code Location**: ``src/sd/sd_client.cpp`` (find_service, process_offer_entry) .. requirement:: SD Option Validation :id: REQ_SD_242 :satisfies: feat_req_someipsd_1095, feat_req_someipsd_1097, feat_req_someipsd_1098, feat_req_someipsd_1099, feat_req_someipsd_1100 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Create option with invalid length, verify it is rejected. Create option with valid type/length, verify acceptance. The software shall validate options for correct length, type, and content. Invalid options shall cause the referencing entry to be rejected. **Rationale**: Option validation prevents processing of malformed endpoint data. **Code Location**: ``include/sd/sd_types.h`` (OptionType::LOAD_BALANCING) .. requirement:: SD Endpoint Option Processing :id: REQ_SD_243 :satisfies: feat_req_someipsd_1101, feat_req_someipsd_1102, feat_req_someipsd_1103 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Parse OfferService with IPv4EndpointOption, extract IP=10.0.0.1 port=30001, verify endpoint matches option data. The software shall process Endpoint Options to determine the transport endpoint (IP, port, protocol) for a service instance. **Rationale**: Endpoint processing resolves abstract SD entries to concrete transport addresses. **Code Location**: ``src/sd/sd_message.cpp`` (IPv4EndpointOption::serialize/deserialize) SD FindService Message Details ============================== .. requirement:: SD FindService Message Construction :id: REQ_SD_250 :satisfies: feat_req_someipsd_217, feat_req_someipsd_218, feat_req_someipsd_219, feat_req_someipsd_220 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Call shutdown(), verify StopOffer entries (TTL=0) are sent for all offered services. The software shall construct FindService messages with the appropriate Service ID, Instance ID (0xFFFF for all), Major Version (0xFF for any), and Minor Version (0xFFFFFFFF for any). **Rationale**: Clean shutdown prevents clients from sending to unavailable services. **Code Location**: ``src/sd/sd_server.cpp`` (shutdown, send_stop_offer_messages) .. requirement:: SD FindService Response Behavior :id: REQ_SD_251 :satisfies: feat_req_someipsd_224, feat_req_someipsd_225, feat_req_someipsd_227, feat_req_someipsd_766, feat_req_someipsd_767 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server reboots (reboot flag set), client detects new session, verify re-subscription is initiated. The software shall respond to FindService with OfferService entries for matching services. Responses shall use configurable delay (REQUEST_RESPONSE_DELAY). **Rationale**: Reboot recovery ensures subscriptions are re-established after endpoint restart. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` SD OfferService Message Details =============================== .. requirement:: SD OfferService Message Construction :id: REQ_SD_260 :satisfies: feat_req_someipsd_221, feat_req_someipsd_233, feat_req_someipsd_235, feat_req_someipsd_236, feat_req_someipsd_237 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Configure non-SOME/IP protocol support, offer service with ID 0xFFFE, verify interoperability entries. The software shall construct OfferService messages with Service ID, Instance ID, Major/Minor Version, TTL, and Endpoint Options. **Rationale**: Non-SOME/IP support enables interoperability with other automotive protocols. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD StopOfferService Construction :id: REQ_SD_261 :satisfies: feat_req_someipsd_256, feat_req_someipsd_261, feat_req_someipsd_262 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Stop service, verify StopOfferService entry has TTL=0, same Service ID and Instance ID as the offer. The software shall construct StopOfferService messages with TTL=0 when a service instance is stopped or going down. **Rationale**: StopOfferService with TTL=0 signals immediate service unavailability. **Code Location**: ``src/sd/sd_message.cpp`` (IPv4MulticastOption::serialize/deserialize) SD SubscribeEventgroup Message Details ====================================== .. requirement:: SD SubscribeEventgroup Construction :id: REQ_SD_270 :satisfies: feat_req_someipsd_230, feat_req_someipsd_429, feat_req_someipsd_430, feat_req_someipsd_431, feat_req_someipsd_432, feat_req_someipsd_428 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server receives FindService from unknown client, verify it responds without authentication checks (open access). The software shall construct SubscribeEventgroup messages with Service ID, Instance ID, Eventgroup ID, TTL, and client Endpoint Options. Subscriptions shall be triggered by OfferService reception. **Rationale**: Open access simplifies deployment without per-client authorization at SD level. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Subscription Lifecycle :id: REQ_SD_271 :satisfies: feat_req_someipsd_435, feat_req_someipsd_436, feat_req_someipsd_437, feat_req_someipsd_439, feat_req_someipsd_444, feat_req_someipsd_445 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Subscribe on OfferService receipt, renew before TTL/2 expiry, call shutdown → verify StopSubscribe sent. The software shall manage subscription lifecycle: subscribe on service availability, renew before TTL expiry, unsubscribe on shutdown, and re-subscribe after timeout. **Rationale**: Subscription lifecycle management ensures correct subscribe/renew/unsubscribe behavior. **Code Location**: ``include/sd/sd_types.h`` (OptionType::CONFIGURATION) .. requirement:: SD SubscribeEventgroupAck Construction :id: REQ_SD_272 :satisfies: feat_req_someipsd_612, feat_req_someipsd_613, feat_req_someipsd_614, feat_req_someipsd_619, feat_req_someipsd_844 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server ACKs multicast eventgroup subscription, verify ACK includes IPv4MulticastOption with group address and port. The software shall construct SubscribeEventgroupAck messages to confirm accepted subscriptions. Ack shall include Multicast Options if the eventgroup uses multicast. **Rationale**: Multicast options in ACKs direct the client to the correct multicast group. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD SubscribeEventgroupNack Construction :id: REQ_SD_273 :satisfies: feat_req_someipsd_617, feat_req_someipsd_869, feat_req_someipsd_870 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server rejects subscription, verify NACK entry with TTL=0 is sent. Verify client handles NACK by checking TCP connectivity. The software shall construct SubscribeEventgroupNack messages with TTL=0 to reject subscriptions. Clients shall handle Nack by checking TCP connections. **Rationale**: NACK with TTL=0 clearly signals subscription rejection. **Code Location**: ``src/sd/sd_server.cpp`` (offer/stop-offer flow) .. requirement:: SD StopSubscribeEventgroup Construction :id: REQ_SD_274 :satisfies: feat_req_someipsd_433, feat_req_someipsd_440, feat_req_someipsd_441, feat_req_someipsd_442 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Client unsubscribes from eventgroup, verify StopSubscribeEventgroup entry with TTL=0 is sent. The software shall construct StopSubscribeEventgroup messages with TTL=0 when unsubscribing from an eventgroup. **Rationale**: StopSubscribe with TTL=0 signals immediate unsubscription. **Code Location**: ``src/sd/sd_client.cpp`` (find_service, subscribe_eventgroup flow) SD Communication Behavior Details ================================= .. requirement:: SD Timing Configuration :id: REQ_SD_280 :satisfies: feat_req_someipsd_66, feat_req_someipsd_68, feat_req_someipsd_72 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Configure SD with INITIAL_DELAY_MIN=50, MAX=100, REPETITIONS_BASE=200, MAX=3, verify all values applied. The software shall support configurable SD timing parameters: INITIAL_DELAY_MIN/MAX, REPETITIONS_BASE_DELAY, REPETITIONS_MAX, and CYCLIC_OFFER_DELAY. **Rationale**: Configurable timing adapts SD phases to network characteristics. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription_request, client_endpoint extraction) .. requirement:: SD Phase Transitions :id: REQ_SD_281 :satisfies: feat_req_someipsd_74, feat_req_someipsd_75, feat_req_someipsd_77, feat_req_someipsd_419, feat_req_someipsd_422 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Start SD, verify InitialWait→Repetition after first send, Repetition→Main after REPETITIONS_MAX, any→Down on stop. The software shall implement phase transitions: from Initial Wait to Repetition (after first send), from Repetition to Main (after REPETITIONS_MAX), and from any phase to Down (on stop/error). **Rationale**: Phase transitions enforce the SD protocol state machine. **Code Location**: ``include/sd/sd_types.h`` (SdResult), ``src/sd/sd_server.cpp`` .. requirement:: SD Multicast Group Management :id: REQ_SD_282 :satisfies: feat_req_someipsd_101, feat_req_someipsd_102, feat_req_someipsd_103, feat_req_someipsd_104 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Register service, verify SD joins configured multicast group. Unregister, verify SD leaves multicast group. The software shall join and leave multicast groups for SD communication based on service registration and subscription state. **Rationale**: Dynamic multicast group management conserves network resources. **Code Location**: ``src/sd/sd_message.cpp`` (SdMessage::serialize/deserialize) .. requirement:: SD Response Delay Configuration :id: REQ_SD_283 :satisfies: feat_req_someipsd_106, feat_req_someipsd_107, feat_req_someipsd_109 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Configure REQUEST_RESPONSE_DELAY=50ms, send FindService, verify response is delayed by at least 50ms. The software shall apply configurable response delays (REQUEST_RESPONSE_DELAY) when responding to FindService messages to avoid network storms. **Rationale**: Response delays prevent network storms from simultaneous SD responses. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service per instance) SD Endpoint Handling Details ============================ .. requirement:: SD Server Endpoint Registration :id: REQ_SD_290 :satisfies: feat_req_someipsd_806, feat_req_someipsd_807, feat_req_someipsd_808, feat_req_someipsd_809, feat_req_someipsd_811 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Register server endpoint (IP, port, TCP), verify OfferService includes IPv4EndpointOption with proto=TCP. The software shall register server endpoints (IP, port, protocol) for offered services and include them in OfferService options. **Rationale**: Server endpoint registration enables clients to discover communication endpoints. **Code Location**: ``src/sd/sd_server.cpp``, ``include/sd/sd_types.h`` (SdConfig) .. requirement:: SD Client Endpoint Resolution :id: REQ_SD_291 :satisfies: feat_req_someipsd_812, feat_req_someipsd_813, feat_req_someipsd_814, feat_req_someipsd_816 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Client receives SubscribeEventgroup, extracts client endpoint from option, verify IP and port are correct. The software shall resolve client endpoints from SubscribeEventgroup options to determine where to send events and notifications. **Rationale**: Client endpoint resolution enables the server to deliver events to subscribers. **Code Location**: ``src/sd/sd_message.cpp`` (SdEntry, ServiceEntry) .. requirement:: SD Multicast Endpoint Handling :id: REQ_SD_292 :satisfies: feat_req_someipsd_751, feat_req_someipsd_752, feat_req_someipsd_754, feat_req_someipsd_755, feat_req_someipsd_756, feat_req_someipsd_757, feat_req_someipsd_758 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Configure multicast eventgroup, verify server joins multicast group, sends initial events via unicast, switches to multicast when threshold met. The software shall handle multicast endpoints for eventgroups, including joining multicast groups, sending initial events via unicast, and switching between unicast/multicast based on subscriber count. **Rationale**: Multicast endpoint handling optimizes event delivery for groups with many subscribers. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Endpoint Validation :id: REQ_SD_293 :satisfies: feat_req_someipsd_1111, feat_req_someipsd_1113, feat_req_someipsd_1114, feat_req_someipsd_1169, feat_req_someipsd_1170, feat_req_someipsd_1171 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Parse option with invalid IP=0.0.0.0, verify rejection. Parse option with valid IP and supported protocol, verify acceptance. The software shall validate endpoint options for correct format, valid IP addresses, and supported protocols. **Rationale**: Endpoint validation prevents communication failures from malformed addresses. **Code Location**: ``include/sd/sd_types.h`` (SdConfig::initial_delay, repetition_base) SD Service Registration and Discovery ===================================== .. requirement:: SD Service Offer Processing :id: REQ_SD_300 :satisfies: feat_req_someipsd_762, feat_req_someipsd_763, feat_req_someipsd_828, feat_req_someipsd_829 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server ACKs subscription, verify initial event is triggered for the newly subscribed client. The software shall process OfferService entries by updating the service registry with endpoint information and TTL. **Rationale**: Initial events ensure newly subscribed clients have up-to-date state. **Code Location**: ``src/sd/sd_server.cpp`` (subscription acknowledgment, initial events) .. requirement:: SD Service State Tracking :id: REQ_SD_301 :satisfies: feat_req_someipsd_771, feat_req_someipsd_772, feat_req_someipsd_776, feat_req_someipsd_777, feat_req_someipsd_778 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Receive OfferService, verify service state transitions to AVAILABLE. TTL expires, verify state transitions to UNAVAILABLE. The software shall track service state (available, unavailable, timing out) and notify applications of state changes. **Rationale**: Service state tracking enables applications to react to availability changes. **Code Location**: ``src/sd/sd_message.cpp`` (SdMessage structure) .. requirement:: SD Subscription State Tracking :id: REQ_SD_302 :satisfies: feat_req_someipsd_779, feat_req_someipsd_780, feat_req_someipsd_781, feat_req_someipsd_782, feat_req_someipsd_783 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Send SubscribeEventgroup, receive ACK, verify subscription state=ACTIVE. Receive NACK, verify state=REJECTED. The software shall track subscription state (active, pending, rejected, expired) for each eventgroup. **Rationale**: Subscription state tracking enables applications to know their subscription status. **Code Location**: ``src/sd/sd_message.cpp`` (flags, reserved bytes) .. requirement:: SD Service Registry Management :id: REQ_SD_303 :satisfies: feat_req_someipsd_784, feat_req_someipsd_785, feat_req_someipsd_786, feat_req_someipsd_787, feat_req_someipsd_788 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Register 3 services, verify registry contains 3 entries. Unregister 1, verify registry contains 2. The software shall maintain a service registry with service entries, supporting add, remove, update TTL, and lookup operations. **Rationale**: The service registry provides a central lookup for available services. **Code Location**: ``src/sd/sd_message.cpp`` (entries_array serialization) SD Shutdown and Recovery ======================== .. requirement:: SD Graceful Shutdown :id: REQ_SD_310 :satisfies: feat_req_someipsd_818, feat_req_someipsd_819, feat_req_someipsd_822, feat_req_someipsd_823, feat_req_someipsd_824 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Configure reserved eventgroup handling, attempt subscription to reserved ID, verify rejection. The software shall implement graceful shutdown by sending StopOfferService for all offered services and StopSubscribe for all active subscriptions. **Rationale**: Mandatory features define the minimum required SD implementation. **Code Location**: ``include/sd/sd_types.h``, ``src/sd/sd_message.cpp`` .. requirement:: SD Reboot Recovery :id: REQ_SD_311 :satisfies: feat_req_someipsd_871, feat_req_someipsd_793, feat_req_someipsd_794 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Simulate server reboot (session ID reset + reboot flag), verify client clears cached offers and re-triggers FindService. The software shall recover from remote reboot by clearing cached services and re-subscribing to previously subscribed eventgroups. **Rationale**: Reserved identifier handling at SD level ensures system integrity. **Code Location**: ``src/sd/sd_client.cpp`` (find_service entry construction) .. requirement:: SD Service Stop Handling :id: REQ_SD_312 :satisfies: feat_req_someipsd_831, feat_req_someipsd_832, feat_req_someipsd_834 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server calls stop_service(), verify StopOffer (TTL=0) is sent and service is removed from local registry. The software shall handle service stop events by cleaning up subscriptions and notifying affected clients. **Rationale**: Proper handling of reserved IDs prevents undefined behavior in SD processing. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service entry construction) SD Non-SOME/IP Protocol Support =============================== .. requirement:: SD Non-SOME/IP Service Announcement :id: REQ_SD_320 :satisfies: feat_req_someipsd_497, feat_req_someipsd_498, feat_req_someipsd_499, feat_req_someipsd_500, feat_req_someipsd_501, feat_req_someipsd_502, feat_req_someipsd_503 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Parse SD message flags, verify reboot_flag and unicast_flag extraction. Verify session_id increments. The software shall support announcing non-SOME/IP services using Service ID 0xFFFE with the appropriate configuration. **Rationale**: Flag processing controls SD response addressing behavior. **Code Location**: ``src/sd/sd_message.cpp`` (flags, session_id, reboot_flag) SD Initial Event Handling ========================= .. requirement:: SD Initial Event Sending :id: REQ_SD_330 :satisfies: feat_req_someipsd_833, feat_req_someipsd_1166, feat_req_someipsd_1167, feat_req_someipsd_1168 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server processes multiple concurrent subscriptions, verify each receives independent ACK/NACK. The software shall send initial events of fields via unicast to newly subscribed clients after sending SubscribeEventgroupAck. **Rationale**: Version-aware subscription ensures clients receive compatible events. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Initial Event Requesting :id: REQ_SD_331 :satisfies: feat_req_someipsd_1191, feat_req_someipsd_1192, feat_req_someipsd_1193, feat_req_someipsd_946 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server ACKs subscription with initial event flag, verify initial field values are sent via unicast to subscriber. The software shall request initial events after reboot or when no active subscription exists for the eventgroup. **Rationale**: Version-aware workflows ensure client-server compatibility. **Code Location**: ``src/sd/sd_client.cpp`` (subscribe_eventgroup entry construction) SD Advanced Features ==================== .. requirement:: SD Error Handling :id: REQ_SD_340 :satisfies: feat_req_someipsd_1162, feat_req_someipsd_1164, feat_req_someipsd_1221, feat_req_someipsd_1227, feat_req_someipsd_1228 :status: implemented :priority: high :category: error_path :verification: Unit test: Load SD configuration (delays, timeouts, TTLs), verify all parameters are applied to SD behavior. The software shall implement SD error handling by checking message headers, entry fields, and option validity. Invalid messages shall be silently discarded. **Rationale**: Configurable parameters enable deployment-specific SD behavior tuning. **Code Location**: ``include/sd/sd_types.h`` (SdConfig) .. requirement:: SD Option Conflict Resolution :id: REQ_SD_341 :satisfies: feat_req_someipsd_1140, feat_req_someipsd_1147, feat_req_someipsd_1149 :status: implemented :priority: medium :category: error_path :verification: Unit test: Receive two options for same entry with conflicting data, verify the later option takes precedence (or error logged). The software shall resolve option conflicts by using the first valid option and ignoring subsequent conflicting options. **Rationale**: Phase timing configuration controls SD protocol behavior. **Code Location**: ``src/sd/sd_server.cpp`` (multicast_port config), ``include/sd/sd_types.h`` .. requirement:: SD Security Considerations :id: REQ_SD_342 :satisfies: feat_req_someipsd_1176, feat_req_someipsd_1177, feat_req_someipsd_1178, feat_req_someipsd_1179, feat_req_someipsd_1180, feat_req_someipsd_1182, feat_req_someipsd_1184 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Verify SD rejects SD messages from unauthorized sources when security mode is enabled. The software shall implement SD security measures including message validation, source address verification, and rate limiting. **Rationale**: SD timing configuration enables adaptation to different network environments. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD IPv4 SD Endpoint Processing :id: REQ_SD_343 :satisfies: feat_req_someipsd_1151, feat_req_someipsd_1152, feat_req_someipsd_1153, feat_req_someipsd_1154, feat_req_someipsd_1155, feat_req_someipsd_1156 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Parse IPv4 SD EndpointOption (type=0x24), verify SD endpoint fields are extracted and not referenced by entries. The software shall process IPv4 SD Endpoint Options when present, using them instead of the source IP/port for SD communication. **Rationale**: TTL configuration controls service and subscription expiry timing. **Code Location**: ``src/sd/sd_server.cpp`` (subscription TTL handling) .. requirement:: SD Mandatory Feature Set :id: REQ_SD_344 :satisfies: feat_req_someipsd_1248, feat_req_someipsd_1249, feat_req_someipsd_1250, feat_req_someipsd_1251, feat_req_someipsd_1252, feat_req_someipsd_1253 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Verify all mandatory SD features (Offer, Find, Subscribe, ACK, NACK, TTL, reboot detection) are functional. The software shall implement the mandatory SD feature set including FindService, OfferService, SubscribeEventgroup, and their acknowledgments. **Rationale**: Multicast configuration specifies the network parameters for SD communication. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` (TTL management) .. requirement:: SD Unicast Flag Processing :id: REQ_SD_345 :satisfies: feat_req_someipsd_1187, feat_req_someipsd_1188 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Receive FindService with Unicast Flag=1, verify response is sent via unicast. Test Flag=0, verify multicast. The software shall process the Unicast Flag in SD messages to determine the response transport (unicast vs multicast). **Rationale**: SD port configuration ensures correct network resource allocation. **Code Location**: ``src/sd/sd_server.cpp`` (handle_eventgroup_subscription_request) .. requirement:: SD Service State Machine Details :id: REQ_SD_346 :satisfies: feat_req_someipsd_624, feat_req_someipsd_631, feat_req_someipsd_684, feat_req_someipsd_691 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Verify SD server state machine transitions: DOWN→INITIAL_WAIT→REPETITION→MAIN→DOWN with correct entries at each phase. The software shall implement detailed service state machine behavior including proper handling of Find/Offer cycles and timer management. **Rationale**: Port assignment rules prevent conflicts with reserved system ports. **Code Location**: ``src/sd/sd_client.cpp`` (process_offer_entry endpoint extraction) .. requirement:: SD Subscription Renewal :id: REQ_SD_347 :satisfies: feat_req_someipsd_839, feat_req_someipsd_840, feat_req_someipsd_841, feat_req_someipsd_842, feat_req_someipsd_843 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Subscribe with TTL=60s, verify renewal at 80% (48s). Verify no renewal if TTL=0xFFFFFF (max). The software shall implement the soft-state model where entries (services, subscriptions) expire unless refreshed. Subscription renewal shall occur before TTL expiry. **Rationale**: Configurable ports enable deployment flexibility. **Code Location**: ``src/sd/sd_server.cpp`` (offer_service, service registration) .. requirement:: SD Publish/Subscribe Event Flow :id: REQ_SD_348 :satisfies: feat_req_someipsd_836, feat_req_someipsd_837, feat_req_someipsd_838, feat_req_someipsd_1239 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Full pub/sub flow: server offers → client subscribes → ACK → event published → subscriber receives notification. The software shall implement the publish/subscribe event flow including link loss handling at both client and server sides. **Rationale**: Consistent port usage ensures clients can reach services at expected endpoints. **Code Location**: ``src/sd/sd_client.cpp`` (find_service, process_offer_entry) .. requirement:: SD Duplicate Offer Handling :id: REQ_SD_349 :satisfies: feat_req_someipsd_844, feat_req_someipsd_848, feat_req_someipsd_849, feat_req_someipsd_850, feat_req_someipsd_851 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Receive same OfferService twice, verify only one entry in registry. Verify TTL is refreshed from second offer. The software shall handle duplicate OfferService messages by updating the existing entry rather than creating duplicates. **Rationale**: Port validation prevents misconfiguration that could disrupt communication. **Code Location**: ``src/sd/sd_server.cpp`` (shutdown, send_stop_offer_messages) .. requirement:: SD Entry Aggregation :id: REQ_SD_350 :satisfies: feat_req_someipsd_852, feat_req_someipsd_853, feat_req_someipsd_854, feat_req_someipsd_855, feat_req_someipsd_856 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server detects client reboot via session ID reset, verify existing subscriptions for that client are cleared. The software shall aggregate multiple SD entries into single messages when possible to reduce network traffic. **Rationale**: Reboot detection triggers re-subscription to restore event delivery. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Startup Behavior :id: REQ_SD_351 :satisfies: feat_req_someipsd_857, feat_req_someipsd_858, feat_req_someipsd_862, feat_req_someipsd_864 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Start SD module, verify initial FindService is sent after configured delay (not immediately). The software shall implement the SD startup behavior with three phases (Initial Wait, Repetition, Main) as per the specification. **Rationale**: Delayed startup prevents SD storms when multiple ECUs boot simultaneously. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Advanced Reboot Detection :id: REQ_SD_352 :satisfies: feat_req_someipsd_796, feat_req_someipsd_797, feat_req_someipsd_798 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Simulate endpoint reboot (reboot flag + session ID reset), verify complete re-subscription lifecycle. The software shall implement advanced reboot detection using Session ID regression and Reboot Flag analysis. **Rationale**: Advanced reboot detection covers complex restart scenarios. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Service Timeout Handling :id: REQ_SD_353 :satisfies: feat_req_someipsd_790, feat_req_someipsd_791 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Offer service with TTL=10, verify client marks service as UNAVAILABLE after 10 seconds with no renewal. The software shall handle service timeouts by removing expired services and notifying applications of unavailability. **Rationale**: Service timeout handling cleans up services that stop offering without explicit StopOffer. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: SD Subscribe Multicast Handling :id: REQ_SD_354 :satisfies: feat_req_someipsd_747, feat_req_someipsd_1134, feat_req_someipsd_1136, feat_req_someipsd_1137 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Subscribe to multicast eventgroup, receive ACK with multicast option, verify client joins multicast group. The software shall handle multicast in subscriptions including Multicast Option in SubscribeEventgroupAck and SubscribeEventgroupNack for conflicting multicast endpoints. **Rationale**: Multicast subscription handling enables efficient event delivery to groups. **Code Location**: ``src/sd/sd_server.cpp`` (subscription acknowledgment, initial events) .. requirement:: SD Subscription Server State :id: REQ_SD_355 :satisfies: feat_req_someipsd_877, feat_req_someipsd_878, feat_req_someipsd_879 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Server tracks subscription state per eventgroup per client, verify state transitions: PENDING→ACTIVE on ACK, ACTIVE→EXPIRED on TTL. The software shall maintain server-side subscription state including client lists per eventgroup and proper cleanup on StopSubscribe. **Rationale**: Per-client subscription state enables correct per-subscriber event delivery decisions. **Code Location**: ``include/sd/sd_types.h``, ``src/sd/sd_message.cpp`` .. requirement:: SD Service Registration :id: REQ_SD_356 :satisfies: feat_req_someipsd_1194, feat_req_someipsd_1195, feat_req_someipsd_1262, feat_req_someipsd_1297 :status: implemented :priority: medium :category: happy_path :verification: Unit test: Configure SD timing parameters, verify initial_delay, repetition_base, and cyclic_offer_delay are applied. The software shall support service registration and deregistration with proper cleanup of associated subscriptions and endpoints. **Rationale**: SD timing parameters control the behavior of all SD protocol phases. **Code Location**: ``include/sd/sd_types.h`` (SdConfig), ``src/sd/sd_server.cpp`` .. requirement:: Error - SD Message Too Short :id: REQ_SD_001_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Receive SD message with total length < 20 bytes (header + flags + lengths), verify rejection. The software shall reject SD messages shorter than the minimum valid SD message size. **Rationale**: Short SD messages cannot contain valid flags and length fields. **Error Handling**: Discard message, log actual vs minimum expected size. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD Entries Length Mismatch :id: REQ_SD_001_E02 :status: implemented :priority: high :category: error_path :verification: Unit test: Construct SD message where entries length field exceeds remaining buffer, verify rejection. The software shall reject SD messages where the entries array length exceeds the remaining message data. **Rationale**: Length mismatch prevents correct entry parsing. **Error Handling**: Discard message, log declared vs available length. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD Option Index Out of Range :id: REQ_SD_120_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Construct entry referencing option index 10 in a message with only 3 options, verify entry is skipped. The software shall skip entries that reference option indices beyond the options array. **Rationale**: Out-of-range option indices indicate malformed SD messages. **Error Handling**: Skip entry, continue processing remaining entries, log error. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD Unknown Entry Type :id: REQ_SD_119_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Construct SD message with entry type=0xFF (undefined), verify entry is skipped and remaining entries processed. The software shall skip SD entries with unknown entry type codes. **Rationale**: Unknown entry types may appear in messages from newer SD implementations. **Error Handling**: Skip entry, log unknown type code, continue processing. **Code Location**: ``src/sd/sd_server.cpp``, ``src/sd/sd_client.cpp`` .. requirement:: Error - SD TTL Overflow Prevention :id: REQ_SD_222_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Receive OfferService with TTL=0xFFFFFF (max), verify TTL timer does not overflow. The software shall handle maximum TTL values without timer overflow. **Rationale**: Maximum TTL values must be handled safely without arithmetic overflow. **Error Handling**: Clamp TTL to implementation maximum if necessary, log clamping. **Code Location**: ``src/sd/sd_client.cpp``, ``src/sd/sd_server.cpp`` .. requirement:: Error - SD Subscription to Unavailable Service :id: REQ_SD_116_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Client sends SubscribeEventgroup for a service that has not been offered, verify NACK response. The software shall NACK subscriptions for services that are not currently offered. **Rationale**: Subscriptions to unavailable services cannot be fulfilled. **Error Handling**: Send NACK (TTL=0), log rejected subscription details. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Error - SD Offer with Invalid Endpoint :id: REQ_SD_115_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Receive OfferService with IPv4EndpointOption containing IP=0.0.0.0, verify offer is ignored. The software shall ignore OfferService messages with invalid endpoint addresses. **Rationale**: Invalid endpoints cannot be used for communication. **Error Handling**: Discard offer, log invalid endpoint address. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Error - SD Duplicate Offer Handling :id: REQ_SD_115_E02 :status: implemented :priority: low :category: error_path :verification: Unit test: Receive same OfferService twice (same Service ID, Instance ID, endpoint), verify TTL is refreshed without duplication. The software shall handle duplicate offers by refreshing the TTL without creating duplicate registry entries. **Rationale**: Duplicate offers are normal during the repetition phase. **Error Handling**: Refresh TTL of existing entry, no new entry created. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Error - SD Multicast Send Failure :id: REQ_SD_134_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Simulate multicast send failure, verify SD falls back to unicast or retries. The software shall handle multicast send failures gracefully. **Rationale**: Multicast may fail due to network configuration issues. **Error Handling**: Log error, retry or fall back to unicast based on configuration. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Error - SD Session ID Non-Incremental :id: REQ_SD_010_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Receive SD messages with session IDs 5, 3 (non-incremental), verify reboot detection logic is triggered. The software shall detect non-incremental SD session IDs as potential reboot indicators. **Rationale**: Session ID regression indicates the sender has restarted. **Error Handling**: Trigger reboot detection, clear cached state for sender. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Error - SD Entry References No Options :id: REQ_SD_030_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Parse OfferService entry with num_opts_1=0 and num_opts_2=0, verify offer is accepted but no endpoint is extracted. The software shall handle SD entries that reference zero options gracefully. **Rationale**: Entries without options are valid but may limit functionality. **Error Handling**: Process entry, log warning if endpoint info is missing. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD Subscription Conflict :id: REQ_SD_080_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Client subscribes to eventgroup from two different endpoints simultaneously, verify server handles both or rejects the second. The software shall handle conflicting subscriptions from the same client to the same eventgroup. **Rationale**: Duplicate subscriptions may indicate configuration errors. **Error Handling**: Accept latest subscription, log conflict. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Error - SD Offer Without Endpoint Option :id: REQ_SD_060_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Receive OfferService with no IPv4EndpointOption attached, verify offer is stored but communication is not attempted. The software shall handle OfferService messages without endpoint options by storing the offer but not attempting communication. **Rationale**: Offers without endpoints may be followed by separate endpoint announcements. **Error Handling**: Store offer, log warning about missing endpoint. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Error - SD Options Array Too Large :id: REQ_SD_021_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Receive SD message with options_length > remaining message size, verify message is rejected. The software shall reject SD messages where the options array length exceeds the remaining message data. **Rationale**: Prevents buffer overread from malformed SD messages. **Error Handling**: Discard entire message, log length mismatch. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD FindService Timeout :id: REQ_SD_070_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Send FindService, wait for configured discovery timeout (e.g., 30s), verify timeout is reported to application. The software shall report a timeout when no OfferService response is received within the configured discovery period. **Rationale**: Discovery timeout enables the application to handle unavailable services. **Error Handling**: Invoke discovery timeout callback. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Error - SD Malformed Option Length :id: REQ_SD_050_E01 :status: implemented :priority: high :category: error_path :verification: Unit test: Parse IPv4EndpointOption with declared length=5 (should be 9), verify option is rejected. The software shall reject SD options whose declared length does not match the expected length for the option type. **Rationale**: Length mismatches indicate malformed or truncated options. **Error Handling**: Skip option, log expected vs actual length. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD Reserved Flags :id: REQ_SD_010_E02 :status: implemented :priority: low :category: error_path :verification: Unit test: Parse SD flags byte with reserved bits set (e.g., 0b00111111), verify reserved bits are ignored. The software shall ignore reserved bits in the SD flags byte for forward compatibility. **Rationale**: Reserved bits may be defined in future SD versions. **Error Handling**: Ignore reserved bits, process known flags normally. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD TTL Zero in Offer :id: REQ_SD_060_E02 :status: implemented :priority: high :category: error_path :verification: Unit test: Receive OfferService with TTL=0, verify it is treated as StopOffer and service is marked unavailable. The software shall treat OfferService entries with TTL=0 as StopOffer messages. **Rationale**: TTL=0 signals immediate unavailability regardless of entry type. **Error Handling**: Remove service from registry, notify application. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Error - SD Entry With Invalid TTL Format :id: REQ_SD_044_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Parse entry with TTL bytes that are not aligned to the 24-bit field boundary, verify correct extraction. The software shall correctly extract the 24-bit TTL field from the 3-byte packed format. **Rationale**: TTL is a 24-bit field packed across bytes, requiring careful extraction. **Error Handling**: Validate TTL extraction against known test vectors. **Code Location**: ``src/sd/sd_message.cpp`` .. requirement:: Error - SD Multiple Subscriptions Same Client :id: REQ_SD_083_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Client subscribes to same eventgroup 3 times, verify only one active subscription exists and TTL is refreshed. The software shall coalesce duplicate subscriptions from the same client into a single subscription with refreshed TTL. **Rationale**: Duplicate subscriptions waste server resources. **Error Handling**: Refresh TTL of existing subscription. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Error - SD Server Offers During Shutdown :id: REQ_SD_113_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Initiate shutdown, attempt new offer_service(), verify it is rejected with NOT_READY error. The software shall reject new service offers during the shutdown phase. **Rationale**: Offering services during shutdown creates inconsistent state. **Error Handling**: Return NOT_READY error. **Code Location**: ``src/sd/sd_server.cpp`` .. requirement:: Error - SD ACK Timeout :id: REQ_SD_116_E02 :status: implemented :priority: medium :category: error_path :verification: Unit test: Subscribe to eventgroup, wait for ACK timeout, verify subscription state transitions to TIMEOUT. The software shall handle subscription ACK timeouts by transitioning the subscription state. **Rationale**: ACK timeout indicates the server may be unreachable. **Error Handling**: Transition to TIMEOUT state, retry or notify application. **Code Location**: ``src/sd/sd_client.cpp`` .. requirement:: Error - SD Invalid Multicast Address in Option :id: REQ_SD_123_E01 :status: implemented :priority: medium :category: error_path :verification: Unit test: Parse IPv4MulticastOption with unicast address 10.0.0.1 (not multicast), verify option is rejected. The software shall reject multicast options containing non-multicast addresses. **Rationale**: Non-multicast addresses in multicast options indicate malformed messages. **Error Handling**: Reject option, log invalid address. **Code Location**: ``src/sd/sd_message.cpp`` Traceability ============ Implementation Files -------------------- * ``include/sd/sd_types.h`` - SD type definitions * ``include/sd/sd_message.h`` - SD message interface * ``include/sd/sd_client.h`` - SD client interface * ``include/sd/sd_server.h`` - SD server interface * ``src/sd/sd_message.cpp`` - SD message implementation * ``src/sd/sd_client.cpp`` - SD client implementation * ``src/sd/sd_server.cpp`` - SD server implementation Test Files ---------- * ``tests/test_sd.cpp`` - SD unit tests