简体   繁体   English

网络中的IP地址和端口号有什么区别?

[英]What is Difference between IP address and Port Number in Networking?

网络中的IP地址和端口号有什么区别?

IP address is address of the system in the Network. IP 地址是网络中系统的地址。

Port is address of the service within the System.端口是系统内服务的地址。

So IP address + Port defines address of the particular service on the particular system.所以IP地址+端口定义了特定系统上特定服务的地址。

IP 地址用于标识网络中的一个主机或一组主机,而端口号用于标识在主机中运行的特定服务

Think about how many application layer protocols exist ( HTTP , FTP , DNS , SSH , etc).考虑存在多少应用层协议( HTTPFTPDNSSSH等)。 Now think about how many task / process / programs exist within your device trying to communicate over the internet.现在想想你的设备中有多少任务/进程/程序试图通过互联网进行通信。 Would it be possible just one address, the IP address, to be able to handle all these different assignments and types of protocols alone?是否有可能只有一个地址,即IP地址,能够单独处理所有这些不同的分配和协议类型? The answer is no.答案是否定的。

The IP address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. IP地址是分配给连接到使用 Internet 协议进行通信的计算机网络的每个设备的数字标签。 The port number is used so the data is directed to the correct location within this device .使用端口号是为了将数据定向到该设备内的正确位置。

The IP and the port number form the structure IP:port number, 192.168.1.1:8080 for example, and the port number can hold 65536 numbers, with the following division: IP端口号组成结构IP:端口号,例如192.168.1.1:8080端口号可以容纳65536个数字,划分如下:

  • 0 to 1023 - Well known port numbers. 0 到 1023 - 众所周知的端口号。 Only special companies like Apple QuickTime, MSN, SQL Services, Gopher Services and other prominent services have these port numbers.只有像 Apple QuickTime、MSN、SQL Services、Gopher Services 和其他著名服务这样的特殊公司才有这些端口号。

  • 1024 to 49151 - Registered ports; 1024 到 49151 - 注册端口; meaning they can be registered to specific protocols by software corporations.这意味着它们可以被软件公司注册到特定的协议。

  • 49152 to 65536 - Dynamic or private ports; 49152 到 65536 - 动态或专用端口; meaning that they can be used by just about anybody.这意味着它们几乎可以被任何人使用。

Port number is used to identify an application/services which you want to talk to on your system.端口号用于标识您要在系统上与之通信的应用程序/服务。 Some predefined ports like 80 = HTTP server, 23 = Telnet.一些预定义的端口,如 80 = HTTP 服务器,23 = Telnet。

You identify a host uniquely (globally) by its IP address.您可以通过 IP 地址唯一地(全局)识别主机。 So if I ever wanted to access your laptop via telnet then I'd use the IP address given to you by your ISP and the port 23因此,如果我想通过 telnet 访问您的笔记本电脑,那么我将使用您的 ISP 提供给您的 IP 地址和端口 23

A MAC address is a layer-2 address. MAC 地址是第 2 层地址。 It is used by some layer-2 protocols, eg ethernet and Wi-Fi.它被一些第 2 层协议使用,例如以太网和 Wi-Fi。 There are 48-bit and 64-bit MAC addresses.有 48 位和 64 位 MAC 地址。 Some layer-2 protocols use different addressing.一些第 2 层协议使用不同的寻址方式。

An IP address is the address of the layer-3 IP protocol. IP地址是三层IP协议的地址。 Different layer-3 protocols use different addressing, eg IPv4, IPX, and IPv6 each have different addressing.不同的三层协议使用不同的寻址方式,例如 IPv4、IPX 和 IPv6 都有不同的寻址方式。

A port number is a layer-4 address used by some layer-4 protocols, eg TCP and UDP.端口号是某些第 4 层协议(例如 TCP 和 UDP)使用的第 4 层地址。 Some layer-4 protocols use different addressing, or none at all.一些第 4 层协议使用不同的寻址,或者根本不使用。

TCP example: RFC 793, TRANSMISSION CONTROL PROTOCOL TCP 示例: RFC 793,传输控制协议

Multiplexing:多路复用:

To allow for many processes within a single Host to use TCP communication facilities simultaneously, the TCP provides a set of addresses or ports within each host .为了允许单个主机内的多个进程同时使用 TCP 通信设施, TCP 在每个主机内提供了一组地址或端口 Concatenated with the network and host addresses from the internet communication layer, this forms a socket.与来自 Internet 通信层的网络和主机地址连接,形成一个套接字。 A pair of sockets uniquely identifies each connection.一对套接字唯一标识每个连接。 That is, a socket may be simultaneously used in multiple connections.也就是说,一个套接字可以同时用于多个连接。

You may want to learn more about the network layers.您可能想了解有关网络层的更多信息。

Simply:简单地说:

  • A socket is like a telephone (ie end to end device for communication)套接字就像电话(即用于通信的端到端设备)
  • IP is like your telephone number (ie address of your socket) IP就像你的电话号码(即你的socket地址)
  • Port is like the person you want to talk to (ie the service you want to order from that address)端口就像您要与之交谈的人(即您要从该地址订购的服务)

In networking, generally a socket is (IP+Port)在网络中,一般一个socket是(IP+Port)

IP address: Ip address is a address of your system, it assign when your system connects to internet.There are two types of ip address available here among first one is dynamic which invokes at your system in online. IP 地址: IP 地址是您系统的地址,它是在您的系统连接到 Internet 时分配的。这里有两种类型的 IP 地址可用,第一种是动态的,它在线调用您的系统。 Second one is static, which assign when your system get in offline.第二个是静态的,它在您的系统离线时分配。

port address Port address is an Id of server such as your using apache server that get port number default 8080 is id of apache server,If you can change server port number.端口地址端口地址是服务器的ID,例如您使用的获取端口号的apache服务器默认8080是apache服务器的ID,如果您可以更改服务器端口号。

IP address is your system domain name or socket address of specific system like 192.168.0.1 IP 地址是您的系统域名或特定系统的套接字地址,例如 192.168.0.1

but the port number is the number of specific location or folder where to you want to write your file or any file transfer like: 3308但端口号是您要写入文件或任何文件传输的特定位置或文件夹的编号,例如:3308

The IP address of your computer (host) is the mix of the network ID of the ISP/any other provider (uniquely provided by the ICANN group) and the host name (provided by the Network administrator).您的计算机(主机)的 IP 地址是 ISP/任何其他提供商的网络 ID(由 ICANN 组唯一提供)和主机名(由网络管理员提供)的组合。 The Network ID is unique for all the network and among two networks, we can have same host names but on the same network, the host names can not be the same. Network ID对于所有网络都是唯一的,在两个网络之间,我们可以有相同的主机名,但在同一个网络上,主机名不能相同。 So, this is how the host can be identified on the network and data can be transferred.因此,这就是在网络上识别主机和传输数据的方式。 But on the same host multiple applications will be running and once the data reach to the host, we need an identifier to recognize which application data is this TCP Segment/UDP datagram.但是在同一台主机上将运行多个应用程序,一旦数据到达主机,我们需要一个标识符来识别哪个应用程序数据是这个 TCP Segment/UDP 数据报。

The Port number is 16 bits (possibly 65K application can run) and assigned by the Network operating system when the application process creates the sockets.端口号为 16 位(可能 65K 应用程序可以运行),由网络操作系统在应用程序进程创建套接字时分配。 On the Server side, the port numbers are well defined numbers (HTTP- Port #80, SMTP- Port#25).在服务器端,端口号是明确定义的数字(HTTP-Port #80、SMTP-Port#25)。 The port number is transport layer addressing (L4) and goes in the header of TCP/UDP.端口号是传输层寻址 (L4),位于 TCP/UDP 的标头中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM