802.1p DON'T WORK WITH traffic control dll !!!
I enable Qos Packet Scheduller and disable 802.1p support on my NIC.
I don't see the tag .
whereas with the DSCP it works fine.
Can you help me to make it works fine....
thank you
DWORD destPort;
PCHAR destAddress;
destAddress="172.18.100.39"; //IP_ADDRESS;
destPort = 0x1388;//5000;
// Intialization of Winsock API
int err;
WSADATA WSAData;
err = WSAStartup(MAKEWORD(2,2), &WSAData);
if (err) {
printf("WSAStartup Failed (%d) \n", err);
exit(err);
}
HANDLE ClientHandle;
HANDLE ifcHandle;
HANDLE flowHandle;
HANDLE FilterHandle;
// pas besoin mais necessaire pour TcRegisterClient API
TCI_CLIENT_FUNC_LIST QoSFunctions;
QoSFunctions.ClAddFlowCompleteHandler = NULL;
QoSFunctions.ClDeleteFlowCompleteHandler = NULL;
QoSFunctions.ClModifyFlowCompleteHandler = NULL;
QoSFunctions.ClNotifyHandler = (TCI_NOTIFY_HANDLER)MyClNotifyHandler;
// enregistrement d'un client avec Traffic control interface.
long result = TcRegisterClient(CURRENT_TCI_VERSION, NULL, &QoSFunctions , &ClientHandle);
if (result == NO_ERROR) {
printf("no error TcRegisterClient.\n");
TC_IFC_DESCRIPTOR InterfaceBuffer[30];
PTC_IFC_DESCRIPTOR pInterfaceBuffer = &InterfaceBuffer[0];
ULONG BufferSize = 30* sizeof(TC_IFC_DESCRIPTOR);
//Trouver les interfaces actives sur la machine
result = TcEnumerateInterfaces(ClientHandle, &BufferSize,pInterfaceBuffer);
if (result == NO_ERROR) {
printf("no error TcEnumerateInterfaces \n" );
if (BufferSize == 0) {
printf("no traffic control interfaces are available\n");
}
TCHAR interfaceName[500];
// function maps a wide-character string to a new character string
WideCharToMultiByte(CP_ACP,0,InterfaceBuffer[0].pInterfaceName, -1,interfaceName, sizeof(interfaceName), 0, 0 );
int error = GetLastError();
// The TcOpenInterface function identifies et ouvre une interface
result = TcOpenInterface( interfaceName, ClientHandle, NULL, &ifcHandle );
if( result == NO_ERROR ) {
// Creating of Traffic flow headers
printf("no error OpenInterfaces.\n");
int curSize = sizeof (TC_GEN_FLOW )+ sizeof (QOS_TRAFFIC_CLASS) +sizeof(QOS_OBJECT_HDR);
char *bufFlow = new char[curSize];
PTC_GEN_FLOW newFlow = ( PTC_GEN_FLOW )bufFlow;
// Creation d'un nouveau flow.
LPQOS_OBJECT_HDR objHdr = NULL;
newFlow->ReceivingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;
newFlow->ReceivingFlowspec.Latency = QOS_NOT_SPECIFIED;
newFlow->ReceivingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;
newFlow->ReceivingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;
newFlow->ReceivingFlowspec.PeakBandwidth = QOS_NOT_SPECIFIED;
newFlow->ReceivingFlowspec.ServiceType =QOS_NOT_SPECIFIED;
newFlow->ReceivingFlowspec.TokenBucketSize = QOS_NOT_SPECIFIED;
newFlow->ReceivingFlowspec.TokenRate = QOS_NOT_SPECIFIED;
newFlow->SendingFlowspec.DelayVariation = QOS_NOT_SPECIFIED;
newFlow->SendingFlowspec.Latency = QOS_NOT_SPECIFIED;
newFlow->SendingFlowspec.MaxSduSize = QOS_NOT_SPECIFIED;
newFlow->SendingFlowspec.MinimumPolicedSize = QOS_NOT_SPECIFIED;
newFlow->SendingFlowspec.PeakBandwidth = QOS_NOT_SPECIFIED;
newFlow->SendingFlowspec.ServiceType =SERVICETYPE_BESTEFFORT;
newFlow->SendingFlowspec.TokenBucketSize = QOS_NOT_SPECIFIED;
newFlow->SendingFlowspec.TokenRate = QOS_NOT_SPECIFIED;
/****************************802.1p*********************************/
newFlow->TcObjectsLength =sizeof(QOS_TRAFFIC_CLASS)+ sizeof(QOS_OBJECT_HDR);
LPQOS_TRAFFIC_CLASS pTRClass = (LPQOS_TRAFFIC_CLASS)(&(newFlow->TcObjects[0]));
pTRClass->ObjectHdr.ObjectType = QOS_OBJECT_TRAFFIC_CLASS;
pTRClass->ObjectHdr.ObjectLength = sizeof (QOS_TRAFFIC_CLASS);
pTRClass->TrafficClass = 0x5;
objHdr = (LPQOS_OBJECT_HDR)((char *)&(newFlow->TcObjects[0]) + sizeof(QOS_TRAFFIC_CLASS));
// Set the end of the list
objHdr->ObjectType = QOS_OBJECT_END_OF_LIST;
objHdr->ObjectLength = sizeof (QOS_OBJECT_HDR);
/****************************************************************/
//add le nouveau flow à l'interface .
int retCode = TcAddFlow( ifcHandle, /*ClientHandle*/NULL, 0, newFlow, &flowHandle );
if(retCode == NO_ERROR) {
printf("no error TcAddFlow\n");
} else {
printf("TcAddFlow: ERROR: %lu\n",retCode);
//printf("Handle %d\n", (int)IfcHandle);
switch(retCode) {
case ERROR_SIGNAL_PENDING:
printf("The function is being executed asynchronously; the client will be called back through the client-exposed ClAddFlowComplete function when the flow has been added or when the process has been completed..\n");
break;
case ERROR_INVALID_HANDLE:
printf("The interface handle is invalid.\n");
break;
}
return -1;
}
// Creation d'un filtre.
TC_GEN_FILTER GenericFilter;
IP_PATTERN Pattern, Mask;
memset(&Pattern,0,sizeof(IP_PATTERN));
memset(&Mask,0,sizeof(IP_PATTERN));
GenericFilter.AddressType =NDIS_PROTOCOL_ID_TCP_IP ; // Protocol stack is TCP/IP
GenericFilter.PatternSize = sizeof(IP_PATTERN);
GenericFilter.Pattern = &Pattern; // pattern to match, defined below
GenericFilter.Mask = &Mask;
// Filter pattern.
Pattern.Reserved1 = 0;
Pattern.Reserved2 = 0;
Pattern.SrcAddr = 0;//inet_addr("172.18.100.38");
Pattern.DstAddr = 0;//inet_addr("172.18.100.39");
Pattern.tcSrcPort = 0;//htons(0);
Pattern.tcDstPort = 0;//destPort;//htons(destPort);//destPort;
Pattern.ProtocolId = IPPROTO_UDP;
Pattern.Reserved3[0] = 0;
Pattern.Reserved3[1] = 0;
Pattern.Reserved3[2] = 0;
// Patterns mask
Mask.Reserved1 = 0;
Mask.Reserved2 = 0;
Mask.SrcAddr = 0;//htonl(0xFFFFFFFF);
Mask.DstAddr = 0;//htonl(0xFFFFFFFF);
Mask.tcSrcPort = 0;//htons(0);//0xFFFF;
Mask.tcDstPort = 0;//htons(0xFFFF);
Mask.ProtocolId = 0;//0xFF;
Mask.Reserved3[0] = 0;
Mask.Reserved3[1] = 0;
Mask.Reserved3[2] = 0;
/////////////////////////////////////////////////////////////////////////////
// Add filter to the flow. .
retCode = TcAddFilter(flowHandle, &GenericFilter, &FilterHandle);
if(retCode != NO_ERROR) {
printf("TcAddFilter: ERROR: %lu\n",retCode);
switch(retCode) {
case ERROR_INVALID_HANDLE:
printf("The filter handle is invalid.\n");
break;
}
return -1;
} else {
printf("no error TcAddFilter.\n");
}
} else {
switch(result) {
case ERROR_INVALID_PARAMETER:
printf("A parameter is invalid.\n");
break;
case ERROR_NOT_FOUND:
printf("An invalid address type has been provided.\n");
break;
}
printf("TcOpenInterface returned 0x%x\n", result);
return -1;
}
} else {
switch(result) {
case NO_ERROR:
printf("The function executed without errors.\n");
break;
case ERROR_INVALID_HANDLE:
printf("The client handle is invalid.\n");
break;
}
printf("TcEnumerateInterfaces returned 0x%x\n", result);
return -1;
}
} else {
printf("TcRegisterClient returned 0x%x\n", result);
return -1;
}
// Create a normal UDP socket for sending data
SOCKET sd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (sd == INVALID_SOCKET) {
err = GetLastError();
printf("\"Socket\" failed with error %d\n", err);
return 1;
}
SOCKADDR_IN destAddr;
memset (&destAddr, 0, sizeof(SOCKADDR_IN));
destAddr.sin_family = AF_INET;
destAddr.sin_port = htons(0x60);
destAddr.sin_addr.s_addr = inet_addr(destAddress); // this is our test destination IP
bind(sd,(struct sockaddr*)&destAddr,sizeof(destAddr));
int nRet;
nRet = sendto( sd, "TEST QOS DIGICOM 25", 30, 0, (sockaddr*)&destAddr,sizeof(SOCKADDR_IN));
result = TcDeleteFilter(FilterHandle);
if (result != NO_ERROR) {
printf("Error deleting filter\n");
} else {
printf("no error TcDeleteFilter\n");
}
// Delete flow associated with the network interface
result = TcDeleteFlow(flowHandle);
if (result != NO_ERROR) {
printf("Error deleting flow\n");
} else {
printf("no error TcDeleteFlow\n");
}
// Close the Traffic control interface opened earlier.
result = TcCloseInterface(ifcHandle);
if (result != NO_ERROR) {
switch(result) {
case ERROR_INVALID_HANDLE:
printf("The interface handle is invalid.\n");
break;
case ERROR_TC_SUPPORTED_OBJECTS_EXIST:
printf("Not all flows have been deleted for this interface.");
}
printf("Error closing interface\n");
} else {
printf("no error TcCloseInterface\n");
}
// Unregister the client.
result = TcDeregisterClient(ClientHandle);
if (result != NO_ERROR) {
switch(result) {
case ERROR_INVALID_HANDLE:
printf("Invalid interface handle, or the handle was set to NULL.\n");
break;
case ERROR_TC_SUPPORTED_OBJECTS_EXIST:
printf("Interfaces are still open for this client. all interfaces must be closed to deregister a client.\n");
}
printf("Error degresitering client\n");
} else {
printf("no error TcDeregisterClient\n");
}
// shutdown the socket
shutdown(sd, SD_BOTH);
closesocket(sd);
WSACleanup();
return 0;
You specifically said that you *disable* 802.1p in the NIC. You must *enable* 802.1p in the NIC to get packet tagging. The NIC has to support tagging for the tag to get added.
-- Gabe Frost [MSFT]
As I've posted on multiple related threads, I need to know *exactly* how you are validating that the 802.1p tag is not getting added to outgoing frames. What is telling you that the tag is not there? How are you troubleshooting this problem?