100% Pass Cisco, PMP, CISA, CISM, AWS Dumps on SALE!
Get Now
01:59:56

X

What exactly is a computer port?

What exactly is a computer port?

Problem Description

 

It is said that the port number is abstracted by the operating system and used to locate a process. Then when there are two network cards on a host, each network card is bound to an IP address. If you access the same port with different IP addresses, such as 80, you should not be able to locate the same program. Then the port number should be a process abstraction for each network card, not an abstraction for each process by the operating system. I do n’t know if there is any problem with this understanding.


 

This question is particularly valuable for discussion and is shared with interested students. When a computer receives a message, it needs to deliver it to a specific process. The method of computer operating system management process is very similar to that of public security system to manage population. In order to uniquely identify a citizen, each citizen has a unique ID number, such as 31010xxxxxxxxxxx, each number is unique, this ID number is the master key of the population management system (Master Key). As long as any legal ID number is entered into the query system, the return value must be one, not multiple. If there are multiple return values, then this system is estimated to be false! The operating system also assigns a unique process ID (Process ID) to each process, including the system process of the operating system itself and the user process executed by the user. If the message carries the process number, the operating system (TCP / IP protocol stack) only needs to forward the message to the process corresponding to the process number. But unfortunately, regardless of the Ethernet frame header, IP header, TCP header, and application layer in the packet, the process number is not carried, so how can the operating system accurately transfer the packet to the real receiving process? This can't help but a clever and clever operating system design master. The master shouts to each process in advance: If you want to communicate with the outside world, you must use the Bind (address, port) function to connect your own process number with the local The IP address and port number are bound together. Otherwise, you will be at your own risk! Note: The outside world above can be other processes on the same computer, or it can be a process on any computer on the Internet. The younger brother (process) heard the boss (operating system) speak and strictly abide by the rules. One process A did this: Bind (‘1.1.1.1’, 50007). This system call message carried the process ’s process ID = 165364 and was sent to the operating system TCP / IP protocol stack. The operating system lazily took out a book to record:

(1.1.1.1, 50007) -------- 165364 Note: 1.1.1.1 is the IP address, 50007 is the port number Later when the operating system TCP / IP protocol stack receives an IP packet, it extracts the destination IP The address (located in the IP header) and the destination port number (located in the TCP header), the combination of the two is exactly (1.1.1.1, 50007). The operating system queries the small book, and immediately learns that this is process number = 165364 process A, and then notifies the process A to come and take the message away. Process B also wanted to follow suit: Bind (‘1.1.1.1’, 50007), unfortunately, the operating system refused. The rejected message is as follows: "builtins.OSError: [WinError 10048] Usually each socket address (protocol / network address / port) is allowed to be used only once." Means (1.1.1.1, 50007) this combination can uniquely identify one Process, the combination of the two is a master key (Master Key). In layman's terms, in a database management system, the primary key can uniquely lock a record. Process B (process ID = 168323) was unwilling to find that the computer had another interface address 2.2.2.2, so it passed Bind (‘2.2.2.2’, 50007), and this time it succeeded. The grandfather of the operating system trembled again and took out a small book to record it:

 

(2.2.2.2, 50007) -------- 168323

 

In this way, when a (2.2.2.2, 50007) combined message arrives, the operating system can forward it to process B with process number = 168323. The question is coming, what is the relationship between process A and process B? Processes A and B can be programs with completely different codes, or they can be programs with the same code and run in different instances in their own independent memory space (Instance). It's like you open multiple Word programs at the same time. These Word programs use the same code, but they are multiple Word instances. The problem is again, if the code of process A is really encoded that way, if it is executed on other computers, you will encounter problems, because the IP addresses of other computers may not be 1.1.1.1. In order to improve the robustness and portability of the code, such code is usually used:

Bind (‘’, 50007)

 

Where ‘’ means any IP address. In other words, not the interface IP address of the Care computer. This IP address can be 127.0.0.1, 1.1.1.1, or 192.168.1.1, whatever you want. Then this program can be executed on any computer.

 

On the same machine, a process B is also executed like this: Bind (‘’, 50007). Wow? No, because it conflicts with process A! Process B can be Bind (‘1.1.1.1’, 50007), can it be? No, it still conflicts with process A. Because 1.1.1.1 is a subset of all IP addresses. Process B panicked, so how can it be? The grandfather of the operating system said without hesitation, as long as you don't use port 50007 anymore. Process B then executes the code as follows: Bind (‘’, 50008), can it be? Congratulations, of course!

 

Usually the server code is executed in a manner similar to Bind (‘’, 50007), so the port number 50007 can uniquely identify a process, which is why the port number can uniquely identify the process number!

 

The above is the news sharing from the PASSHOT. I hope it can be inspired you. If you think today' s content is not too bad, you are welcome to share it with other friends. There are more latest Linux dumps, CCNA 200-301 dumpsCCNP Written dumps and CCIE Written dumps waiting for you.


Have any question for us?

Cisco Dumps Popular Search:

ccie data center curriculum ccie dc lab 2.1 what exactly are ccna tests for ccie lab study ccnp routing and switching syllabus how to download cisco ccna certificate cisco ccnp enterprise core 350-401 encor ccna wireless practice test ccna cyber ops dumps free ccnp route 300-101 book

Copyright © 2024 PASSHOT All rights reserved.