52

Bidirectional and full-duplex are different concepts. For example the Ethernet is only half-duplex because at a specific time, only one host can send data over the wire, and it cannot send and receive data simultaneously.

So when we use TCP over an Ethernet, I think TCP is only bidirectional or half-duplex.

But here it says TCP is full-duplex. Why?

smwikipedia
  • 61,609
  • 92
  • 309
  • 482
  • 10
    Modern Ethernet is full-duplex. – Yu Hao Feb 13 '15 at 07:59
  • @YuHao Thanks, but what if in an old half-duplex Ethernet environment? How could TCP fit there? – smwikipedia Feb 13 '15 at 08:14
  • 1
    TCP as a 'transport layer protocol' provides a bi-directional channel to the upper layer, I think it should be looked at that context. – sanjayk79 Feb 13 '15 at 08:47
  • 4
    TCP doesn't care what the layers below the IP layer do or don't do so long as they can move IP datagrams. – David Schwartz Feb 13 '15 at 09:27
  • 1
    TCP can of course be full-duplex, wherein both hosts can generate datagrams at the same instant of time. However, it's the MAC and PHY layers that truly determine whether these datagrams (now frames) can be exchanged in a full-duplex manner. – V-Red Mar 07 '18 at 20:19
  • Being strict, the term full-duplex should be applied to TCP. – John Z. Li Aug 27 '18 at 08:20

7 Answers7

41

It is both. It is bidirectional because it can send data in both directions, and it is full-duplex because it can do that simultaneously, without requiring line turnarounds, at the API level.

Of course at a lower level it may be restricted by the available physical layer.

user207421
  • 305,947
  • 44
  • 307
  • 483
38

It's certainly bidirectional, since both parties send / receive packets. What exactly do you mean when you ask if TCP is full-duplex?

Both sending and receiving packets at the same time has more to do with the physical component, while TCP is a protocol defining how data should be framed and handled in order to reach the destination.

The NIC (Network Interface Controller) is responsible for sending and receiving physical packets and you would have to check there about the half / full - duplex capabilities.

Wireless (802.11) for example is half-duplex if it is using the same antenna for sending and receiving radio signal.

Razvan
  • 3,017
  • 1
  • 26
  • 35
  • 1
    Thanks. So I think the word `duplex` is just *not applicable* to TCP. So this tutorial (http://ssfnet.org/Exchange/tcp/tcpTutorialNotes.html) is NOT precise to say `TCP is Full-Duplex`. – smwikipedia Feb 13 '15 at 09:01
  • 3
    I think that they refer to the fact that TCP protocol supports full-duplex communication. – Razvan Feb 13 '15 at 12:17
14

The TCP API is full-duplex. This mean that TCP API allow send data from both side of connection just in same time. Let's see the source of test program to proof:

#include <sys/types.h>
#include <sys/socket.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <unistd.h>


void do_write(const char* who, int socket) {
    const char hello[] = "hello!";
    if( 0 < write(socket, hello, strlen(hello)) )
        printf( "%s: write done ok\n", who );
    else
        printf( "%s: write error: %s\n", who, strerror(errno) );
}

void do_read(const char* who, int socket) {
    /* do parental things with this end, like reading the child's message */
    char buf[1024];
    int n = read(socket, buf, sizeof(buf));
    if( 0 < n )
        printf("%s: received '%.*s' %db\n", who, n, buf, n);
    else if( 0 == n )
        printf( "%s: no data available\n", who );
    else
        printf( "%s: read error: %s\n", who, strerror(errno) );
}

int main() {
    int fd[2];
    static const int parent = 0;
    static const int child = 1;
    pid_t pid;

    socketpair(PF_LOCAL, SOCK_STREAM, 0, fd);

    pid = fork();
    if (pid == 0) {      /* child process */
        close(fd[parent]);
        do_write("child", fd[child]);
        do_read("child", fd[child]);
        /* sleep(1); */
        do_write("child", fd[child]);
        do_read("child", fd[child]);
    } else {             /* parent process */
        close(fd[child]);
        do_write("parent", fd[parent]);
        do_read("parent", fd[parent]);
        do_write("parent", fd[parent]);
        do_read("parent", fd[parent]);
    }

    return 0;
}

The output (on FreeBSD) is:

parent: write done ok
child: write done ok
child: received 'hello!' 6b
child: write done ok
parent: received 'hello!hello!' 12b
parent: write done ok
child: received 'hello!' 6b
parent: no data available

So TCP API is full-duplex and data may be sended from both side at the same time. I think that implementation is full-duplex too, but it need to write more complicated test to recognize. This is implementation dependent of course. And good implementation may does not effect when at least one transport chain link is not full-duplex.

oklas
  • 7,935
  • 2
  • 26
  • 42
11

By reading the article you posted, I think it's clear that they're talking about TCP supporting full-duplex communication (emphasis mine):

[TCP] is a full duplex protocol, meaning that each TCP connection supports a pair of byte streams, one flowing in each direction.

Agis
  • 32,639
  • 3
  • 73
  • 81
10

Yes, a TCP connection provides a full-duplex service. Let's understand the meaning of full-duplex. It means exchanging data(sending and receiving) between two entities at the same time. As TCP is a transport layer protocol and transport layer protocols provide logical communication between processes running on different hosts, here also the meaning of full duplex is in this respect.

Here full-duplex means "If there is a TCP connection between Process A on one host and Process B on another host, then application layer data can flow from Process A to Process B at the same time as application layer data flows from Process B to Process A". A TCP connection is also always point-to-point, that is, between a single sender and a single receiver. Remember, the data from Process A is yet to pass through layers below transport layer, similarly the data from Process B will pass through layers below transport layer.

Source: Computer Networking by Kurose, Ross.

Abhishek Sharma
  • 101
  • 1
  • 4
2

Summary

TCP is a software layer which supports full-duplex, but doesn't guarantee it. If the physical hardware layer is only half-duplex Ethernet, then technically you'd be getting time-sliced half-duplex at the hardware layer, even though the TCP software layer wouldn't know the difference.

So, if the hardware supports it, then TCP is truly full duplex. If the hardware is only half-duplex, then the TCP software acts like it is full-duplex because it allows "simultaneous" bi-directional communication, but technically it is only half-duplex.

Refer back to paragraph one above: therefore, TCP is a software layer which supports full-duplex, but doesn't guarantee it.

Ethernet can be half-duplex or full-duplex at the physical hardware layer

Modern Ethernet, however, starting with the 10BASE-T [10 Mbps] standard, apparently, is now truly full-duplex. See here: https://en.wikipedia.org/wiki/Ethernet (emphasis added):

Furthermore, the 10BASE-T [10 Mbps] standard introduced a full duplex mode of operation which became common with Fast Ethernet [100 Mbps] and the de facto standard with Gigabit Ethernet [1000 Mbps]. In full duplex, switch and station can send and receive simultaneously, and therefore modern Ethernets are completely collision-free.

In both cases: whether half-duplex vs full-duplex at the physical hardware layer, TCP is still bidirectional.

To further complicate the matter, apparently all of the Ethernet standards define both full-duplex and half-duplex communication options, but "half-duplex operation for gigabit speed is not supported by any existing hardware." See here: https://en.wikipedia.org/wiki/Ethernet_over_twisted_pair#Autonegotiation_and_duplex (emphasis added):

Autonegotiation and duplex

Ethernet over twisted-pair standards up through Gigabit Ethernet define both full-duplex and half-duplex communication. However, half-duplex operation for gigabit speed is not supported by any existing hardware.[27][28] Higher speed standards, 2.5GBASE-T up to 40GBASE-T[29] running at 2.5 to 40 Gbit/s, consequently define only full-duplex point-to-point links which are generally connected by network switches, and do not support the traditional shared-medium CSMA/CD operation.[30]

Many different modes of operations (10BASE-T half-duplex, 10BASE-T full-duplex, 100BASE-TX half-duplex, etc.) exist for Ethernet over twisted pair, and most network adapters are capable of different modes of operation. Autonegotiation is required in order to make a working 1000BASE-T connection.

More interesting tidbits I just learned

I've always wondered: "what the heck does 'BASE' mean in 10BASE-T, 100BASE-T, etc?"

Answer:

https://en.wikipedia.org/wiki/Classic_Ethernet:

In 10BASE-X, the 10 represents its maximum throughput of 10 Mbit/s, BASE indicates its use of baseband transmission, and X indicates the type of medium used.

And: https://en.wikipedia.org/wiki/Baseband:

A baseband signal or lowpass signal is a signal that can include frequencies that are very near zero, by comparison with its highest frequency (for example, a sound waveform can be considered as a baseband signal, whereas a radio signal or any other modulated signal is not).

So, "BASE" means that it uses a baseband signal, which is defined as a low-pass signal which can go from 0 Hz to cutoff_freq Hz, rather than a frequency-modulated (FM) signal which varies within a certain pass-band (vs baseband) range of x Hz to y Hz, for instance. FM radio is a passband signal, not a baseband signal. Ethernet, apparently, is a baseband signal.

See also: https://en.wikipedia.org/wiki/Passband

T stands for "twisted", as in the twisted pair cabling used to transmit the signals. See: https://www.techtarget.com/searchnetworking/definition/10BASE-T:

10BASE-T is a shorthand identifier designated by IEEE. The 10 refers to a maximum transmission speed of 10 Mbps. BASE refers to baseband signaling, which means that it can only carry Ethernet signals on the medium. T refers to twisted as in twisted-pair cabling.

Gabriel Staples
  • 36,492
  • 15
  • 194
  • 265
1

it depends on which layer you are thinking. On physical layer, it depends on the media, how electic signals are transmitted; if you think from transport layer, it is full duplex, since each peer can send and receive at same time if they want.

codewarrior
  • 723
  • 7
  • 22