Hi,@DTS Engineer
After our last discussion, I dedicated significant time and effort to implementing the withPoolAndServiceClass()method and testing application-level packet transmission using NWParameters.ServiceClass to specify QoS.
Implementation of withPoolAndServiceClass()
I attempted to implement withPoolAndServiceClass() as follows:
QueryFreeSpaceAction TxQ0QueryFreeSpaceAction = My_QueryFreeSpaceAction
DequeueAction TxQ0DequeueAction = My_DequeueAction;
ret = IODispatchQueue::Create("NetworkTxSubmission", 0, 0, &ivars->queueDispatch[2]);
Require(kIOReturnSuccess == ret, Failed);
ret = CreateActionTxPacketAvailable(0, &ivars->txPacketAction);
Require(kIOReturnSuccess == ret, Failed);
ret = IOUserNetworkTxSubmissionQueue::Create(ivars->txNetworkPool,this,8,kNetworkQueueIdTxSubmission, ivars->queueDispatch[2],&ivars->queueTxSubmission);
Require(kIOReturnSuccess == ret, Failed);
IOUserNetworkTxSubmissionQueue::withPoolAndServiceClass(ivars->txNetworkPool, kIOUserNetworkPacketServiceClassBE,8,0, this, TxQ0QueryFreeSpaceAction, TxQ0DequeueAction);
ret = ivars->queueTxSubmission->CopyDataQueue(&ivars->dataDispatch[2]);
Require(kIOReturnSuccess == ret, Failed);
My objective is to use withPoolAndServiceClass() to allocate packets from the pool based on a specific service class and assign them to a designated queue ID for transmission.
**
Could you confirm whether this implementation correctly achieves that functionality? If not, could you provide corrections and sample code?**
Testing NWParameters.ServiceClass for QoS Marking
Assuming my withPoolAndServiceClass() implementation is correct, I designed a simple socket client that sets different NWParameters.ServiceClass values (.interactiveVideo, .responsiveData, .background, .bestEffort, .interactiveVoice, .signaling) to verify whether it triggers the DequeueAction function and correctly transmits packets with the expected QoS markings.
However, upon inspecting the IPv4 TOS (Type of Service) field using Wireshark and tcpdump (tcpdump -i -v), I observed that regardless of the ServiceClass setting, the transmitted packets always have a TOS value of 0x00. Furthermore, withPoolAndServiceClass() does not seem to invoke the DequeueAction function.
I attempted to implement application-level packet transmission as follows:
func getQoSClass(from input: String) -> NWParameters.ServiceClass
{
switch input.lowercased() {
case "interactive":
return .interactiveVideo
case "responsive":
return .responsiveData
case "background":
return .background
case "besteffort":
return .bestEffort
case "interactiveVoice":
return .interactiveVoice
case "signaling":
return .signaling
default:
print("⚠️ 無效的 QoS,預設使用 `.responsiveData`")
return .responsiveData
}
}
Could you help identify any misunderstandings in my approach that might be causing this issue? Specifically:
• Are there additional configurations needed for NWParameters.ServiceClass to ensure that packets are transmitted with the expected QoS values?
• How can I verify whether withPoolAndServiceClass() is correctly handling packets according to the specified service class?
Since Apple's ConnectingANetworkDriver sample code does not reference or implement withPoolAndServiceClass(), I need further guidance on its correct usage.
Thank you for your assistance.
Best regards,