IP_TOS

Set IP header TOS field

Synopsis:
CALL IP_TOS value$ TO [status], [oldvalue$]
'ip_tos( value$, [status], [oldvalue$] )
ArgumentEnumerationPurpose
value$Value to set TOS field to
statusKDB_ERROR_ENUMReturn status
oldvalue$old value of TOS field
>IP_TOS

IP_TOS

This function allows you to manipulate the Type of Service (TOS) field in Internet Protocol (IP) headers of all outgoing packets for the current KCML session. Input must be a single byte string or "" to signify you just wish to return the previous value.

This is useful when providing Quality of Service (QoS). The example below show how the TOS field is used in modern applications. It can be used to implement Differentiated Services Code Point (DSCP). The DSCP is a selector for router's per-hop behaviours.

Note: CALL IP_TOS will only work where KCML is connected directly to a socket. This means a direct connection or one using the Connection Manager. This function will not work with a telnet connection.

Note: Microsoft have removed the ability to set IP header TOS bits from Winsock 2. As a result CALL IP_TOS will always fail under Windows.

For more info on TOS see: For more info on DSCP see:

Example

REM
REM DSCP (Differentiated Services Code Point) Constants
REM See RFC2474 
REM See RFC2697
REM See RFC2598
REM
DIM _DSCP_BestEffort=0
DIM _DSCP_Class1=0x08
DIM _DSCP_Class1_AF11=10
DIM _DSCP_Class1_AF12=12
DIM _DSCP_Class1_AF13=14
DIM _DSCP_Class2=0x10
DIM _DSCP_Class2_AF21=18
DIM _DSCP_Class2_AF22=20
DIM _DSCP_Class2_AF23=22
DIM _DSCP_Class3=0x18
DIM _DSCP_Class3_AF31=26
DIM _DSCP_Class3_AF32=28
DIM _DSCP_Class3_AF34=30
DIM _DSCP_Class4=0x20
DIM _DSCP_Class4_AF41=34
DIM _DSCP_Class4_AF42=36
DIM _DSCP_Class4_AF43=38
DIM _DSCP_Express=0x28
DIM _DSCP_Expedited=0x2e
REM
REM Set DSCP value
REM
REM We can set the IP headers TOS (type of service) field
REM DSCP uses the top six bits of this field
REM
DEFSUB 'SetDSCP(uValue)
  LOCAL DIM a$1
  LOCAL DIM b$1
  LOCAL DIM z$1
  LOCAL DIM eStatus
  REM Shift value into top 6 bits
  z$ = BIN((uValue * 2) * 2)
  REM Get old lower 2 bit value
  CALL IP_TOS "" TO eStatus, b$
  b$ = AND HEX(03)
  REM Combine
  a$ = z$ OR b$
  CALL IP_TOS a$ TO eStatus
END SUB
History
Introduced in KCML 6.20
See Also:
KI_AES_DECRYPT, KI_AES_ENCRYPT, KI_COMP, KI_COMPFILE, KI_CRYPT, KI_DCOMP, KI_DCOMPFILE, KI_DES_DECRYPT, KI_DES_ENCRYPT, KI_DF, KI_DFK, KI_DIR, KI_DIR_LIST, KI_DS, KI_MD5, KI_PID, KI_PMATCH, KI_SHA1, KI_SIZE, KI_STAT, KI_STATFS, KI_TOUCH, R7_DATE2J, R7_J2DATE
KCML database status codes