Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Networking With Open Transport / Part 1 - Open Transport Essentials
Chapter 12 - Introduction to AppleTalk


About AppleTalk

Every Mac OS computer includes AppleTalk hardware and software, so if your application needs to communicate with other Mac OS computers, you may want to use an AppleTalk protocol. AppleTalk includes protocols that handle file sharing, LaserWriter and ImageWriter printing, data exchange through data streams or packets, and AppleTalk name lookups across a network.

Although AppleTalk includes protocols that provide connection-oriented services, it is considered a connectionless network because all AppleTalk data is ultimately delivered by the Datagram Delivery Protocol (DDP), which implements connectionless packet delivery. Connection-oriented AppleTalk protocols that establish sessions and provide reliable delivery of data, such as the AppleTalk Data Stream Protocol (ADSP), are built on top of the connectionless packet services that DDP provides. In the AppleTalk protocol stack, each protocol in a specific layer provides a set of functions and services to one or more protocols in a higher-level layer.

The AppleTalk architecture is closely aligned with the industry-standard Open Systems Interconnection (OSI) networking model. Figure 12-1 shows the AppleTalk protocols supported by Open Transport and shows how they relate to one another in the layers defined by the OSI model.

Figure 12-1 AppleTalk protocol stack and the OSI model

Here are some points worth noting about how AppleTalk under Open Transport maps to the OSI model:

AppleTalk Networks and Addresses

Applications can use AppleTalk protocols across a single AppleTalk network or an AppleTalk internet, which is a number of interconnected AppleTalk networks. An AppleTalk internet can include a mix of LocalTalk, TokenTalk, EtherTalk, and FDDITalk networks, or it can consist of multiple networks of a single type, such as several LocalTalk networks. An AppleTalk internet can include both nonextended and extended networks.

An AppleTalk nonextended network is one in which

LocalTalk is an example of a nonextended network. Each node on a nonextended network, such as LocalTalk, has a unique 8-bit node ID. Since there are 256 possible combinations of 8 bits, and three IDs are not available (ID 255 is reserved for broadcast messages and ID 0 and 254 are not allowed), a nonextended network can support up to 253 active nodes at a time.

An AppleTalk extended network is one in which

Table 12-1 summarizes the identifiers that you use for AppleTalk addressing.

Table 12-1 AppleTalk addressing identifiers
Identifier Description
Network number  A 16-bit number that identifies the network to which a node is connected. An extended network is defined by a range of network numbers.
Node IDAn 8-bit number that identifies a node.
Zone nameA name assigned to a logical grouping of nodes in an AppleTalk network or internet.
Socket numberAn 8-bit number that identifies a socket.
DDP typeAn 8-bit number that identifies an endpoint's protocol.

Each network is assigned a network number so that an AppleTalk router can determine the packet's destination network number and forward the packet through an internet from one router to another until the packet arrives at its correct destination network. An extended network uses a range of network numbers. Nodes on an extended network can have different zone names and different network numbers within the network number range.

A node is the data-link addressable entity on an AppleTalk network; all physical devices on an AppleTalk network are nodes. When a node first connects to an AppleTalk network or is rebooted, AppleTalk dynamically assigns it a unique 8-bit node ID. For a node on an extended network, AppleTalk also assigns it a 16-bit network number within the range of numbers assigned to the extended network that the device is connected to. Once a packet arrives at its destination network, the packet is delivered to its destination node within that network, based on the node ID.

Note
Open Transport allows system administrators to assign static node IDs.
Because AppleTalk assigns node IDs dynamically whenever a node joins the network or is rebooted, a node's address on an AppleTalk network can change from time to time, although a computer attempts to reuse the node ID it last used. the NBP provides a mapping of logical names (like those in the Chooser) to physical addresses in such a way that if the node ID changes, you can still find the remote service. This mapping is discussed further in "About AppleTalk Addressing" and "About AppleTalk Service Providers" in this book.

A zone is a logical grouping of nodes within an AppleTalk internet. The use of zones allows a network administrator to set up departmental or other logical sets of nodes in an internet. A single extended network can contain nodes belonging to multiple zones; an individual node on an extended network can belong to only one zone. Each zone is identified by a unique zone name.

A socket is an addressable data-link entity on a network. Endpoints exchange data with each other across an internet through sockets. Because each endpoint has its own socket address, a node can have multiple concurrent open connections, for example, one to a file server and one to a printer. A node can have several sockets open at the same time, so each endpoint on an AppleTalk network is associated with a unique 8-bit socket number.

AppleTalk sockets are divided into two groups: statically assigned sockets and dynamically assigned sockets. Statically assigned sockets are those sockets that are permanently reserved for a designated protocol or process. For example, socket 4 is always reserved as the echo socket, used for echoing packets across a network. Dynamically assigned sockets are those sockets arbitrarily assigned by DDP if you do not specify a socket number when binding an endpoint; DDP returns the socket number to you in the endpoint's address when the binding has completed. In certain situations, you can bind multiple endpoints to a single socket.

Multinodes

AppleTalk's multinode architecture allows an application to acquire virtual node IDs, called multinode IDs. These multinode IDs allow the computer running your application to appear as multiple nodes on the network even though it is only one physical entity. Each acquired multinode is in addition to the standard node ID already assigned to the computer when it joined the network as a node. The prime example of a multinode application is Apple Remote Access Server (ARA), which uses multinodes to make the connected remote client appear on the local network.

You can use a multinode to receive broadcast packets and any AppleTalk packets addressed to it through its multinode ID. You must then process the packets in a custom manner. A multinode ID is not connected to the AppleTalk protocol stack above the network (DDP) layer, which means that an application that uses a multinode cannot expect to be supported by the services of higher-level protocols such as NBP, ATP, and ADSP, but instead must implement its own higher-level protocols if it expects packets for such protocols.

Handling Miscellaneous Events

In classic AppleTalk, you could use the AppleTalk Transition Queue (ATQ) to inform your application of miscellaneous events that occurred unexpectedly within AppleTalk. In Open Transport AppleTalk, this facility has been modified to allow your endpoint to receive only a few predefined events. An example of such an event is an AppleTalk router coming online or a zone name changing. When one of these events occurs, Open Transport sends a message to the notifier functions of all endpoints that have registered for reception of miscellaneous events. (Any applications that rely on the AppleTalk Transition Queue must use AppleTalk backward compatibility to handle them as described in Inside Macintosh: Networking.)

In Open Transport AppleTalk, there are five miscellaneous events that you can receive on your AppleTalk endpoint, which does not need to be bound. They are as follows:

Miscellaneous eventValueExplanation
T_ATALKROUTERDOWNEVENT0x23010051The router on your application's network is no longer available.
T_ATALKROUTERUPEVENT0x23010052A router has become available on your application's network.
T_ATALKZONENAMECHANGEDEVENT0x23010053The router has changed the name for your computer's zone.
T_ATALKCONNECTIVITYCHANGEDEVENT  0x23010054  A multinode connection was established or disconnected on your network.
T_ATALKCABLERANGECHANGEDEVENT0x23010055A router has become available on your network, and your endpoint's address is no longer in the correct local-network number range.

To receive these events, your application must use the OTIoctl function with a provider reference value, the constant kOTGetMiscellaneousEvents as its command, and the value of 1 as its data. For more information on the OTIoctl function, refer to "OTIoctl" in this book.

Configuring AppleTalk Protocol Providers

When you want to use a particular AppleTalk protocol, you open an endpoint configured for that protocol. To do this, you use specific constants as part of a configuration string that you pass to the Open Transport function for opening endpoints. This string specifies to Open Transport how to create the correct endpoint for you. For more information on the functions that you use to open endpoints, mappers, and AppleTalk service providers, refer to the chapters in this book on the specific type of provider; for more information about configuring providers, see "Configuring and Opening a Provider" in this book.

Table 12-2 lists the constants you use to configure the AppleTalk providers. You can use either the constant or the literal string when creating configurations.

Table 12-2 Protocol identifiers for use in configuring AppleTalk providers
ConstantConfiguration
  string value  
Type of provider configured
kNBPName  "nbp"NBP mapper provider
kDDPName"ddp"DDP endpoint provider
kATPName"atp"ATP endpoint provider
kADSPName"adsp"ADSP endpoint provider
kPAPName"pap"PAP endpoint provider

There is one exception to the typical method of configuring providers. AppleTalk service providers do not have a string equivalent value. You configure an AppleTalk service provider with the constant kDefaultAppleTalkServicesPath, which has a value of ((OTConfiguration*)-3). The code for creating an AppleTalk service provider is as follows:

OTOpenEndpoint(kDefaultAppleTalkServicesPath, 0, &err)
If you want to set an option as part of the configuration string, you need to know which protocols use which options and how to translate the option's constant name, given in the header files, into a string that the configuration functions can parse. For the AppleTalk options, Table 12-3 provides the constant name, the value used in the configuration string, and the protocols that use that option.

Table 12-3 AppleTalk options in the configuration string
Indicating
Constant nameConfiguration
string value
Valid protocols
OPT_CHECKSUM"Checksum"DDP, ATP, ADSP, PAP
OPT_SELFSEND"SelfSend"DDP
OPT_ENABLEEOM"EnableEOM"ADSP, PAP
OPT_INTERVAL"RetryInterval"  ATP
OPT_RETRYCNT"RetryCount"ATP
ATP_OPT_RELTIMER"ReleaseTimer"ATP
PAP_OPT_OPENRETRY  "OpenRetry"PAP

To configure a provider with an option string, you put the string and its assigned value in parentheses after the protocol that uses it, as in the following lines of code:

OTOpenEndpoint(OTCreateConfiguration
                  ("adsp,ddp(Checksum=1),ltlkB"), 0, NULL, &err) 
OTOpenEndpoint(OTCreateConfiguration
                  (kADSPName"(EnableEOM=1)"), 0, NULL, &err); 

Subtopics
AppleTalk Networks and Addresses
Multinodes
Handling Miscellaneous Events
Configuring AppleTalk Protocol Providers

Previous Book Contents Book Index Next

© Apple Computer, Inc.
15 JAN 1998