| technology | networking - David Mundhenk
AFP vs SMB vs NFS: Which Is the Best Data Transfer Protocol?
File sharing over networks is a very common practice today, especially in enterprise settings, as well as in SOHO (small office/home office) environments. In the earlier days of computing, file sharing involved the use of what was often termed the "SneakerNet", which meant taking a floppy disk or other removable media from one computer to another to transfer files.
With the advent of more and more computer networks like ethernet, it became much more convenient to share or transfer files over this network. This post will explain the most popular methods of file sharing, what they require, and how they are implemented.
File Transfer vs File Sharing
For clarity, it's useful to make a distinction between file transfer and file sharing. While there may be some gray area or overlap of how these terms are used, for this post it will be useful to separate them in the following way. The term transfer will be used to refer to what is commonly called uploading or downloading files. This type of functionality is most often provided by the FTP (File Transfer Protocol) or HTTP (HyperText Transfer Protocol) or variants of these protocols.
Typically these are used with web browsers, for example, in scenarios where the user is presented with a web page with a link, which when clicked on initiates a download of the file to the user's computer. They can be used for uploads also, but this is less common.
There are also a variety of file sharing methods called "peer-to-peer" (P2P), such as Bittorrent, Kazaa, and Freenet, that require special software and/or additional networking protocols to function. These are beyond the scope of this article, which discusses protocols supported by corporate or home networks without such modifications.
The File Sharing protocols we will explore in this article were developed with a focus on the LAN (Local Area Network) in an office or campus environment. They have evolved over time, and have a long, rich history.
SMB: What is Server Message Block Protocol?
The SMB (Server Message Block) protocol was first developed by IBM in early 1983. This protocol was designed to provide shared access to server-based files, printers, and serial ports to client nodes running DOS (Microsoft MS-DOS or IBM PC-DOS) on a LAN. There were a variety of physical LAN types of topologies in use or in development also, but ethernet was the most common choice. At this time, the network was based on NetBIOS Frames (NBF), which were non-routable and only well-suited for small to medium sized networks.
There was some competition in the file sharing space around that same time, most notably, the product called Novell Netware. Netware used Netware Control Protocol (NCP) running on IPX/SPX networks. It had some efficiency benefits, and actually evolved and survived as part of the Linux-based Open Enterprise Server (OES) until 2009. However, Netware gradually lost market share to Microsoft as more and more file sharing features were built-in to Microsoft Windows operating system after its Windows for Workgroups product was introduced in 1993.
As of today, SMB has evolved up to Version 3.1.1, and has become ubiquitous primarily because it is bundled with the operating system in modern versions of Microsoft Windows, which has over 75% of the global market share in desktop and laptop computers. In addition, modern Enterprise Network-Attached Storage (NAS) file servers, Microsoft Windows-based servers, and even Linux-based servers support SMB.
NFS: What is Network File System?
Network File System (NFS) is a distributed file system protocol originally developed by Sun Microsystems in 1984; however it was not made available for public use until Version 2 of the protocol was released in 1989. It was originally created for use on systems running the UNIX operating system, but has been adapted to most other common operating systems over the years largely because it is based on an open standard maintained by the IETF (Internet Engineering Task Force). NFS has evolved through Version 3 to Version 4 at present, with numerous improvements and new features.
NFS was not built to provide printing services or shared serial port services like SMB, because the UNIX operating system typically already addressed those needs via other methods. Perhaps it is because of its focus on file sharing services, that NFS has some efficiency advantages over SMB. It is consistently superior to SMB for small random reads and writes. However, NFS (at least prior to NFSv4) has weaker security than SMB. One significant feature in NFSv4.1 is a Session trunking mechanism (Also known as NFS Multipathing), which provides it with much more fault-tolerant access when there are multiple network interfaces available on both the server and client.
AFP: What is Apple Filing Protocol?
As the name implies, Apple Filing Protocol (AFP) was developed by Apple, Inc., originally called "AppleTalk Filing Protocol" because at that time it ran on AppleTalk networks. It was first released to the public in Macintosh System 6 in 1988. AppleTalk networks at that time were a proprietary, slow, built-in, "Apple only" network, so AFP was restricted to only Apple products. Even so, it was quite popular since the only other options available for Apple Mac computers at that point in time were quite expensive.
Apple made some wise design choices with AppleTalk which enhanced the adoption of AFP. One such choice is that the AppleTalk network stack followed the Open Systems Interconnection (OSI) model, which was growing in popularity, and was designed to work with any underlying physical link. This facilitated the eventual move to Ethernet, which permitted Mac users to continue using AFP long after AppleTalk had been phased out. In addition to this, the networking in Mac OS was built to be virtually maintenance-free, and very easy to set up for non-technical users.
As computer networks became more standardized on Ethernet and became more heterogeneous with a variety of operating systems, the desire for interoperability drove some developments that made it possible to use AFP with other operating systems and even some NAS systems. On the other hand, Apple has made it possible to also use SMB and NFS on Mac OS.
How to Choose the Right Data Transfer Protocol
So, how does one choose the best protocol? It really depends on a number of criteria. Let's look at several scenarios.
Scenario 1: Large Corporate Headquarters.
In this scenario, the company has an on-premise data center, a relatively fast LAN, and mostly Microsoft Windows servers and personal computers. The decision is fairly straightforward, at least for the bulk of the user community. Microsoft Windows Servers, Active Directory (AD) authentication and access security, most likely some NAS filers that are integrated with AD, are the perfect home for SMB.
Protocol You Should Use: SMB
Rationale for using SMB: There may be questions about which version(s) of SMB to support, but it is definitely the primary protocol of choice here. If there are small groups of say, Mac or Linux users, it is up to the IT organization or upper management to decide whether or not to support NFS or AFP for them. The decision might be based more on security risk than performance or ease of use. While it may be possible to support all three protocols, more complexity is likely to translate into more calls to the support line and more work for the IT department.
Scenario 2: Small Website Design Firm
In this case, there is a strong chance that there are many Mac users in this environment. Hence, AFP is the likely choice as the primary supported file sharing protocol. It is well integrated with the Mac OS operating system, performs well, and is reasonably secure if password and sharing best practices are followed.
Protocols You Should Use: AFP and SMB
Rationale for using AFP and SMB: That said, while it is possible that a company could take the position of only supporting Mac OS computers and AFP, it is unlikely for several reasons. Apple computers are more expensive than most basic Windows-compatible computers, and the higher cost may only be justified for certain types of users.
For example, the accounting department may be using software that only runs on Windows, and does not require high-end video performance, CPU or memory. Therefore, there would be a need to support SMB for this group of users, since there is no AFP client for Windows. It is likely that these two groups would be accessing different shares, so adding SMB to the mix may not add much complexity. SMB is supported by Mac OS and a company could decide to only support SMB even for Mac users, but AFP is the protocol of choice for Mac users.
Scenario 3: Linux Software Development Group
NFS has been part of the UNIX/Linux world for many years and is the most familiar protocol to those who work primarily with these operating systems. It performs well and the security mechanisms are familiar to Linux administrators.
Protocol You Should Use: NFS
Rationale for using NFS: A group that is working with and running the Linux operating system will probably choose to use NFS for their file sharing needs. However, as in both of the previous examples, a homogeneous network of systems with the same operating system is rare. Even a small group of Windows or Mac users in a situation like this will be best served by supporting at least the SMB protocol, or possibly both SMB and AFP.
What About the Internet?
None of these protocols is designed to work securely (or at all) over the Internet. In fact, most Internet Service Providers (ISPs) may block this kind of traffic. If they do allow the traffic, security is a major concern. If there is a strong need to share files across the Internet, there are other methods of doing so that are not as convenient but are better at protecting data. Most of these are in the categories mentioned earlier in the article, of File Transfer or Peer-to-Peer sharing.
Most businesses use private Wide Area Networks (WANs) to connect their various facilities. These consist of secure leased circuits. For smaller offices and individual remote workers, the connection to the corporate LAN is made using a Virtual Private Network (VPN) which can run over the Internet, but provides a secure encrypted "tunnel" for traffic, including file sharing protocols, to run. The limiting factors in this case are the speed, latency, and reliability of the internet connection. There have been vast improvements in all of these factors over the years, and using a file sharing protocol from home over the Internet can appear just as well performing as being at the office.