Networking Tips

  


[an error occurred while processing this directive]

No Title

[an error occurred while processing this directive]

Reference: Cisco: Internetworking Basics

Contents

Introduction

Every machine on your network with a TCP/IP stack has a configuration setting for a gateway. This is so that it can reach IP networks other than its own. When it detects that the destination is part of a remote network, it sends the packet to the gateway for forwarding. For destinations in the same subnet, it will send the packet directly to the other machine. How does a workstation determine if a destination is part of the same or a different IP network?

First it ANDs the destination address of the packet with its own subnet mask. If the resulting address matches its own network mask, then the destination is in the same subnet, and the TCP/IP stack tells the card to send the packet directly to the destination machine. (Actually, more than this occurs in order to send the packet directly, but it's no longer part of TCP/IP, but Ethernet.) If, however, the calculation shows that the destination is part of another network, then the sender makes use of its gateway to transmit the packet. In effect, the sender is saying, "I do not know how to deliver this packet; can you please deliver it for me?" The gateway accepts the packet and then goes through a similar procedure. (That procedure is known as routing.)

Here are a few examples of the workstation's decision-making process.

Workstation IP Address Network/Netmask Gateway
A 192.168.16.4 192.168.16.0/22 192.168.16.1
B 192.168.17.20 192.168.16.0/22 192.168.16.1
C 192.168.30.4 192.168.30.0/24 192.168.30.1

Example 1 - Workstation A sends to Workstation B

Workstation A knows its own network address/subnet mask is 192.168.16.0/22. Workstation A calculates the local-subnettedness of the destination packet as follows:

Are A and B in the same subnet?
bitwise-AND 11111111 . 11111111 . 11111100 . 00000000
11000000 . 10101000 . 00010001 . 00010100
subnet mask of A
IP addr of dest (B)
  11000000 . 10101000 . 00010000 . 00000000 network of dest
compare 11000000 . 10101000 . 00010000 . 00000000 network of A
They are equal - Both Workstations are on the network (192.168.16.0)

Because the network address of the sender matches the result of this calculation, the packet is sent directly to machine B.

Example 2 - Workstation C sends to Workstation B

Workstation C knows its network address/subnet mask is 192.168.30.0/24. Machine C checks to see if the destination packet falls within its subnet.

Are C and B in the same subnet?
bitwise-AND 11111111 . 11111111 . 11111111 . 00000000
11000000 . 10101000 . 00010001 . 00010100
subnet mask of C
IP addr of dest (B)
  11000000 . 10101000 . 00010001 . 00000000 network of dest
compare 11000000 . 10101000 . 00011110 . 00000000 network of C
They ARE NOT equal - (192.168.17.0 not equal to 192.168.30.0)

In this case, the comparison fails. The sender, C, has no choice but to send packet to its gateway. (If you take the time to do the calculation, you discover the gateway is in machine C's subnet. In fact the gateway must always be in the sender's subnet; otherwise, the sender could not send to it either!)

A Workstation's Routing Table

About the Author

Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, and an Oracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located in Pittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming, developing high availability solutions, capacity planning, database security, and physical / logical database design in a UNIX / Linux server environment. Jeff's other interests include mathematical encryption theory, tutoring advanced mathematics, programming language processors (compilers and interpreters) in Java and C, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Database Administrator and Software Engineer for over 20 years and maintains his own website site at: http://www.iDevelopment.info. Jeff graduated from Stanislaus State University in Turlock, California, with a Bachelor's degree in Computer Science and Mathematics.



Copyright (c) 1998-2017 Jeffrey M. Hunter. All rights reserved.

All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express, prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.

I have made every effort and taken great care in making sure that the material included on my web site is technically accurate, but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.

Last modified on
Wednesday, 28-Dec-2011 14:14:16 EST
Page Count: 3632