Recently, we threatened to discuss Samba, the open source freeware implementation of the Server Message Block protocol. Well, it was no idle threat. Here we go . . .
Samba is a remarkable piece of engineering. It provides directory tree browsing and sharing; disk, file and printer sharing; Windows Internet Name Service (WINS) resolution; and Windows domain client authentication. It runs under Linux, Unix, VMS and Mac OS X.
What is interesting is that where high performance is necessary, Samba under Unix (which is known to be a very stable and robust pairing) has been benchmarked to outperform Windows Server 2000 on identical hardware by a factor of 2 to 1. It also requires no client licenses and is well-documented. In short, Samba is an awesome service tool for heterogeneous networks.
First, what is Server Message Block (SMB)? To answer this we need to go back to 1984 when IBM released the Network Basic Input/Output System (NetBIOS) as the protocol for low-level file access across IBM PC or Token Ring networks. We'll skip over a chunk of history here and jump to 1987 when the IETF published RFC 1001 and 1002, which defined NetBIOS over TCP/User Datagram Protocol (UDP) transport, otherwise called NBT. NBT defines the naming, datagram service and session service.
All of the preceding discussion of NetBIOS is important because that is the transport for the exchange of SMB requests and responses. The SMB protocol was created by IBM in 1985 for LAN Manager and essentially split out the file access mechanism from the lower-level services NetBIOS.
And there's isn't just one version of SMB (of course) - the protocol is covered by multiple standards. The versions that interest us most are NT LAN Manager 0.12 and the Common Internet File System (which Windows 2000 and XP use). Interestingly, all versions of SMB are backward-compatible, and a single network can support any mix of versions simultaneously.
SMB servers are computers that provide access to resources - disk storage, files and printers - that can be shared with SMB clients. And at any given time a machine can be a server, a client or both simultaneously.
Establishing an SMB connection to a shared resource (usually simply called a "share") is a four-step process: First, a NetBIOS session must be negotiated and set up; next, the SMB protocol that is to be used must be negotiated; the session parameters must be set; and finally, a "tree connection" to the resource must be made.
Negotiating a NetBIOS session requires that computers first register their name, workgroup and resource type (actually each computer registers its name multiple times - one for each resource it offers). Registration can be done with a NetBIOS Name Server (a computer that acts as a central authority for NetBIOS name registration and resolution) or without (in which case each computer is responsible for reporting its IP address when it receives a broadcast request for its NetBIOS name).
In a Windows network, NetBIOS Name Service is provided by WINS if there is a Win 2000 or NT server available and configured to provide WINS. Now under Windows a WINS server can be a primary server (that is the one that is active) or a secondary server (intended to take over name serving if the primary becomes unavailable). Note that Windows WINS servers automatically synchronize their name data regularly.
While you might assume that peer-to-peer address resolution is less efficient and generates more traffic, the overhead is minimal. On the other hand, a centralized NetBIOS Name Server is more efficient. Samba can provide a primary WINS service but cannot act as a secondary WINS server or provide synchronization with secondary Windows WINS servers.
Resource types include the two resources that matter most to us: the Standard Workstation Service and the Fileserver (which also can provide print service). When a name is resolved the resource type also is returned so the requestor can determine the target machine's capabilities.
There's a lot more to say about NetBIOS operations but that's the topic of a separate column. For now, we'll leave it that a session can be established and we're ready to negotiate the SMB protocol.