跳至主要内容

Download and Upload Simultaneously?

Have you ever wonder whether we can download and upload simultaneously?
Sometimes, we may listening the music online and chat with our friends, but that doesn’t really means download and upload at exact the same time. Because the the computer is faster than human being so much, if it switch its job fast enough, we can’t really tell the differences. This is the where ‘Concurrency’ and ‘Parallelism’ in computer science originates.

Before we start answering this questions, we need to introduce some terminology in network.

Duplex vs Simplex

Duplex means data can be sent in both direction of a communication system, while simplex means data can only be sent in one direction.
You can take the differences as normal street vs one-way street.

Full Duplex vs Half Duplex

Full duplex means data is sent in both direction at the same time (so we can rephrase our first question into: is our network full duplex?), while half duplex, like a single-plank bridge, you can sent in both direction, but not same time.


In order to answer our question, we need more info actually. That is, how we access the network, which also influences the answer to our question. The WiFi and Ethernet is two common forms to use network, so we focus on them.

WiFi

WiFi is a generic term for bunch of wireless protocols. The answer for WiFi is no. Because the following explanation:

WiFi devices wirelessly connect to the router using radio waves at 2.4GHz or at 5GHz. The router schedules and makes sure the correct information flows between each connected device and the Internet; without collision and loss; by a process call Time Division Duplexing (TDD) to behave like full-duplexing.

As we can see, every information is scheduled in different time slices to avoid collision, which, in terminology, is called CSMA/CA (carrier sense multiple access and collision avoid). Our packet of data for download and upload also share the media, but only one packet at the same time. In conclusion, WiFi is half-duplex.

Ethernet

The Ethernet has a similar terminology called CSMA/CD (collision detection). It sounds like even the Ethernet can’t be duplex, but we can dive deeper.
The modern Ethernet use a cable called twisted pair wires in which two conductors twisted in pairs:

The wired portion of the LAN communicates at full-duplex with two pairs of twisted wires forming the ethernet cable connection. Each pair is dedicated to transmit and receive information packets simultaneously, hence no collision of data and no interference.

The upper cites solve our question, but what does CSMA/CD mean?

In a modern Ethernet, the stations do not all share one channel through a shared cable or a simple repeater hub; instead, each station communicates with a switch, which in turn forwards that traffic to the destination station. In this topology, collisions are only possible if station and switch attempt to communicate with each other at the same time, and collisions are limited to this link. Furthermore, the 10BASE-T standard introduced a full duplex mode of operation which became common with Fast Ethernet and the de facto standard with Gigabit Ethernet. In full duplex, switch and station can send and receive simultaneously, and therefore modern Ethernets are completely collision-free.

Here, we can understand that it is because in early year, multiple station connect to same cable, which may cause collision. And now, every station connect to router/switch directly, so is collision free.

Conclusion

When we using WiFi, we can’t download and upload at the same time, but using Ethernet can.
What the use of knowing that? Maybe you can plug in a Ethernet cable rather than using WiFi when you play game and the latency is so high. Maybe you can understand why speed of your WiFi is so slow.

Ref

Written with StackEdit.

评论

此博客中的热门博文

Spring Boot: Customize Environment

Spring Boot: Customize Environment Environment variable is a very commonly used feature in daily programming: used in init script used in startup configuration used by logging etc In Spring Boot, all environment variables are a part of properties in Spring context and managed by Environment abstraction. Because Spring Boot can handle the parse of configuration files, when we want to implement a project which uses yml file as a separate config file, we choose the Spring Boot. The following is the problems we met when we implementing the parse of yml file and it is recorded for future reader. Bind to Class Property values can be injected directly into your beans using the @Value annotation, accessed via Spring’s Environment abstraction or bound to structured objects via @ConfigurationProperties. As the document says, there exists three ways to access properties in *.properties or *.yml : @Value : access single value Environment : can access multi...

Elasticsearch: Join and SubQuery

Elasticsearch: Join and SubQuery Tony was bothered by the recent change of search engine requirement: they want the functionality of SQL-like join in Elasticsearch! “They are crazy! How can they think like that. Didn’t they understand that Elasticsearch is kind-of NoSQL 1 in which every index should be independent and self-contained? In this way, every index can work independently and scale as they like without considering other indexes, so the performance can boost. Following this design principle, Elasticsearch has little related supports.” Tony thought, after listening their requirements. Leader notice tony’s unwillingness and said, “Maybe it is hard to do, but the requirement is reasonable. We need to search person by his friends, didn’t we? What’s more, the harder to implement, the more you can learn from it, right?” Tony thought leader’s word does make sense so he set out to do the related implementations Application-Side Join “The first implementation ...

Learn Spring Expression Language

When reading the source code of some Spring based projects, we can see some code like following: @Value( "${env}" ) private int value ; and like following: @Autowired public void configure (MovieFinder movieFinder, @ Value ("#{ systemProperties[ 'user.region' ] } ") String defaultLocale) { this.movieFinder = movieFinder; this.defaultLocale = defaultLocale; } In this way, we can inject values from different sources very conveniently, and this is the features of Spring EL. What is Spring EL? How to use this handy feature to assist our developments? Today, we are going to learn some basics of Spring EL. Features The full name of Spring EL is Spring Expression Language, which exists in form of Java string and evaluated by Spring. It supports many syntax, from simple property access to complex safe navigation – method invocation when object is not null. And the following is the feature list from Spring EL document : ...