Which File-Sharing Protocol Should You Use for a NAS?

Which one should I use: SMB, WebDAV, FTP, or SFTP? Many people have faced the problem of sharing files across devices. In the age of the Internet, networks provide a solution for scenarios like this. The four protocols mentioned above are currently the mainstream options, so letโ€™s use the data to determine which one is best suited to your needs.

1. Distinguishing the Similarities and Differences

1.1. Similarities

There is not much to say here. Even though their application scenarios differ, their purpose is the same: sharing and transferring files over a network.

1.2. Differences

First, here are the scoring criteria. The security score is based on the CNNVD vulnerability classification standard, using the number of disclosures between March 15, 2017 and March 15, 2022 as the basis. After weighting, the score is calculated using statistical normalization (Chinese Wikipedia and normalization operations. The weights used are 0.5 for critical vulnerabilities, 0.25 for high-severity vulnerabilities, 0.15 for medium-severity vulnerabilities, and 0.1 for low-severity vulnerabilities. Finally, Min-Max scaling is used for normalization to obtain ฮผ. The script used can be found here: Vulnerability Statistics. Please also note that this calculation is not rigorous and does not distinguish between results with the same name but different meanings.

Convenience ScoreDescription
โ˜…โ˜†โ˜†โ˜†โ˜†Requires complex commands for deployment, needs multiple projects to work together, and has no Chinese documentation.
โ˜…โ˜…โ˜†โ˜†โ˜†Must be downloaded and configured manually, but offers quick deployment with a basic configuration and has detailed documentation in other languages for reference.
โ˜…โ˜…โ˜…โ˜†โ˜†Must be downloaded and configured manually, but offers quick deployment with a basic configuration and has detailed Chinese documentation for reference.
โ˜…โ˜…โ˜…โ˜…โ˜†Offers one-click deployment or convenient Docker deployment.
โ˜…โ˜…โ˜…โ˜…โ˜…Built into the system and can be deployed without commands.
Compatibility ScoreDescription
โ˜…โ˜†โ˜†โ˜†โ˜†Supported only on specific devices and tightly coupled to the hardware and software.
โ˜…โ˜…โ˜†โ˜†โ˜†Limited support only after installing software on smart devices such as computers, tablets, and phones.
โ˜…โ˜…โ˜…โ˜†โ˜†Limited support on common household devices after installing software.
โ˜…โ˜…โ˜…โ˜…โ˜†Good support only after installing software on smart devices such as computers, tablets, and phones.
โ˜…โ˜…โ˜…โ˜…โ˜…Natively supported by common household devices, or well supported after installing software.
Security ScoreDescription
โ˜…โ˜†โ˜†โ˜†โ˜†1 > ฮผ โ‰ฅ 0.8
โ˜…โ˜…โ˜†โ˜†โ˜†0.8 > ฮผ โ‰ฅ 0.6
โ˜…โ˜…โ˜…โ˜†โ˜†0.6 > ฮผ โ‰ฅ 0.4
โ˜…โ˜…โ˜…โ˜…โ˜†0.8 > ฮผ โ‰ฅ 0.2
โ˜…โ˜…โ˜…โ˜…โ˜…0.2 > ฮผ โ‰ฅ 0
Transfer Efficiency ScoreDescription
โ˜…โ˜†โ˜†โ˜†โ˜†Less than 60% of the available bandwidth
โ˜…โ˜…โ˜†โ˜†โ˜†60% or more of the available bandwidth
โ˜…โ˜…โ˜…โ˜†โ˜†70% or more of the available bandwidth
โ˜…โ˜…โ˜…โ˜…โ˜†80% or more of the available bandwidth
โ˜…โ˜…โ˜…โ˜…โ˜…90% or more of the available bandwidth

1.2.1. SMB

Server Message Block (abbreviated as SMB), also known as Common Internet File System (abbreviated as CIFS, /หˆsษชfs/), is an application-layer network transport protocol developed by Microsoft. Its primary function is to enable machines on a network to share computer files, printers, serial ports, and communications resources.

The preceding information comes from Wikipedia. Based on its application scenarios, it is easy to see that SMB focuses on file sharing within a local network, while also offering broad protocol compatibility. While gathering information, I came across an interesting detail: the relationship between SMB and Samba. The Wikipedia entry for SMB says that SMB was originally developed by IBM, after which Microsoft made substantial changes to it, resulting in the protocol version most commonly used today. Samba, meanwhile, is free software that implements compatibility with SMB through reverse engineering and is used primarily on Linux.

At the same time, I found another article that gives the exact opposite account, claiming that Samba came first and that Microsoft’s SMB was a reimplementation created to avoid paying licensing fees.

In any case, the first account is the widely accepted one today, and I agree with it. SMB is a file-sharing protocol; whether it is Windows’ SMB 3.0 or Linux’s Samba, each is simply an implementation of that protocol, which is why they are mutually compatible.

  • Convenience: Windows supports SMB natively, making it easy to enable file sharing through SMB. Linux requires you to install Samba yourself, although the process is not particularly difficult overall.

  • Compatibility: This is arguably one of the most widely compatible protocols available. From Windows to Linux, and from TV boxes to home computers, it is supported almost everywhere.

  • Security: Windows SMB uses port 445, and the notorious EternalBlue was an exploit for vulnerabilities in that port and the SMB protocol. As a result, a large number of computers were infected with ransomware for a long time afterward, making everyone wary of it. It is therefore recommended only for use on a local network. The script output is as follows:

1
2
3
4
5
6
ๆผๆดžๆ€ปๆ•ฐ๏ผš45
ๆœชๅˆ†็บงๆ•ฐ้‡๏ผš1
ไฝŽๅฑๆ•ฐ้‡๏ผš0
ไธญๅฑๆ•ฐ้‡๏ผš18
้ซ˜ๅฑๆ•ฐ้‡๏ผš20
่ถ…ๅฑๆ•ฐ้‡๏ผš6
  • Transfer efficiency: Due to its inherent characteristics, SMB has somewhat higher overhead and is therefore slightly less efficient. For details, see the tests I conduct later.

1.2.2. WebDAV

Web-based Distributed Authoring and Versioning (WebDAV) is an extension of the Hypertext Transfer Protocol (HTTP) that facilitates collaborative editing and management of documents stored on World Wide Web servers.

This is how Wikipedia describes WebDAV. It is easy to see that WebDAV is primarily intended for file sharing over the public Internet. Since it is based on HTTP, it also inherits HTTP’s advantages, including:

  • Operating-system integration
  • Easy traversal of firewalls
  • Tight integration with Web services
  • Free to use
  • Version control
  • Encrypted transmission
  • Remote access
  • Centralized storage
  • Version control
  • File locking

However, because HTTP transmits data in plaintext, deployment with HTTPS is recommended, even on a local network.

  • Convenience: There are quite a few Docker deployment options, so deployment is reasonably convenient.
  • Compatibility: On common operating systems, phones, and computers, installing software provides good support; it can even be used, albeit with limitations, through a browser. However, TV boxes and many other specialized devices generally do not support it directly.
  • Security: Using HTTPS provides good security. The script output is as follows:
1
2
3
4
5
6
ๆผๆดžๆ€ปๆ•ฐ๏ผš3
ๆœชๅˆ†็บงๆ•ฐ้‡๏ผš0
ไฝŽๅฑๆ•ฐ้‡๏ผš0
ไธญๅฑๆ•ฐ้‡๏ผš2
้ซ˜ๅฑๆ•ฐ้‡๏ผš1
่ถ…ๅฑๆ•ฐ้‡๏ผš0
  • Transfer efficiency: WebDAV establishes only one TCP connection and supports GZIP compression. When sending and receiving large numbers of small files, some people have confirmed that FTP is faster; when sending and receiving large files, the two are equally fast and the overhead is negligible. This article will verify that claim again in a later experiment.

1.2.3. FTP

File Transfer Protocol (English: File Transfer Protocol, abbreviated as FTP) is an application-layer protocol used to transfer files between clients and servers over a computer network.