Minimum cost
Used when it is important to minimize the cost of data transmission. Leasing bandwidth on a satellite for a transpacific crossing is generally less costly than leasing space on a fiber-optical cable over the same distance, so network providers may choose to provide both and charge differently depending on which you use. In this scenario, your 'minimum cost' type of service bit may cause your datagrams to be routed via the lower-cost satellite route.
Setting the TOS Bits Using ipfwadm or ipchains
The ipfwadm and ipchains commands deal with the TOS bits in much the same manner. In both cases you specify a rule that matches the datagrams with particular TOS bits set, and use the
The changes are specified using two-bit masks. The first of these bit masks is logically ANDed with the IP options field of the datagram and the second is logically eXclusive-ORd with it. If this sounds complicated, we'll give you the recipes required to enable each of the types of service in a moment.
The bit masks are specified using eight-bit hexadecimal values. Both ipfwadm and ipchains use the same argument syntax:
- t
Fortunately the same mask arguments can be used each time you wish to set a particular type of service, to save you having to work them out. They are presented with some suggested uses in Table 9.3.
Table 9.3: Suggested Uses for TOS Bitmasks
| TOS | ANDmask | XORmask | Suggested Use |
|---|---|---|---|
| Minimum Delay | 0x01 | 0x10 | ftp, telnet, ssh |
| Maximum Throughput | 0x01 | 0x08 | ftp-data, www |
| Maximum Reliability | 0x01 | 0x04 | snmp, dns |
| Minimum Cost | 0x01 | 0x02 | nntp, smtp |
Setting the TOS Bits Using iptables
The iptables tool allows you to specify rules that capture only datagrams with TOS bits matching some predetermined value using the
Rather than the complicated two-mask configuration of ipfwadm and ipchains, iptables uses the simpler approach of plainly specifying what the TOS bits should match, or to what the TOS bits should be set. Additionally, rather than having to remember and use the hexadecimal value, you may specify the TOS bits using the more friendly mnemonics listed in the upcoming table.
The general syntax used to match TOS bits looks like:
- m tos -tos
The general syntax used to set TOS bits looks like:
[
Remember that these would typically be used together, but they can be used quite independently if you have a configuration that requires it.
| Mnemonic | Hexadecimal |
|---|---|
| Normal-Service | 0x00 |
| Minimize-Cost | 0x02 |
| Maximize-Reliability | 0x04 |
| Maximize-Throughput | 0x08 |
