The two main roles of the transport layer in data communication on a network are:
- Reliable Data Transfer: The transport layer makes sure that data is delivered safely between the communicating devices. It has ways to find and fix errors, and to send again any lost or damaged data packets.
- Flow Control: The transport layer controls the rate of data flow between the sender and receiver. This stops the sender from sending more data than the receiver can handle. It keeps the data transfer smooth and efficient.
In simple terms, the transport layer ensures that data is sent reliably and at the right pace between networked devices.