Basic concepts of the network TCP, UDP, unicast (Unicast), Multicast (multicast) (multicast)

Source: Internet
Author: User


The chapter is quite low, but very important!


Everything around us is almost dependent on abstracting things down to a lower level and at some point detailing them in some design concepts. The interface layer is clear and the target is very focused, the application does not consider how the operating system works, the operating system does not have to consider how the hardware works, the 4th layer of the OSI model does not need to consider how the third layer works. So we just need to focus on a certain layer, when the following layers are working properly, but is that OK? Suppose you write an app, you better know how the OS works. and consider how the database stores characters, the same. A good operating system must understand how the hardware works. Suppose you think TCP does not have to consider the implementation of IP that is wrong. So, here even if we do Web applications and services are performed on the OSI layer 7th. Now let's go down to the 4th floor (or lower) and see what's going on there. We will discuss the difference between TCP and UDP and what is multicast (multicast). How it works and how not to work. Believe me. These things are very practical.

First of all, HTTP, we are using directly with this Protocol, HTTP and some other network applications (sql*net, WCI Search) work together on the 7th layer of the network, the application layer, on the 4th layer of TCP, what is TCP? TCP (Transmission Control Protocol) and UDP are the main low-level network protocols for the Internet. They are all built on a layer of IP (Internet Protocol). The IP is one layer below them, on the 3rd floor. So to understand TCP, look at the IP first, and then look back at what TCP is doing on top.

IP: (Internet Protocol)

IP has the ability to send a packet from one place to another. This protocol is implemented by providing a specific address (IP address) of a "place" or "device" and specifying how packets are moved between devices by address. Today, the difference between IP and the next layer of protocol is that devices on the 2nd level always know exactly how to send information to other network devices (layer 2nd is the link layer). Usually expressed as Ethernet or WiFi) on the 2nd floor. The device knows not only how to send data to the destination (usually the address represented by the MAC address), but also whether the data can reach its destination at the same time. (Take a sample, for example.) Ethernet and WiFi simply broadcast the entire packet to the entire network. The destination device listens to this MAC address and then extracts the packet. If the destination does not exist or is not listening, the Ethernet data cannot be reached. By the way, the network "sniffer" is using this broadcasting mechanism to work. The PPP protocol used for modem dial-up connections can send whatever thing to a single target: the number you dial.

IP provides a way to send data to other networks. A device does not need to know the detailed path to be able to put one thing to another there is a network, this is the origin of "inter-net": "Between the network." It defines a packet with a destination address by specifying a routing rule. This is the main rule: Assume that the target is sent directly locally (you know where the target is, because they are on the same network), or you find an address in a list of routes to send. A route follows only one protocol. Unless the address belongs to two or more different networks at the same time, there will be different local destination addresses in this case, and a longer route list will be generated to point to many other unknown addresses. So far, IP can not do anything other than to send a single packet to a single address, of course, it can receive packets from whatever network (unlike other low-level protocols), but that's all.

Obvious disadvantages such as the following:


    • IP does not provide notification of send, receive, error, etc.

    • IP does not provide tokens such as "port number" to isolate packets sent to the destination IP address.
    • IP does not provide two-way communication.
    • IP does not sort or group multiple packages in any way.


The simplest analogy is that IP is like postal service. You live in your mailbox and throw a postcard with an address, and then it's mailed to the address you wrote. Sent to. Or not, you don't know. When the postcard is sent to the house, you don't know if the other roommate has read it. Suppose you think of a reply, your recipient can't write on the same card and give it to the postman, they write on their cards, put stamps on them, and address them. Finally send it by myself.

TCP: Transmission Control Protocol

Although the IP protocol does not provide these features, TCP can.

Let's say you take a look at the features that IP doesn't provide, and then look at the post and then you can tell: "Eh? Of course can do two-way communication!

People write and go back and forth as if they had been talking. " Or, "You can directly ask the addressee or the post office to return a letter to you." Or, "Forget it, idiot, you can mark the postcard with a number and tell the recipient to read it sequentially, assuming there's a loss to tell you." Well, you're right, that's what TCP does. It uses the primary IP (or postal Service) and specifies how to add some additional information. To implement these features. So, what TCP really solves is how to reliably communicate multiple IP devices today.

God horse means? This means that you can send a series of messages (packages). Based on a selected session (port or connection), the package will be received in the same order, and will not be dropped when sent, and will not be repeated. It does this: write a port number for all the packages. Used to make other connections and conversations different. At the same time give each package a serial number, the receiver will be able to know whether the transmission is lost.

After that, TCP specifies that the receiver responds to each received data (it does not force each packet to respond.) Can simply reply: "I received all the data before the 13,456th byte, or" I received data between 845 and 13433 ", so that the sender knows whether to send again. At last. Communication is bi-directional. Not the only answer. It also allows the receiver to directly live back messages without specifying an address, a bit like attaching a reply envelope to each package that writes its own address.

As you can see, TCP actually needs to do a lot of work if the packets are dropped or the order is incorrect. Suppose we continue the post-office theory. TCP is like a personal assistant who helps you collect, sort, and sequence mail. Get and read. Reply Back again. Assuming the postal service is super reliable, the task of TCP is very easy. Just need to be an intermediary to distribute the papers. Suppose the postal service loses a lot of staff. Or there is a lot of mail to deal with. TCP is going to do a lot of work, send back the lost packets, track and store lots of information.

UDP: User Data protocol

UDP is much simpler than TCP, as it does with IP, plus the concept of port. So you send the message to a recipient with an IP address. It has no sequential or connected, or bidirectional connection, and no answer. You should think that UDP is unreliable, because you know that TCP is a reliable connection scheme, but in fact, in the same network segment, or on a well-signaled LAN, UDP is actually very reliable.

If no packet is dropped and the packet arrives sequentially (this is almost the normal of the short LAN). There is no need to transfer the package again. So TCP's full answer and wait is just a waste of time. Add Network latency. For applications that can tolerate packet loss (real-time audio and video), even if the network is not power. UDP is also generally a good solution.

It is also used frequently for small messages and notifications. For example, both DHCP and DNS use UDP.

It is worth mentioning that the UNIX network file System (NFS) is using UDP on the LAN.

You might think that a file system should require a reliable TCP connection, but the NFS implementation thinks that UDP can get better performance. and establish a special mechanism to guarantee the reliability.

Incidentally, please. It is called a "User Datagram Protocol" for a reason. Because it was designed by a bunch of system administrators. "Datagram" is a "package" and a name, "user" does not have any practical meaning, just like "you".

This means that the computer program has nothing to do with the operating system. The reason is that the low-level IP is written by the person who writes the OS, but UDP provides a lot of the same functionality as the datagram, serving the "user" program (not the OS).

Multicast (multicasting)

This simplifies the discussion of the next tcp/ip/udp, by default we know that IP (UDP and TCP) can send packets to a network with a single device. The more accurate point is that IP sends packets from an IP address to an IP address. Multicast's trick is to send a packet to multiple devices at the same time, to designate a specific IP address as a multicast address, and to send it to multiple devices at the same point.

IP multicast The first thing to know is that there is only UDP multicast, there is no TCP multicast such things, why? The focus of multicasting is to efficiently send the same package as much as possible to different, possibly unknown devices. However, TCP connections may require packet loss or delay or reassembly order. These operations can be resource-intensive. Not suitable for many scenarios that use multicasting.

(At the same time multicast does not know whether the sent packets have arrived, this also causes the use of TCP).

As you know earlier, non-multicast UDP (TCP) messages that are used frequently are called unicast (unicast).

Below we need to know that multicasting is often unable to route to a network. The following are some of the reasons:

    • The TTL of most multicast packets is relatively low: all IP packets have a "time to Live" (time-to-live), or TTL. Unlike DNS records, the TTL specifies the maximum number of times a packet skips a network before it reaches its destination. Unicast packets are usually agreed to traverse 30 networks (for example, to be routed or "jump" over 29 routes), usually less than 15 "hops" through the network, so the 30 limit is often used when the network configuration is very bad when the packet is killed. However, many programs send multicast with the TTL set to a very low value, typically 0 (so that the message does not leave its own device).
    • A setting of 1 indicates that only computers that can be sent to the local network are set to 2 to be able to traverse only one route. Very few applications want to advertise multiple unknown devices to the entire campus network. Will not be sent to the entire network.
    • Many routes have set a very high TTL threshold: very many network routers. In particular, WAN Routing and Internet Gateway routing have very high TTL thresholds so that they do not send multicast packets with these low TTL (such as 15). This prevents multicast from being leaked from the local network.

    • Routers are generally configured to not send multicast at all, or simply send some specific addresses, or be configured to block multicast packets.

UDP multicasting can be a bit too evil, but it can be used much more often than you estimate. It will not be used for web video sites such as YouTube. Because it needs to send the video when the user is on demand, not the same time to all users, the same is not used for VoIP voice. It is used for very much discovery and self-active configuration. such as Skype, ITunes and UPnP, are also occasionally used for WCI portals.

From https://blogs.oracle.com/lmukadam/entry/tcp_udp_unicast_multicast_i_th


Basic concepts of the network TCP, UDP, unicast (Unicast), Multicast (multicast) (multicast)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.