If one attempted to download a file at a speed of 800 Mb/s (100 MB/s) onto a hard drive with a write speed of 500 Mb/s (62.5 MB/s), what would happen? Would the system cap the download speed?
Many protocols, including TCP which is most widely used protocol on the Internet, use something called flow control. Flow control simply means that TCP will ensure that a sender is not overwhelming a receiver by sending packets faster than it can empty its buffer. The idea is that a node receiving data will send some kind of feedback to the node sending the data to let it know about its current condition. So, two way feedback allows both machine to optimally use their resources and prevent any problems due to mismatch in their hardware.
what would happen?
- The bytes that cannot be written to the HDD in time would be buffered temporarily somewhere; very likely some of them would be buffered in the application that "converts" the network traffic into HDD traffic (i.e., your browser), and in cases of longer congestion, the lower level parts of the stack (i.e., the networking subsystem of your PC) would have buffers at lower levels as well, which would fill up until full.
- The information that the data is coming too fast would then propagate back to the sender in some fashion. In the case of TCP/IP, this would mean that there is a part of the TCP protocol which tells the sender that it should stop sending. The Wikipedia page on TCP/IP says it best when it says:
Its [TCP] responsibility includes end-to-end message transfer independent of the underlying network, along with error control, segmentation, flow control, congestion control, and...
- At the end of the day, the "system" (not necessarily the computer of the receipient, but the total system consisting of sender, network and receipient) would indirectly "cap" the download speed. At no point is a "speed" variable in existance, though. Both network traffic and HDD traffic is block-based, that is, the delays between those blocks would get long enough (on the faster network side) until the net "speed" (throughput) is on average the same as the slower speed of your HDD.
Would the system cap the download speed?
Not literally. A few dozen years ago, computers indeed communicated with synchronous speeds (i.e., modems with fixed speed settings). This is, at some relatively low level, also happening today; i.e., your DSL or cable modem will probably have some set speed at which it communicates with its direct physical uplink component. But in 2017, all of this is sufficiently complicated that almost all components are quite dynamic. In the good old days, modems were often physically only able to speak a certain speed, and that even had to be established before dialing in. There are (were) some network protocols like ATM which tried to get a synchronous wide-area network, but they didn't turn out so well, compared to TCP/IP.
Today, the effective speed is usually always implicitely reached by buffering, flow control, and such.
Also note that in your example there can even be more participiants. The network interface could have more work to do (other connections to your PC). Some part of the network along the way could be busy (a family member surfing or watching videos). The HDD might be doing 3 large file writes at the same time. So it would make no sense to specifically set a "speed" which could be capped.
File downloads (usually) happen over a protocol called TCP. In TCP, the sender doesn't send any data until the receiver is ready to receive it.
What will happen is that your computer will reserve some amount of RAM to hold the received data temporarily before writing it to your hard drive (this is called a buffer). Then it will ask the sender for just enough data to fill the buffer. As it receives data, it will start writing data from the buffer to the hard drive - however, it won't ask for more data while the buffer is nearly full.
The overall effect is the sender simply waits for the receiver to catch up before it continues sending.