yueweng
2005-05-04 01:54:30 UTC
Dear all,
Does anyone knows how to Qos DiffServ in the IP header to Expedite
Forwarding (EF) level for win2000 and WinXp. I have tried to use Qos Api but
I can only set to maximum of Class Selector 5 under WinXp and Assured
Forwarding using the below Qos Api code. Does anyone have any clue how to
set to EF level? Actually, I am interested to use Winsock2 interface to
achive it in UDP protocol.
FLOWSPEC default_notraffic =
{
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
SERVICETYPE_NOTRAFFIC,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED
};
FLOWSPEC default_g711 =
{
8500,
680,
17000,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
SERVICETYPE_GUARANTEED,
340,
340
};
SOCKET OpenQoSSocket(INT iSocketType)
{
DWORD bufferSize = 0;
DWORD numProtocols, i;
LPWSAPROTOCOL_INFO installedProtocols, qosProtocol;
SOCKET fd;
//
// Call WSAEnumProtocols to determine buffer size required
//
numProtocols = WSAEnumProtocols(NULL, NULL, &bufferSize);
if((numProtocols != SOCKET_ERROR) && (WSAGetLastError() != WSAENOBUFS))
{
dbgprintf ( "WSAEnumProtocols Failed", WSAGetLastError() );
return(INVALID_SOCKET);
}
else
{
//
// Allocate a buffer to hold the list of protocol info structures
//
installedProtocols = (LPWSAPROTOCOL_INFO)malloc(bufferSize);
//
// Enumerate the protocols, find the QoS enabled one
//
numProtocols = WSAEnumProtocols(NULL,
installedProtocols,
&bufferSize);
if(numProtocols == SOCKET_ERROR){
dbgprintf ( "WSAEnumProtocols Failed", WSAGetLastError() );
return(INVALID_SOCKET);
}
else
{
qosProtocol = installedProtocols;
for( i=0 ; i < numProtocols ; qosProtocol++, i++)
{
if ((qosProtocol->dwServiceFlags1 & XP1_QOS_SUPPORTED) &&
(qosProtocol->iSocketType == iSocketType) &&
(qosProtocol->iAddressFamily == AF_INET))
{
break;
}
}
}
//
// Now open the socket.
//
fd = WSASocket(0,
iSocketType,
0,
qosProtocol, // Use the QoS SP we found
0,
WSA_FLAG_OVERLAPPED); // *MUST* be overlapped!
//
// De-allocate protocol info buffer
//
free(installedProtocols);
return(fd);
}
}
BOOL SetQoS (SOCKET s, INT iSocketType, SOCKADDR_IN *remoteaddr)
{
QOS Qos;
int result ;
DWORD BytesRet;
memset ( &Qos, QOS_NOT_SPECIFIED, sizeof(QOS) );
Qos.SendingFlowspec = default_g711;
Qos.ReceivingFlowspec = default_notraffic;
QOS_DESTADDR QosDestaddr;
ZeroMemory((char *)&QosDestaddr, sizeof(QosDestaddr));
QosDestaddr.ObjectHdr.ObjectType = QOS_OBJECT_DESTADDR;
QosDestaddr.ObjectHdr.ObjectLength = sizeof(QosDestaddr);
QosDestaddr.SocketAddress = (SOCKADDR *)remoteaddr;
QosDestaddr.SocketAddressLength = sizeof(SOCKADDR);
Qos.ProviderSpecific.len = QosDestaddr.ObjectHdr.ObjectLength;
Qos.ProviderSpecific.buf = (char *)&QosDestaddr;
result = WSAIoctl(s,SIO_SET_QOS, &Qos,sizeof(QOS),NULL, 0,&BytesRet,
NULL,NULL);
if (result == SOCKET_ERROR)
{
dbgprintf ("SetQoS Error %d\n", GetLastError());
return FALSE;
}
return TRUE;
}
Thanks for any help in advanced!
YueWeng
3-May-2005
***@_@yahoo.com
(Please remove the @_ the prevent spammer from scanning)
Does anyone knows how to Qos DiffServ in the IP header to Expedite
Forwarding (EF) level for win2000 and WinXp. I have tried to use Qos Api but
I can only set to maximum of Class Selector 5 under WinXp and Assured
Forwarding using the below Qos Api code. Does anyone have any clue how to
set to EF level? Actually, I am interested to use Winsock2 interface to
achive it in UDP protocol.
FLOWSPEC default_notraffic =
{
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
SERVICETYPE_NOTRAFFIC,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED
};
FLOWSPEC default_g711 =
{
8500,
680,
17000,
QOS_NOT_SPECIFIED,
QOS_NOT_SPECIFIED,
SERVICETYPE_GUARANTEED,
340,
340
};
SOCKET OpenQoSSocket(INT iSocketType)
{
DWORD bufferSize = 0;
DWORD numProtocols, i;
LPWSAPROTOCOL_INFO installedProtocols, qosProtocol;
SOCKET fd;
//
// Call WSAEnumProtocols to determine buffer size required
//
numProtocols = WSAEnumProtocols(NULL, NULL, &bufferSize);
if((numProtocols != SOCKET_ERROR) && (WSAGetLastError() != WSAENOBUFS))
{
dbgprintf ( "WSAEnumProtocols Failed", WSAGetLastError() );
return(INVALID_SOCKET);
}
else
{
//
// Allocate a buffer to hold the list of protocol info structures
//
installedProtocols = (LPWSAPROTOCOL_INFO)malloc(bufferSize);
//
// Enumerate the protocols, find the QoS enabled one
//
numProtocols = WSAEnumProtocols(NULL,
installedProtocols,
&bufferSize);
if(numProtocols == SOCKET_ERROR){
dbgprintf ( "WSAEnumProtocols Failed", WSAGetLastError() );
return(INVALID_SOCKET);
}
else
{
qosProtocol = installedProtocols;
for( i=0 ; i < numProtocols ; qosProtocol++, i++)
{
if ((qosProtocol->dwServiceFlags1 & XP1_QOS_SUPPORTED) &&
(qosProtocol->iSocketType == iSocketType) &&
(qosProtocol->iAddressFamily == AF_INET))
{
break;
}
}
}
//
// Now open the socket.
//
fd = WSASocket(0,
iSocketType,
0,
qosProtocol, // Use the QoS SP we found
0,
WSA_FLAG_OVERLAPPED); // *MUST* be overlapped!
//
// De-allocate protocol info buffer
//
free(installedProtocols);
return(fd);
}
}
BOOL SetQoS (SOCKET s, INT iSocketType, SOCKADDR_IN *remoteaddr)
{
QOS Qos;
int result ;
DWORD BytesRet;
memset ( &Qos, QOS_NOT_SPECIFIED, sizeof(QOS) );
Qos.SendingFlowspec = default_g711;
Qos.ReceivingFlowspec = default_notraffic;
QOS_DESTADDR QosDestaddr;
ZeroMemory((char *)&QosDestaddr, sizeof(QosDestaddr));
QosDestaddr.ObjectHdr.ObjectType = QOS_OBJECT_DESTADDR;
QosDestaddr.ObjectHdr.ObjectLength = sizeof(QosDestaddr);
QosDestaddr.SocketAddress = (SOCKADDR *)remoteaddr;
QosDestaddr.SocketAddressLength = sizeof(SOCKADDR);
Qos.ProviderSpecific.len = QosDestaddr.ObjectHdr.ObjectLength;
Qos.ProviderSpecific.buf = (char *)&QosDestaddr;
result = WSAIoctl(s,SIO_SET_QOS, &Qos,sizeof(QOS),NULL, 0,&BytesRet,
NULL,NULL);
if (result == SOCKET_ERROR)
{
dbgprintf ("SetQoS Error %d\n", GetLastError());
return FALSE;
}
return TRUE;
}
Thanks for any help in advanced!
YueWeng
3-May-2005
***@_@yahoo.com
(Please remove the @_ the prevent spammer from scanning)