Wednesday, October 20, 2004

Packet/MTU Size

Packet size, also referred to as MTU (Maximum Transmission Unit) is the largest amount of data that can be transferred in one physical frame on the network.
Standard MTU Sizes:Ethernet MTU = 1500 bytesPPPoE MTU = 1492 bytesDial-Up MTU = 576 bytes
A packet or "MTU" consists of a header and the actual data. The actual data is referred to as the Maximum Segment Size or "MSS". The MSS is the largest segment of TCP data that can be transmitted. In other words: MTU = MSS + TCPIP headers.
MSS = MTU - (TCP20 + IP20) or MSS = MTU - 40
no packet fragmentation
zero packet loss
zero router congestion
Packet Size vs. Latency

Let's examine a transfer of 1,500,000 bytes of data using different packet size over a T1 line (T1=1,544,000 bits/sec) using the following formula:
( MSS + header ) * 8 bits/byte------------------------------ = latency (per hop)1,544,000 bits/sec.

Then, using different MTU values, we can calculate the relevance of packet size to latency.
If MTU = 1500, then: (1460+40) * 8 / 1,544,000 = 7.772 ms delay per hop If MTU = 576, then: (536+40) * 8 / 1,544,000 = 2.924 ms delay
Assuming a transfer over 10 hops, the 1500 MTU would wield 77.72 ms delay, while a 576 MTU would take 29.24 ms to transfer over a T1 line.
So what are we getting at? Well, it takes more time to send/receive larger packets. DUH!? How much mathematics do we need to understand this?

Of course we also need to look at it this way:
Even though we are receiving the smaller packets and they are transmitting faster, the overall speed in which we receive the TOTAL file will vary. That is the point in changing your MTU.
In some instances, the Total File will be received faster by smaller packet sizes and vice versa. Larger packets will present the Total File to you in certain circumstances.

Throughput vs. Packet Size

Using this formula:
( MSS + header ) * 8 bits/byte------------------------------ = latency (per hop)1,544,000 bits/sec.
Assume we need to transfer 1 MByte file:
1MByte = 1024 KB = 1,048,576 bytes.
If MTU = 1500, then: (1460+40) * 8 / 1,544,000 = 7.772 ms delay per hop
1 MByte / MSS = 1,048,576 bytes / 1460 = 718.2, or effectively 719 packets to transfer 1 MByte.
Then, to transfer 1Mbyte: 719 packets * 7.772 ms delay per hop = 5588.068 ms, or 5.588 seconds per hop.
If we are transferring our 1 MByte file over 10 hops, it will take us 55.88 sec.
If MTU = 576, then: (536+40) * 8 / 1,544,000 = 2.924 ms delay per hop.
1 MByte / MSS = 1,048,576 bytes / 536 = 1956.3, or effectively 1957 packets to transfer 1 MByte.
Then, to transfer 1 MByte: 1957 packets * 2.924 ms delay per hop = 5722.268 ms, or 5.722 seconds per hop.

If we are transferring our 1 MByte file over the same 10 hops, it will take us 57.22 sec.
The difference comes from the fact that when using larger packets the overhead is smaller. To transfer 1 MByte, if using MTU of 1500 there are 719 * 40 = 28,760 bytes of overhead, while if using MTU of 576 1957 * 40 = 78,280 bytes, additional 49,520 bytes of headers transferred each MByte. For our 10-hop transfer, the additional overhead accounts for 1.34 seconds difference in transfer time for every MByte. This difference is a bit higher in practice, considering TCP options and the fact that modern TCP/IP implementations tend to use larger headers (additional 12 bytes header space for Timestamps for example).

Summary

It's logical to assume bigger packets are better, because of all the following factors:
network - reduced number of headers, as illustrated above
routers - less routing decisions
clients - less protocol processing and device interrupts
If throughput is not the goal, smaller packets may be a better selection since they take less time to travel throughout the network. That effect might be preferred in some applications and online gaming, at the expense of throughput.
Ultimately, packet size should be decided based on the type of the desired result, considering the underlying network as well, to avoid negative factors such as fragmentation of packets. Still one has to realize the fact that larger packets will still transmit more useful data than smaller packets, and that there is no single "best" solution for all applications.

(Dial-up) (DSL)
MTU Maximum Transmission Unit 576 1500

MSS Maximum Segment Size
(MTU - 40 bytes
for IP and TCP headers) 536 1460

"RWIN" TCP Receive Window
(Buffer)
or DefaultRcvWindow 8192 32768

Sunday, October 17, 2004

Strengthen security by implementing Network Address Translation

you administer a network that has enough IP addresses to cover your hosts and servers, you probably haven't needed to implement Network Address Translation (NAT). NAT allows a single device to act as a proxy between your private network and the Internet, allowing a single routable IP address to represent a large group of computers.
But NAT isn't just for covering a short IP space; it also increases security and eases administration. If you haven't implemented NAT, it may be time to rethink your choice.
Before deciding to implement NAT, it's important to understand how NAT works and to be familiar with the different types of NAT that you can implement.

NAT vs. proxy servers
People sometimes confuse NAT with the term proxy server. However, there's a big difference. NAT is transparent to both the source and destination computers. A proxy server is not transparent; you must configure a source computer to communicate with a proxy server.
In addition, the destination computer sends network requests to the proxy server, which forwards the communication back to the requesting computer. Proxy servers usually work at Layer 4 (Transport) or higher of the OSI Reference Model; NAT is a Layer 3 (Network) protocol.
Now that you understand the differences between NAT and proxy servers, let's examine four types of NAT.

Static
Also known as inbound mapping, static NAT maps an unregistered/nonroutable internal IP address to a registered/routable IP address on a one-to-one basis. This is necessary when a network device needs to be accessible from outside the network.
Example: Your mail server has an IP address of 10.0.1.5 (a nonroutable IP address on the Internet). Your NAT device translates that address to 202.0.1.5 (a routable IP address).

Dynamic
Dynamic NAT maps an unregistered IP address to a registered IP address from a pool of registered IP addresses. Dynamic NAT creates a one-to-one mapping between unregistered and registered IP addresses. However, this mapping varies depending on the registered addresses available in the pool at the time of communication.
Example: An internal client has an IP address of 10.0.1.150. When this address tries to communicate with an outside network, your NAT device translates it to the first available address in the range of 202.0.1.50 to 202.0.1.100.

Overloading
Also known as Port Address Translation (PAT), single-address NAT, or port-level multiplexed NAT, overloading is a type of dynamic NAT that maps multiple unregistered IP addresses to one registered IP address by using source port substitution before it translates the network request.
Example: Your NAT device translates all internal clients to a single routable IP address, but it assigns each source session a different port before sending it to the destination IP address.

Overlapping
Overlapping NAT occurs when the internal IP addresses are routable but used on another network. The NAT device translates these addresses to unique routable addresses before forwarding the communication.
Organizations use this type of NAT when using the same routable addresses for internal clients in physically different locations on the network. You usually implement overlapping NAT using dynamic DNS.
Example: Your NAT device translates a client with an IP address of 202.0.1.50 (a routable address also used by a different client in a physically different location) to an address in the range of 202.0.2.50 to 202.0.2.100.

Final thoughts
Don't worry that implementing NAT will cause a performance decrease on your network. An entry in the address translation table of your router takes about 160 bytes, and a router with only 2 MB of DRAM can process 13,107 simultaneous translations.
This should be sufficient for any small network. In addition, keep in mind that adding memory to your router can help if you encounter a problem.
When implementing NAT, most organizations usually prefer the Dynamic NAT approach. It creates a Layer-3 firewall between the internal network and the Internet.
This way, computers on the Internet can't connect to the internal client unless the internal client initiates the communication. Keeping hostile networks from connecting to your internal clients is a good beginning to securing your network.