Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!husc6!uwvax!rutgers!ames!ucbcad!ucbvax!JUPITER.BELLCORE.COM!karn From: karn@JUPITER.BELLCORE.COM (Phil R. Karn) Newsgroups: comp.protocols.tcp-ip Subject: Generalized Subnetting Message-ID: <8708180007.AA01148@jupiter.planets> Date: Mon, 17-Aug-87 20:07:53 EDT Article-I.D.: jupiter.8708180007.AA01148 Posted: Mon Aug 17 20:07:53 1987 Date-Received: Wed, 19-Aug-87 01:31:34 EDT Sender: daemon@ucbvax.BERKELEY.EDU Distribution: world Organization: The ARPA Internet Lines: 41 The recent discussion about varying subnet sizes was interesting. I have implemented a "generalized subnetting" scheme in my own IP routing code that handles this and many similar problems quite well. Basically, I completely ignore the usual rules that distinguish class A, B and C addresses. Instead I keep an explicit subnet mask with each entry in the routing table. (Actually, I use integers between 0 and 32, but the semantics are the same). When a packet is to be routed, I search the routing table for the "best" match under control of the mask. That is, if my routing table contains target width interface gateway 128.96.33.101 32 sl0 128.96 16 ec0 0 0 ec0 128.96.41.1 and I present the address 128.96.33.101, all three entries match. In this case, I select the entry with the greatest width, i.e., the first one. Note that the last entry always matches every address; it is the default route. The first one is a host-specific entry, matching only one IP address. Note that the routing table points to an INTERFACE name, not a gateway address. The gateway field is optional. It is filled in only if the target is to be reached through a gateway on a multiple access subnet, in which case the gateway field is passed down to the subnet driver for translation into a subnet address. If the gateway field is null, the subnet driver is given the target IP address for translation; this would be done if the target is directly on the same subnet. If the subnet is a point-to-point link, the gateway address field is ignored altogether since the subnet has no need for link level addresses. With this scheme you can construct a completely arbitrary internet out of ad-hoc point-to-point links, incompletely connected broadcast subnets (e.g., amateur packet radio), partitioned networks as well as "real" subnets like Ethernets without filling up your routing table with lots of host-specific entries. You can "bunch up" address groups that begin with a common bit pattern, regardless of whether they are really all hosts on the same subnet, or you can split off one or more hosts that are behind a point-to-point link, for example. It works very well. Phil