WO2024103716A1 - Method and apparatus for managing subnets in link, and device and readable medium - Google Patents

Method and apparatus for managing subnets in link, and device and readable medium Download PDF

Info

Publication number
WO2024103716A1
WO2024103716A1 PCT/CN2023/100829 CN2023100829W WO2024103716A1 WO 2024103716 A1 WO2024103716 A1 WO 2024103716A1 CN 2023100829 W CN2023100829 W CN 2023100829W WO 2024103716 A1 WO2024103716 A1 WO 2024103716A1
Authority
WO
WIPO (PCT)
Prior art keywords
subnet
information
configuration file
connection
rdma
Prior art date
Application number
PCT/CN2023/100829
Other languages
French (fr)
Chinese (zh)
Inventor
张砚凯
赵帅
Original Assignee
苏州元脑智能科技有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 苏州元脑智能科技有限公司 filed Critical 苏州元脑智能科技有限公司
Publication of WO2024103716A1 publication Critical patent/WO2024103716A1/en

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/2866Architectures; Arrangements
    • H04L67/30Profiles
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/16Combinations of two or more digital computers each having at least an arithmetic unit, a program unit and a register, e.g. for a simultaneous processing of several programs
    • G06F15/163Interprocessor communication
    • G06F15/173Interprocessor communication using an interconnection network, e.g. matrix, shuffle, pyramid, star, snowflake
    • G06F15/17306Intercommunication techniques
    • G06F15/17331Distributed shared memory [DSM], e.g. remote direct memory access [RDMA]

Definitions

  • the present application relates to the field of computers, and more specifically to a method, apparatus, device and readable medium for managing subnets in a link.
  • RDMA Remote-Direct Memory Access
  • Mellanox Mellanox
  • Intel Intel and other companies.
  • RDMA can bypass the operating system protocol stack, reduce the number of memory copies, and avoid the system state kernel state switching overhead, thereby providing higher bandwidth, lower latency, and occupying less system resources.
  • RDMA is similar to TCP, so it also has a process of establishing a connection.
  • CM Connection Management, a component of the RDMA driver, provides some events in the process of establishing a connection
  • plays a pivotal role in the process of establishing a connection It implements some events on the driver side. Users can rely on these events to know what stage the current connection is in during the process of establishing a connection so as to make corresponding processing later.
  • the purpose of the embodiments of the present application is to propose a method, device, equipment and readable medium for subnet management in a link.
  • one aspect of an embodiment of the present application provides a method for subnet management in a link, comprising the following steps:
  • the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively.
  • creating a configuration file at a preset location under a directory of the system, and writing the subnet information to be connected into the configuration file includes:
  • the format of the subnet information is IP address/subnet mask.
  • parsing the configuration file to obtain subnet information includes:
  • the range of the IP address of the subnet is calculated according to the subnet information, including:
  • N 2 ⁇ (32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
  • the range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
  • the host calls a connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
  • it also includes:
  • the IP address of the subnet is recorded;
  • the host In response to the host failing to establish a connection with a subnet, the host re-establishes a connection with the subnet to which the connection failed after a threshold time has passed until a threshold number of times is reached.
  • it also includes:
  • the connection being established with the subnet is stopped, and the established connection is disconnected.
  • Another aspect of the embodiment of the present application further provides a device for subnet management in a link, the device comprising:
  • a writing module wherein the writing module is configured to create a configuration file in a preset location under a system directory, and write the subnet information to be connected into the configuration file;
  • an acquisition module configured to parse the configuration file to acquire the subnet information in response to receiving an instruction to connect to each subnet;
  • a calculation module the calculation module is configured to calculate a range of IP addresses of a subnet according to the subnet information
  • connection module is configured to, according to the calculated range of the IP address of the subnet, enable the host to call a connection establishment mechanism to establish connections with the IP addresses in the range respectively.
  • the writing module is further configured as:
  • the format of the subnet information is IP address/subnet mask.
  • the acquisition module is further configured to:
  • the computing module is further configured to:
  • N 2 ⁇ (32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
  • the range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
  • connection module is further configured as:
  • a deletion module is further included, and the deletion module is configured as follows:
  • the connection being established with the subnet is stopped, and the established connection is disconnected.
  • Another aspect of the embodiments of the present application further provides a computer device, the computer device comprising:
  • the memory stores computer instructions executable on the processor, and the instructions implement the steps of any one of the above methods when executed by the processor.
  • Another aspect of the embodiments of the present application further provides a non-volatile readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above methods are implemented.
  • the method for subnet management in a link provided by the embodiment of the present application creates a configuration file at a preset location under the system directory, and writes the subnet information to be connected into the configuration file; in response to receiving an instruction to connect to each subnet, the configuration file is parsed to obtain the subnet information; the range of the IP address of the subnet is calculated according to the subnet information; based on the calculated range of the IP address of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses within the range respectively.
  • the technical solution can realize automatic connection between multiple devices, reduce manual operations, save labor costs, and avoid errors caused by human operations.
  • FIG1 is a schematic flow chart of a method for managing subnets in a link according to an embodiment of the present application
  • FIG2 is a schematic diagram of a device for subnet management in a link according to an embodiment of the present application
  • FIG3 is a schematic diagram of a computer device according to an embodiment of the present application.
  • FIG. 4 is a schematic diagram of a non-volatile readable storage medium according to an embodiment of the present application.
  • FIG1 shows a schematic flow chart of the method.
  • the method may include the following steps:
  • S1 creates a configuration file in a preset location under the system directory, and writes the subnet information to be connected into the configuration file.
  • Design a configuration file to store subnet discovery configuration information save the configuration file on the local system, and record the saved location and the name of the configuration file.
  • create a configuration file in the system directory and create a configuration file named "subnet" in the /data directory.
  • the user writes the subnet information expected to be connected into the subnet configuration file.
  • the format of the subnet information is IP address/subnet mask. For example, the user writes 192.168.1.1/28 in the configuration file.
  • the IP in front represents the first IP address in the subnet
  • the 28 behind is the value of the subnet mask, which can also be a user-defined value, indicating the range of IP addresses of the subnet.
  • S2 parses the configuration file to obtain the subnet information.
  • the host reads the configuration file according to the location and name of the configuration file recorded, and obtains the subnet information in the configuration file, that is, obtains the value of the first IP address and the subnet mask or a custom value.
  • S3 calculates the range of the subnet IP address according to the subnet information.
  • the host calls the connection establishment mechanism to establish connections with the IP addresses in the range. After obtaining the IP address range, the host establishes a connection to each IP address in turn, relying on the RDMA CM connection establishment mechanism. From initiating a connection to successfully connecting, a total of three CM events (RDMA_CM_EVENT_ADDR_RESOLVED, RDMA_CM_EVENT_ROUTE_RESOLVED, RDMA_CM_EVENT_ESTABLISHED) are experienced. These three events are generated after calling three APIs (rdma_resolve_addr, rdma_resolve_route, rdma_connect).
  • the host sends rdma_resolve_addr (cm_id, src_ip, dst_ip, timeout), where src_ip is the host IP address, dst_ip is the target IP address (i.e., the IP address in the IP address range), cm_id is a structure pointer of type (struct rdma_cm_id*), and establishing a connection requires creating the structure pointer by calling the rdma_create_id interface, and timeout is a custom timeout. The rdma_resolve_add process will be blocked.
  • rdma_resolve_addr does not return a result within the specified time, the function will time out and exit, indicating that rdma_resolve_addr has failed and needs to be retried until it succeeds. If the link is connected, you will receive RDMA_CM_EVENT_ADDR_RESOLVED to indicate success. If you receive RDMA_CM_EVENT_ADDR_ERROR, it means that there is a problem with the link and the connection cannot be established. At this time, you can send a warning to the administrator or wait for a certain period of time and try again. After receiving the success After receiving the return information, the host sends rdma_resolve_route(cm_id, timeout).
  • RDMA_CM_EVENT_ROUTE_RESOLVED If RDMA_CM_EVENT_ROUTE_RESOLVED is received, it means the route resolution is successful. If RDMA_CM_EVENT_ROUTE_ERROR is received, it means failure.
  • the host After receiving the successful return information, the host sends rdma_connect(cm_id, arg), where arg is a structure pointer of type (struct rdma_conn_param*). Before calling rdma_connect to initiate a connection, you need to apply for a struct rdma_conn_param structure space. The main purpose is to fill in some attribute information of the local connection, such as queue depth, current queue number and other information to tell the target end of the connection.
  • RDMA_CM_EVENT_ESTABLISHED If RDMA_CM_EVENT_ESTABLISHED is received, it indicates that the connection is established successfully. If other events are received, it indicates that the connection fails. If the connection is established successfully with the current IP address, the current IP address information is recorded and the connection with the next IP address is started. When all IP addresses in the subnet have tried to establish a connection, a timer is set, for example, to try to establish a connection with the IP address that was not successfully connected after one minute, until the connection is successful or the maximum number of retries is reached.
  • creating a configuration file in a preset location under a system directory, and writing the subnet information to be connected into the configuration file includes:
  • the format of the subnet information is IP address/subnet mask. For example, if the user writes 192.168.1.1/28 in the configuration file, the first IP represents the first IP address in the subnet, and the following 28 is the value of the subnet mask, which can also be a user-defined value, indicating the range of the subnet IP address.
  • the subnet mask or the customized value ranges from 0 to 32.
  • parsing the configuration file to obtain the subnet information includes:
  • the range of the IP address of the subnet calculated according to the subnet information includes:
  • N 2 ⁇ (32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
  • the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
  • RDMA Call the first API of RDMA and send information to determine whether the link is connected, the information is rdma_resolve_addr (cm_id, src_ip, dst_ip, timeout), where src_ip is the IP address of the host, and dst_ip is an IP address in the IP address range;
  • the third return information In response to receiving the third return information indicating that the connection is successfully established, it is determined that the local machine has successfully established a connection with an IP address in the IP address range, wherein the third return information is RDMA_CM_EVENT_ESTABLISHED. If the return information received in any step indicates failure, the next step is not performed, and a corresponding alarm may be issued to the management, or a retry may be performed after a certain period of time. When an IP address is successfully connected, the same steps are continued to establish a connection with the next IP address until all subnets are successfully connected.
  • the IP address of the subnet is recorded;
  • the host In response to the host failing to establish a connection with the subnet, the host re-establishes a connection with the subnet that failed to establish a connection every threshold time until the threshold number of times is reached. Or when all IP addresses in the subnet have tried to establish a connection, a timer is set, such as one minute later, to try to establish a connection with the IP address that failed to connect again until the connection is successful or the maximum number of retries is reached.
  • the connection being established with the subnet is stopped, and the established connection is disconnected. If the user wishes to disconnect all devices connected in the subnet, he only needs to delete the subnet information in the configuration file. When it is detected that there is no subnet information to be connected, the current connection is terminated first, and all IP addresses that have been successfully connected within the subnet range are disconnected.
  • the method disclosed in the embodiment of the present application can also be implemented as a computer program executed by a CPU, and the computer program can be stored in a non-volatile readable storage medium.
  • the computer program is executed by the CPU, the above functions defined in the method disclosed in the embodiment of the present application are performed.
  • a second aspect of an embodiment of the present application provides a device for subnet management in a link.
  • the device 200 includes:
  • a writing module wherein the writing module is configured to create a configuration file in a preset location under a system directory, and write the subnet information to be connected into the configuration file;
  • an acquisition module configured to parse the configuration file to acquire the subnet information in response to receiving an instruction to connect to each subnet;
  • a calculation module the calculation module is configured to calculate a range of IP addresses of a subnet according to the subnet information
  • connection module is configured to, according to the calculated range of the IP address of the subnet, enable the host to call a connection establishment mechanism to establish connections with the IP addresses in the range respectively.
  • the writing module is further configured as:
  • the format of the subnet information is IP address/subnet mask.
  • the acquisition module is further configured to:
  • the calculation module is further configured as:
  • N 2 ⁇ (32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
  • the range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
  • connection module is further configured as:
  • RDMA_CM_EVENT_ADDR_RESOLVED the second API of RDMA is called and rdma_resolve_route(cm_id, timeout) is sent;
  • rdma_connect (cm_id, arg) is sent;
  • a deletion module is further included, and the deletion module is configured as follows:
  • the connection being established with the subnet is stopped, and the established connection is disconnected.
  • FIG3 shows a schematic diagram of an embodiment of the computer device provided by the present application.
  • the embodiment of the present application includes the following apparatus: at least one processor 21; and a memory 22, the memory 22 stores computer instructions 23 that can be run on the processor, and when the instructions are executed by the processor, the following method is implemented:
  • the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively.
  • creating a configuration file in a preset location under a system directory, and writing the subnet information to be connected into the configuration file includes:
  • the format of the subnet information is IP address/subnet mask.
  • parsing the configuration file to obtain the subnet information includes:
  • the range of the IP address of the subnet calculated according to the subnet information includes:
  • N 2 ⁇ (32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
  • the range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
  • the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
  • RDMA_CM_EVENT_ADDR_RESOLVED the second API of RDMA is called and rdma_resolve_route(cm_id, timeout) is sent;
  • rdma_connect (cm_id, arg) is sent;
  • the IP address of the subnet is recorded;
  • the host In response to the host failing to establish a connection with a subnet, the host re-establishes a connection with the subnet to which the connection failed after a threshold time has passed until a threshold number of times is reached.
  • the connection being established with the subnet is stopped, and the established connection is disconnected.
  • FIG4 is a schematic diagram of an embodiment of the non-volatile readable storage medium provided by the present application.
  • the non-volatile readable storage medium 31 stores a computer program 32 that performs the following method when executed by a processor:
  • the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively.
  • creating a configuration file in a preset location under a system directory, and writing the subnet information to be connected into the configuration file includes:
  • the format of the subnet information is IP address/subnet mask.
  • parsing the configuration file to obtain the subnet information includes:
  • the range of the IP address of the subnet calculated according to the subnet information includes:
  • N 2 ⁇ (32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
  • the range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
  • the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
  • RDMA_CM_EVENT_ADDR_RESOLVED the second API of RDMA is called and rdma_resolve_route(cm_id, timeout) is sent;
  • rdma_connect (cm_id, arg) is sent;
  • the IP address of the subnet is recorded;
  • the host In response to the host failing to establish a connection with a subnet, the host re-establishes a connection with the subnet to which the connection failed after a threshold time has passed until a threshold number of times is reached.
  • the connection being established with the subnet is stopped, and the established connection is disconnected.
  • the method disclosed in the embodiment of the present application can also be implemented as a computer program executed by a processor, and the computer program can be stored in a non-volatile readable storage medium.
  • the computer program is executed by the processor, the above functions defined in the method disclosed in the embodiment of the present application are performed.
  • the above method steps and system units may also be implemented using a controller and a non-volatile readable storage medium for storing a computer program that enables the controller to implement the above steps or unit functions.
  • the function can be implemented in hardware, software, firmware or any combination thereof. If implemented in software, the function can be stored on a computer-readable medium or transmitted by a computer-readable medium as one or more instructions or codes.
  • Computer-readable media include computer storage media and communication media, and the communication media include any media that helps to transfer a computer program from one location to another.
  • the storage medium can be any available medium that can be accessed by a general or special computer.
  • the computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage devices, disk storage devices or other magnetic storage devices, or any other medium that can be used to carry or store the required program code in the form of an instruction or data structure and can be accessed by a general or special computer or a general or special processor.
  • any connection can be appropriately referred to as a computer-readable medium.
  • disk and disc include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk, Blu-ray disc, wherein disks usually reproduce data magnetically, while optical discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Theoretical Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

Provided in the present application are a method and apparatus for managing subnets in a link, and a device and a readable medium. The method comprises: creating a configuration file at a preset position under a directory of a system, and writing, into the configuration file, information of subnets to be connected to; in response to receiving instructions for connecting to the subnets, parsing the configuration file so as to acquire the information of the subnets; calculating the range of IP addresses of the subnets according to the information of the subnets; and according to the calculated range of the IP addresses of the subnets, a host calling a connection establishment mechanism to respectively establish connections with the IP addresses within the range. By means of the solution of the present application, automatic connection between a plurality of devices can be realized, thereby reducing manual operations, saving on labor costs, and avoiding errors occurring in the human operations. The present application relates to the field of computers.

Description

一种链路中子网管理的方法、装置、设备及可读介质A method, device, equipment and readable medium for subnet management in a link
相关申请的交叉引用CROSS-REFERENCE TO RELATED APPLICATIONS
本申请要求于2022年11月16日提交中国专利局,申请号为202211430496.7,申请名称为“一种链路中子网管理的方法、装置、设备及可读介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims priority to a Chinese patent application filed with the China Patent Office on November 16, 2022, with application number 202211430496.7 and application name “A method, device, equipment and readable medium for subnet management in a link”, all contents of which are incorporated by reference in this application.
技术领域Technical Field
本申请涉及计算机领域,并且更具体地涉及一种链路中子网管理的方法、装置、设备及可读介质。The present application relates to the field of computers, and more specifically to a method, apparatus, device and readable medium for managing subnets in a link.
背景技术Background technique
RDMA(Remote-Direct Memory Access,远程内存直接访问)是Mellanox、Intel等公司推出的高速网络技术,与传统网络技术相比,RDMA能够绕过操作系统协议栈,减少内存拷贝次数,避免系统态内核态切换开销,从而提供更高带宽、更低时延、占用更少的系统资源。RDMA (Remote-Direct Memory Access) is a high-speed network technology launched by Mellanox, Intel and other companies. Compared with traditional network technology, RDMA can bypass the operating system protocol stack, reduce the number of memory copies, and avoid the system state kernel state switching overhead, thereby providing higher bandwidth, lower latency, and occupying less system resources.
以上是RDMA技术作为一种新兴网络传输技术的优势,基本原理与传统的TCP技术类似。因厂商的推广以及先行者们的奉献,在开源网站上也能找到部分RDMA相关应用的源码。RDMA因与TCP类似,所以也有建立连接的过程。CM(Connection Management,连接管理,是RDMA驱动的一个组成部件,提供建立连接过程中的一些事件)作为RDMA驱动用户态一个组成部分,其在建立连接的过程中有着举足轻重的地位,它在驱动侧实现了一些事件,用户在建立连接过程中依靠这些事件可以知道当前连接处于什么阶段以便后续做相应处理。众所周知TCP是服务端与客户端之间建立连接,并实现两者间的网络通信,RDMA也是如此,在如今复杂的网络环境下,万物互联的时代,连接情景复杂,连接数量众多,当同一个交换机上或者局域网内有多个设备的时候,依靠人工依次实现这些设备之间的连接是一个极其复杂的任务。The above are the advantages of RDMA technology as an emerging network transmission technology. The basic principle is similar to the traditional TCP technology. Due to the promotion of manufacturers and the dedication of pioneers, the source code of some RDMA-related applications can also be found on open source websites. RDMA is similar to TCP, so it also has a process of establishing a connection. CM (Connection Management, a component of the RDMA driver, provides some events in the process of establishing a connection) as a component of the RDMA driver user state, plays a pivotal role in the process of establishing a connection. It implements some events on the driver side. Users can rely on these events to know what stage the current connection is in during the process of establishing a connection so as to make corresponding processing later. As we all know, TCP establishes a connection between the server and the client and realizes network communication between the two. The same is true for RDMA. In today's complex network environment, the era of the Internet of Everything, the connection scenarios are complex and the number of connections is large. When there are multiple devices on the same switch or in the LAN, it is an extremely complex task to manually realize the connection between these devices in sequence.
申请内容Application Contents
有鉴于此,本申请实施例的目的在于提出一种链路中子网管理的方法、装置、设备及可读介质,通过使用本申请的技术方案,能够实现多个设备之间的自动连接,减少人工操作,节约人力成本,能够避免人为操作出现的错误。 In view of this, the purpose of the embodiments of the present application is to propose a method, device, equipment and readable medium for subnet management in a link. By using the technical solution of the present application, automatic connection between multiple devices can be achieved, manual operation can be reduced, labor costs can be saved, and errors caused by human operation can be avoided.
基于上述目的,本申请的实施例的一个方面提供了一种链路中子网管理的方法,包括以下步骤:Based on the above purpose, one aspect of an embodiment of the present application provides a method for subnet management in a link, comprising the following steps:
在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;Create a configuration file in the preset location under the system directory and write the subnet information to be connected into the configuration file;
响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;In response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain subnet information;
根据子网信息计算子网的IP地址的范围;Calculate the range of IP addresses of the subnet based on the subnet information;
根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。According to the calculated range of IP addresses of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively.
根据本申请的一个实施例,在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中包括:According to one embodiment of the present application, creating a configuration file at a preset location under a directory of the system, and writing the subnet information to be connected into the configuration file includes:
在系统的目录下的预设位置创建预设名称的配置文件,并记录配置文件的地址和名称;Create a configuration file with a preset name in a preset location under the system directory, and record the address and name of the configuration file;
将待连接的子网信息写入到创建的配置文件中,子网信息的格式为IP地址/子网掩码。Write the subnet information to be connected to the created configuration file. The format of the subnet information is IP address/subnet mask.
根据本申请的一个实施例,响应于接收到连接各个子网的指令,解析配置文件以获取子网信息包括:According to one embodiment of the present application, in response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain subnet information includes:
响应于接收到连接各个子网的指令,在记录的地址中找到相应名称的配置文件;In response to receiving the instruction to connect to each subnet, finding the configuration file with the corresponding name in the recorded address;
解析配置文件以得到IP地址和子网掩码的值。Parse the configuration file to get the values of IP address and subnet mask.
根据本申请的一个实施例,根据子网信息计算子网的IP地址的范围包括:According to one embodiment of the present application, the range of the IP address of the subnet is calculated according to the subnet information, including:
使用公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,其中N为子网信息中包含的IP地址的个数;Use the formula N = 2^(32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
确定子网的IP地址的范围为配置文件中IP地址后连续N-1个IP地址。The range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
根据本申请的一个实施例,根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接包括:According to an embodiment of the present application, based on the calculated range of IP addresses of the subnet, the host calls a connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
调用RDMA的第一API并发送判断链路是否连通的信息;Call the first API of RDMA and send information to determine whether the link is connected;
响应于接收到表征链路连通的第一返回信息,调用RDMA的第二API并发送判断路由是否解析成功的信息;In response to receiving the first return information indicating link connectivity, calling the second API of the RDMA and sending information for determining whether the route is resolved successfully;
响应于接收到表征路由解析成功的第二返回信息,调用RDMA的第三API并发送建立连接的信息;In response to receiving the second return information indicating successful route resolution, calling a third API of RDMA and sending information for establishing a connection;
响应于接收到表征连接建立成功的第三返回信息,确定本机与IP地址范围中的一个IP地址建立连接成功。In response to receiving the third return information indicating that the connection is successfully established, it is determined that the local device has successfully established a connection with an IP address in the IP address range.
根据本申请的一个实施例,还包括:According to one embodiment of the present application, it also includes:
响应于主机与子网建立连接成功,记录子网的IP地址; In response to the host successfully establishing a connection with the subnet, the IP address of the subnet is recorded;
响应于主机与子网建立连接失败,每经过阈值时间与建立连接失败的子网重新建立连接直到达到阈值次数。In response to the host failing to establish a connection with a subnet, the host re-establishes a connection with the subnet to which the connection failed after a threshold time has passed until a threshold number of times is reached.
根据本申请的一个实施例,还包括:According to one embodiment of the present application, it also includes:
响应于接收到断开与各个子网的连接的指令,将配置文件中的子网信息删除;In response to receiving an instruction to disconnect from each subnet, deleting the subnet information in the configuration file;
响应于检测到配置文件中没有子网信息,停止正在与子网建立的连接,并将已经建立的连接断开。In response to detecting that there is no subnet information in the configuration file, the connection being established with the subnet is stopped, and the established connection is disconnected.
本申请的实施例的另一个方面,还提供了一种链路中子网管理的装置,装置包括:Another aspect of the embodiment of the present application further provides a device for subnet management in a link, the device comprising:
写入模块,写入模块配置为在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;A writing module, wherein the writing module is configured to create a configuration file in a preset location under a system directory, and write the subnet information to be connected into the configuration file;
获取模块,获取模块配置为响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;an acquisition module, the acquisition module being configured to parse the configuration file to acquire the subnet information in response to receiving an instruction to connect to each subnet;
计算模块,计算模块配置为根据子网信息计算子网的IP地址的范围;A calculation module, the calculation module is configured to calculate a range of IP addresses of a subnet according to the subnet information;
连接模块,连接模块配置为根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。The connection module is configured to, according to the calculated range of the IP address of the subnet, enable the host to call a connection establishment mechanism to establish connections with the IP addresses in the range respectively.
根据本申请的一个实施例,写入模块还配置为:According to one embodiment of the present application, the writing module is further configured as:
在系统的目录下的预设位置创建预设名称的配置文件,并记录配置文件的地址和名称;Create a configuration file with a preset name in a preset location under the system directory, and record the address and name of the configuration file;
将待连接的子网信息写入到创建的配置文件中,子网信息的格式为IP地址/子网掩码。Write the subnet information to be connected to the created configuration file. The format of the subnet information is IP address/subnet mask.
根据本申请的一个实施例,获取模块还配置为:According to one embodiment of the present application, the acquisition module is further configured to:
响应于接收到连接各个子网的指令,在记录的地址中找到相应名称的配置文件;In response to receiving the instruction to connect to each subnet, finding the configuration file with the corresponding name in the recorded address;
解析配置文件以得到IP地址和子网掩码的值。Parse the configuration file to get the values of IP address and subnet mask.
根据本申请的一个实施例,计算模块还配置为:According to one embodiment of the present application, the computing module is further configured to:
使用公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,其中N为子网信息中包含的IP地址的个数;Use the formula N = 2^(32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
确定子网的IP地址的范围为配置文件中IP地址后连续N-1个IP地址。The range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
根据本申请的一个实施例,连接模块还配置为:According to one embodiment of the present application, the connection module is further configured as:
调用RDMA的第一API并发送判断链路是否连通的信息;Call the first API of RDMA and send information to determine whether the link is connected;
响应于接收到表征链路连通的第一返回信息,调用RDMA的第二API并发送判断路由是否解析成功的信息;In response to receiving the first return information indicating link connectivity, calling the second API of the RDMA and sending information for determining whether the route is resolved successfully;
响应于接收到表征路由解析成功的第二返回信息,调用RDMA的第三API并发送建立连接的信息; In response to receiving the second return information indicating successful route resolution, calling a third API of RDMA and sending information for establishing a connection;
响应于接收到表征连接建立成功的第三返回信息,确定本机与IP地址范围中的一个IP地址建立连接成功。In response to receiving the third return information indicating that the connection is successfully established, it is determined that the local device has successfully established a connection with an IP address in the IP address range.
根据本申请的一个实施例,还包括删除模块,删除模块配置为:According to one embodiment of the present application, a deletion module is further included, and the deletion module is configured as follows:
响应于接收到断开与各个子网的连接的指令,将配置文件中的子网信息删除;In response to receiving an instruction to disconnect from each subnet, deleting the subnet information in the configuration file;
响应于检测到配置文件中没有子网信息,停止正在与子网建立的连接,并将已经建立的连接断开。In response to detecting that there is no subnet information in the configuration file, the connection being established with the subnet is stopped, and the established connection is disconnected.
本申请的实施例的另一个方面,还提供了一种计算机设备,该计算机设备包括:Another aspect of the embodiments of the present application further provides a computer device, the computer device comprising:
至少一个处理器;以及at least one processor; and
存储器,存储器存储有可在处理器上运行的计算机指令,指令由处理器执行时实现上述任意一项方法的步骤。The memory stores computer instructions executable on the processor, and the instructions implement the steps of any one of the above methods when executed by the processor.
本申请的实施例的另一个方面,还提供了一种非易失性可读存储介质,非易失性可读存储介质存储有计算机程序,计算机程序被处理器执行时实现上述任意一项方法的步骤。Another aspect of the embodiments of the present application further provides a non-volatile readable storage medium, which stores a computer program, and when the computer program is executed by a processor, the steps of any one of the above methods are implemented.
本申请具有以下有益技术效果:本申请实施例提供的链路中子网管理的方法,通过在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;根据子网信息计算子网的IP地址的范围;根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接的技术方案,能够实现多个设备之间的自动连接,减少人工操作,节约人力成本,能够避免人为操作出现的错误。The present application has the following beneficial technical effects: the method for subnet management in a link provided by the embodiment of the present application creates a configuration file at a preset location under the system directory, and writes the subnet information to be connected into the configuration file; in response to receiving an instruction to connect to each subnet, the configuration file is parsed to obtain the subnet information; the range of the IP address of the subnet is calculated according to the subnet information; based on the calculated range of the IP address of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses within the range respectively. The technical solution can realize automatic connection between multiple devices, reduce manual operations, save labor costs, and avoid errors caused by human operations.
附图说明BRIEF DESCRIPTION OF THE DRAWINGS
为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的实施例。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying any creative work.
图1为根据本申请一个实施例的链路中子网管理的方法的示意性流程图;FIG1 is a schematic flow chart of a method for managing subnets in a link according to an embodiment of the present application;
图2为根据本申请一个实施例的链路中子网管理的装置的示意图;FIG2 is a schematic diagram of a device for subnet management in a link according to an embodiment of the present application;
图3为根据本申请一个实施例的计算机设备的示意图;FIG3 is a schematic diagram of a computer device according to an embodiment of the present application;
图4为根据本申请一个实施例的非易失性可读存储介质的示意图。FIG. 4 is a schematic diagram of a non-volatile readable storage medium according to an embodiment of the present application.
具体实施方式Detailed ways
为使本申请的目的、技术方案和优点更加清楚明白,以下结合具体实施例,并参照附图,对本申请实施例进一步详细说明。 In order to make the objectives, technical solutions and advantages of the present application more clearly understood, the embodiments of the present application are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.
基于上述目的,本申请的实施例的第一个方面,提出了一种链路中子网管理的方法的一个实施例。图1示出的是该方法的示意性流程图。Based on the above purpose, the first aspect of the embodiment of the present application provides an embodiment of a method for managing subnets in a link. FIG1 shows a schematic flow chart of the method.
如图1中所示,该方法可以包括以下步骤:As shown in FIG. 1 , the method may include the following steps:
S1在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中。设计一个配置文件用以存放子网发现配置信息,将配置文件保存在本地机的系统上,并记录保存的位置和配置文件的名称,例如在系统目录下创建一个配置文件,在/data目录下创建一个名为“subnet”的配置文件,用户将期望连接的子网信息写入subnet配置文件中,子网信息的格式为IP地址/子网掩码,例如用户在配置文件中写入192.168.1.1/28,前面的IP表示子网中第一个IP地址,后面的28为子网掩码的值,也可以是用户自定义的值,表示子网的IP地址的范围。S1 creates a configuration file in a preset location under the system directory, and writes the subnet information to be connected into the configuration file. Design a configuration file to store subnet discovery configuration information, save the configuration file on the local system, and record the saved location and the name of the configuration file. For example, create a configuration file in the system directory, and create a configuration file named "subnet" in the /data directory. The user writes the subnet information expected to be connected into the subnet configuration file. The format of the subnet information is IP address/subnet mask. For example, the user writes 192.168.1.1/28 in the configuration file. The IP in front represents the first IP address in the subnet, and the 28 behind is the value of the subnet mask, which can also be a user-defined value, indicating the range of IP addresses of the subnet.
S2响应于接收到连接各个子网的指令,解析配置文件以获取子网信息。当需要自动连接到各个子网时,主机按照记录的配置文件存放的位置和配置文件的名称读取该配置文件,并获取配置文件中的子网信息,即获取到第一个IP地址的值和子网掩码或自定义的值。In response to receiving the instruction to connect to each subnet, S2 parses the configuration file to obtain the subnet information. When it is necessary to automatically connect to each subnet, the host reads the configuration file according to the location and name of the configuration file recorded, and obtains the subnet information in the configuration file, that is, obtains the value of the first IP address and the subnet mask or a custom value.
S3根据子网信息计算子网的IP地址的范围。设置子网IP地址的计算规则,能够依据用户填写的子网信息找到相关的IP地址的范围,例如,根据公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,如上例中,N=2^(32-28)=16,即有16个IP地址,所以子网的IP地址的范围是192.168.1.1~192.168.1.16。S3 calculates the range of the subnet IP address according to the subnet information. The calculation rule of the subnet IP address is set to find the range of the relevant IP address according to the subnet information filled in by the user. For example, the number of IP addresses contained in the subnet information is calculated according to the formula N=2^(32-subnet mask). As in the above example, N=2^(32-28)=16, that is, there are 16 IP addresses, so the range of the subnet IP address is 192.168.1.1~192.168.1.16.
S4根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。获取到IP地址范围后,主机依次对每个IP地址建立连接,依赖于RDMA CM建立连接机制,发起连接到连接成功共经历三个CM事件(RDMA_CM_EVENT_ADDR_RESOLVED、RDMA_CM_EVENT_ROUTE_RESOLVED、RDMA_CM_EVENT_ESTABLISHED),这三个事件分别是调用三个API(rdma_resolve_addr、rdma_resolve_route、rdma_connect)后产生,首先主机发送rdma_resolve_addr(cm_id,src_ip,dst_ip,timeout),其中src_ip是主机IP地址,dst_ip是目标IP地址(即IP地址范围中IP地址),cm_id是一个(struct rdma_cm_id*)类型的结构体指针,建立一个连接需要通过调用rdma_create_id接口创建该结构体指针,timeout是自定义的一个超时时间。rdma_resolve_add处理过程中会阻塞,如果规定时间内rdma_resolve_addr一直没有结果返回,则超时退出此函数,说明rdma_resolve_addr失败,需要进行重试,直到执行成功。如果链路上是通的话,则会收到RDMA_CM_EVENT_ADDR_RESOLVED代表成功,如果收到RDMA_CM_EVENT_ADDR_ERROR,则表示链路有问题无法建立连接,此时可以向管理员发出警告或等待一定时间后重试,在接收到成功 的返回信息后,主机发送rdma_resolve_route(cm_id,timeout),如果收到RDMA_CM_EVENT_ROUTE_RESOLVED表示解析路由成功,如果收到RDMA_CM_EVENT_ROUTE_ERROR表示失败,在接收到成功的返回信息后,主机发送rdma_connect(cm_id,arg),其中arg是(struct rdma_conn_param*)类型的结构体指针,调用rdma_connect发起连接之前需要申请一个struct rdma_conn_param结构体空间,主要目的是填充本端连接的一些属性信息,比如队列深度、当前队列号之类的信息告诉连接的目标端。如果收到RDMA_CM_EVENT_ESTABLISHED表示建立连接完成,如果收到其它事件表示建立连接失败,如果与当前的IP地址建立连接成功,则记录当前的IP地址信息,并开始下一个IP地址的连接,当子网中的IP地址全部尝试建立连接后,设置定时器,比如一分钟后再次尝试与没有连接成功的IP地址建立连接,直到连接成功或达到最大重试次数。S4 According to the calculated range of IP addresses of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range. After obtaining the IP address range, the host establishes a connection to each IP address in turn, relying on the RDMA CM connection establishment mechanism. From initiating a connection to successfully connecting, a total of three CM events (RDMA_CM_EVENT_ADDR_RESOLVED, RDMA_CM_EVENT_ROUTE_RESOLVED, RDMA_CM_EVENT_ESTABLISHED) are experienced. These three events are generated after calling three APIs (rdma_resolve_addr, rdma_resolve_route, rdma_connect). First, the host sends rdma_resolve_addr (cm_id, src_ip, dst_ip, timeout), where src_ip is the host IP address, dst_ip is the target IP address (i.e., the IP address in the IP address range), cm_id is a structure pointer of type (struct rdma_cm_id*), and establishing a connection requires creating the structure pointer by calling the rdma_create_id interface, and timeout is a custom timeout. The rdma_resolve_add process will be blocked. If rdma_resolve_addr does not return a result within the specified time, the function will time out and exit, indicating that rdma_resolve_addr has failed and needs to be retried until it succeeds. If the link is connected, you will receive RDMA_CM_EVENT_ADDR_RESOLVED to indicate success. If you receive RDMA_CM_EVENT_ADDR_ERROR, it means that there is a problem with the link and the connection cannot be established. At this time, you can send a warning to the administrator or wait for a certain period of time and try again. After receiving the success After receiving the return information, the host sends rdma_resolve_route(cm_id, timeout). If RDMA_CM_EVENT_ROUTE_RESOLVED is received, it means the route resolution is successful. If RDMA_CM_EVENT_ROUTE_ERROR is received, it means failure. After receiving the successful return information, the host sends rdma_connect(cm_id, arg), where arg is a structure pointer of type (struct rdma_conn_param*). Before calling rdma_connect to initiate a connection, you need to apply for a struct rdma_conn_param structure space. The main purpose is to fill in some attribute information of the local connection, such as queue depth, current queue number and other information to tell the target end of the connection. If RDMA_CM_EVENT_ESTABLISHED is received, it indicates that the connection is established successfully. If other events are received, it indicates that the connection fails. If the connection is established successfully with the current IP address, the current IP address information is recorded and the connection with the next IP address is started. When all IP addresses in the subnet have tried to establish a connection, a timer is set, for example, to try to establish a connection with the IP address that was not successfully connected after one minute, until the connection is successful or the maximum number of retries is reached.
通过使用本发明的技术方案,能够实现多个设备之间的自动连接,减少人工操作,节约人力成本,能够避免人为操作出现的错误。By using the technical solution of the present invention, automatic connection between multiple devices can be achieved, manual operations can be reduced, labor costs can be saved, and errors caused by manual operations can be avoided.
在本申请的一个优选实施例中,在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中包括:In a preferred embodiment of the present application, creating a configuration file in a preset location under a system directory, and writing the subnet information to be connected into the configuration file includes:
在系统的目录下的预设位置创建预设名称的配置文件,并记录配置文件的地址和名称;Create a configuration file with a preset name in a preset location under the system directory, and record the address and name of the configuration file;
将待连接的子网信息写入到创建的配置文件中,子网信息的格式为IP地址/子网掩码。子网信息的格式为IP地址/子网掩码,例如用户在配置文件中写入192.168.1.1/28,前面的IP表示子网中第一个IP地址,后面的28为子网掩码的值,也可以是用户自定义的值,表示子网的IP地址的范围,子网掩码或自定义的值的取值范围为0-32之间的数字。Write the subnet information to be connected to the created configuration file. The format of the subnet information is IP address/subnet mask. For example, if the user writes 192.168.1.1/28 in the configuration file, the first IP represents the first IP address in the subnet, and the following 28 is the value of the subnet mask, which can also be a user-defined value, indicating the range of the subnet IP address. The subnet mask or the customized value ranges from 0 to 32.
在本申请的一个优选实施例中,响应于接收到连接各个子网的指令,解析配置文件以获取子网信息包括:In a preferred embodiment of the present application, in response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain the subnet information includes:
响应于接收到连接各个子网的指令,在记录的地址中找到相应名称的配置文件;In response to receiving the instruction to connect to each subnet, finding the configuration file with the corresponding name in the recorded address;
解析配置文件以得到IP地址和子网掩码的值。需要获取的是第一个IP地址的值和子网掩码或自定义的值。Parse the configuration file to get the IP address and subnet mask values. You need to get the first IP address and subnet mask or a custom value.
在本申请的一个优选实施例中,根据子网信息计算子网的IP地址的范围包括:In a preferred embodiment of the present application, the range of the IP address of the subnet calculated according to the subnet information includes:
使用公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,其中N为子网信息中包含的IP地址的个数;Use the formula N = 2^(32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
确定子网的IP地址的范围为配置文件中IP地址后连续N-1个IP地址。例如用户在配置文件中写入192.168.1.1/28,则N=2^(32-28)=16,即有16个IP地址,所以子网的IP地址的范围是192.168.1.1~192.168.1.16。 The range of IP addresses of the subnet is determined as N-1 consecutive IP addresses after the IP address in the configuration file. For example, if the user writes 192.168.1.1/28 in the configuration file, then N = 2^(32-28) = 16, that is, there are 16 IP addresses, so the range of IP addresses of the subnet is 192.168.1.1 to 192.168.1.16.
在本申请的一个优选实施例中,根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接包括:In a preferred embodiment of the present application, according to the calculated range of the IP address of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
调用RDMA的第一API并发送判断链路是否连通的信息,该信息为rdma_resolve_addr(cm_id,src_ip,dst_ip,timeout),其中src_ip是主机的IP地址,dst_ip是IP地址范围中的一个IP地址;Call the first API of RDMA and send information to determine whether the link is connected, the information is rdma_resolve_addr (cm_id, src_ip, dst_ip, timeout), where src_ip is the IP address of the host, and dst_ip is an IP address in the IP address range;
响应于接收到表征链路连通的第一返回信息,调用RDMA的第二API并发送判断路由是否解析成功的信息,其中第一返回信息为RDMA_CM_EVENT_ADDR_RESOLVED,判断路由是否解析成功的信息为rdma_resolve_route(cm_id,timeout);In response to receiving the first return information indicating link connectivity, calling the second API of RDMA and sending information for determining whether the route is resolved successfully, wherein the first return information is RDMA_CM_EVENT_ADDR_RESOLVED, and the information for determining whether the route is resolved successfully is rdma_resolve_route(cm_id, timeout);
响应于接收到表征路由解析成功的第二返回信息,调用RDMA的第三API并发送建立连接的信息,其中第二返回信息为RDMA_CM_EVENT_ROUTE_RESOLVED,建立连接的信息为rdma_connect(cm_id,arg);In response to receiving the second return information indicating successful route resolution, calling the third API of RDMA and sending information for establishing a connection, wherein the second return information is RDMA_CM_EVENT_ROUTE_RESOLVED, and the information for establishing a connection is rdma_connect(cm_id, arg);
响应于接收到表征连接建立成功的第三返回信息,确定本机与IP地址范围中的一个IP地址建立连接成功,其中第三返回信息为RDMA_CM_EVENT_ESTABLISHED。如果在任一个步骤中接收到的返回信息表示失败,则不进行下一个步骤,可以向管理发出相应的告警,也可以等待一定时间后重试。当一个IP地址连接成功后,继续相同的步骤与下一个IP地址建立连接,直到所有的子网连接成功。In response to receiving the third return information indicating that the connection is successfully established, it is determined that the local machine has successfully established a connection with an IP address in the IP address range, wherein the third return information is RDMA_CM_EVENT_ESTABLISHED. If the return information received in any step indicates failure, the next step is not performed, and a corresponding alarm may be issued to the management, or a retry may be performed after a certain period of time. When an IP address is successfully connected, the same steps are continued to establish a connection with the next IP address until all subnets are successfully connected.
在本申请的一个优选实施例中,还包括:In a preferred embodiment of the present application, it also includes:
响应于主机与子网建立连接成功,记录子网的IP地址;In response to the host successfully establishing a connection with the subnet, the IP address of the subnet is recorded;
响应于主机与子网建立连接失败,每经过阈值时间与建立连接失败的子网重新建立连接直到达到阈值次数。或者当子网中的IP地址全部尝试建立连接后,设置定时器,比如一分钟后再次尝试与没有连接成功的IP地址建立连接,直到连接成功或达到最大重试次数。In response to the host failing to establish a connection with the subnet, the host re-establishes a connection with the subnet that failed to establish a connection every threshold time until the threshold number of times is reached. Or when all IP addresses in the subnet have tried to establish a connection, a timer is set, such as one minute later, to try to establish a connection with the IP address that failed to connect again until the connection is successful or the maximum number of retries is reached.
在本申请的一个优选实施例中,还包括:In a preferred embodiment of the present application, it also includes:
响应于接收到断开与各个子网的连接的指令,将配置文件中的子网信息删除;In response to receiving an instruction to disconnect from each subnet, deleting the subnet information in the configuration file;
响应于检测到配置文件中没有子网信息,停止正在与子网建立的连接,并将已经建立的连接断开。如果用户期望将子网内连接的设备全部断开,只需要删除配置文件中的子网信息,当监测到没有要连接的子网信息时,先终止当前正在进行的连接,并将在子网范围内的已经连接成功的IP地址全部断开连接。In response to detecting that there is no subnet information in the configuration file, the connection being established with the subnet is stopped, and the established connection is disconnected. If the user wishes to disconnect all devices connected in the subnet, he only needs to delete the subnet information in the configuration file. When it is detected that there is no subnet information to be connected, the current connection is terminated first, and all IP addresses that have been successfully connected within the subnet range are disconnected.
针对多个RDMA设备之间建立连接面临庞大工作量和难度的问题,使用这种基于RDMA链路的子网发现技术,可以轻松实现多个设备之间的自动连接,减少人工操作,节约人力成本,避免了人为操作的易出错的特点。 In view of the huge workload and difficulty in establishing connections between multiple RDMA devices, the use of this subnet discovery technology based on RDMA links can easily achieve automatic connections between multiple devices, reduce manual operations, save labor costs, and avoid the error-prone characteristics of manual operations.
通过使用本申请的技术方案,能够实现多个设备之间的自动连接,减少人工操作,节约人力成本,能够避免人为操作出现的错误。By using the technical solution of the present application, automatic connection between multiple devices can be achieved, manual operations can be reduced, labor costs can be saved, and errors caused by human operations can be avoided.
需要说明的是,本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,可以通过计算机程序来指令相关硬件来完成,上述的程序可存储于计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中存储介质可为磁碟、光盘、只读存储器(Read-Only Memory,ROM)或随机存取存储器(Random Access Memory,RAM)等。上述计算机程序的实施例,可以达到与之对应的前述任意方法实施例相同或者相类似的效果。It should be noted that a person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the above-mentioned program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc. The above-mentioned computer program embodiments can achieve the same or similar effects as the corresponding above-mentioned arbitrary method embodiments.
此外,根据本申请实施例公开的方法还可以被实现为由CPU执行的计算机程序,该计算机程序可以存储在非易失性可读存储介质中。在该计算机程序被CPU执行时,执行本申请实施例公开的方法中限定的上述功能。In addition, the method disclosed in the embodiment of the present application can also be implemented as a computer program executed by a CPU, and the computer program can be stored in a non-volatile readable storage medium. When the computer program is executed by the CPU, the above functions defined in the method disclosed in the embodiment of the present application are performed.
基于上述目的,本申请的实施例的第二个方面,提出了一种链路中子网管理的装置,如图2所示,装置200包括:Based on the above purpose, a second aspect of an embodiment of the present application provides a device for subnet management in a link. As shown in FIG2 , the device 200 includes:
写入模块,写入模块配置为在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;A writing module, wherein the writing module is configured to create a configuration file in a preset location under a system directory, and write the subnet information to be connected into the configuration file;
获取模块,获取模块配置为响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;an acquisition module, the acquisition module being configured to parse the configuration file to acquire the subnet information in response to receiving an instruction to connect to each subnet;
计算模块,计算模块配置为根据子网信息计算子网的IP地址的范围;A calculation module, the calculation module is configured to calculate a range of IP addresses of a subnet according to the subnet information;
连接模块,连接模块配置为根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。The connection module is configured to, according to the calculated range of the IP address of the subnet, enable the host to call a connection establishment mechanism to establish connections with the IP addresses in the range respectively.
在本申请的一个优选实施例中,写入模块还配置为:In a preferred embodiment of the present application, the writing module is further configured as:
在系统的目录下的预设位置创建预设名称的配置文件,并记录配置文件的地址和名称;Create a configuration file with a preset name in a preset location under the system directory, and record the address and name of the configuration file;
将待连接的子网信息写入到创建的配置文件中,子网信息的格式为IP地址/子网掩码。Write the subnet information to be connected to the created configuration file. The format of the subnet information is IP address/subnet mask.
在本申请的一个优选实施例中,获取模块还配置为:In a preferred embodiment of the present application, the acquisition module is further configured to:
响应于接收到连接各个子网的指令,在记录的地址中找到相应名称的配置文件;In response to receiving the instruction to connect to each subnet, finding the configuration file with the corresponding name in the recorded address;
解析配置文件以得到IP地址和子网掩码的值。Parse the configuration file to get the values of IP address and subnet mask.
在本申请的一个优选实施例中,计算模块还配置为:In a preferred embodiment of the present application, the calculation module is further configured as:
使用公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,其中N为子网信息中包含的IP地址的个数;Use the formula N = 2^(32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
确定子网的IP地址的范围为配置文件中IP地址后连续N-1个IP地址。 The range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
在本申请的一个优选实施例中,连接模块还配置为:In a preferred embodiment of the present application, the connection module is further configured as:
调用RDMA的第一API并发送rdma_resolve_addr(cm_id,src_ip,dst_ip,timeout),其中src_ip是主机的IP地址,dst_ip是IP地址范围中的一个IP地址;Call the first API of RDMA and send rdma_resolve_addr(cm_id, src_ip, dst_ip, timeout), where src_ip is the IP address of the host and dst_ip is an IP address in the IP address range;
响应于接收到返回信息RDMA_CM_EVENT_ADDR_RESOLVED,调用RDMA的第二API并发送rdma_resolve_route(cm_id,timeout);In response to receiving the return information RDMA_CM_EVENT_ADDR_RESOLVED, the second API of RDMA is called and rdma_resolve_route(cm_id, timeout) is sent;
响应于接收到返回信息RDMA_CM_EVENT_ROUTE_RESOLVED,调用RDMA的第三API并发送rdma_connect(cm_id,arg);In response to receiving the return information RDMA_CM_EVENT_ROUTE_RESOLVED, the third API of RDMA is called and rdma_connect (cm_id, arg) is sent;
响应于接收到返回信息RDMA_CM_EVENT_ESTABLISHED,确定本机与IP地址范围中的一个IP地址建立连接成功。In response to receiving the return information RDMA_CM_EVENT_ESTABLISHED, it is determined that the local machine has successfully established a connection with an IP address in the IP address range.
在本申请的一个优选实施例中,还包括删除模块,删除模块配置为:In a preferred embodiment of the present application, a deletion module is further included, and the deletion module is configured as follows:
响应于接收到断开与各个子网的连接的指令,将配置文件中的子网信息删除;In response to receiving an instruction to disconnect from each subnet, deleting the subnet information in the configuration file;
响应于检测到配置文件中没有子网信息,停止正在与子网建立的连接,并将已经建立的连接断开。In response to detecting that there is no subnet information in the configuration file, the connection being established with the subnet is stopped, and the established connection is disconnected.
基于上述目的,本申请实施例的第三个方面,提出了一种计算机设备。图3示出的是本申请提供的计算机设备的实施例的示意图。如图3所示,本申请实施例包括如下装置:至少一个处理器21;以及存储器22,存储器22存储有可在处理器上运行的计算机指令23,指令由处理器执行时实现以下方法:Based on the above purpose, the third aspect of the embodiment of the present application provides a computer device. FIG3 shows a schematic diagram of an embodiment of the computer device provided by the present application. As shown in FIG3, the embodiment of the present application includes the following apparatus: at least one processor 21; and a memory 22, the memory 22 stores computer instructions 23 that can be run on the processor, and when the instructions are executed by the processor, the following method is implemented:
在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;Create a configuration file in the preset location under the system directory and write the subnet information to be connected into the configuration file;
响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;In response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain subnet information;
根据子网信息计算子网的IP地址的范围;Calculate the range of IP addresses of the subnet based on the subnet information;
根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。According to the calculated range of IP addresses of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively.
在本申请的一个优选实施例中,在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中包括:In a preferred embodiment of the present application, creating a configuration file in a preset location under a system directory, and writing the subnet information to be connected into the configuration file includes:
在系统的目录下的预设位置创建预设名称的配置文件,并记录配置文件的地址和名称;Create a configuration file with a preset name in a preset location under the system directory, and record the address and name of the configuration file;
将待连接的子网信息写入到创建的配置文件中,子网信息的格式为IP地址/子网掩码。Write the subnet information to be connected to the created configuration file. The format of the subnet information is IP address/subnet mask.
在本申请的一个优选实施例中,响应于接收到连接各个子网的指令,解析配置文件以获取子网信息包括:In a preferred embodiment of the present application, in response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain the subnet information includes:
响应于接收到连接各个子网的指令,在记录的地址中找到相应名称的配置文件;In response to receiving the instruction to connect to each subnet, finding the configuration file with the corresponding name in the recorded address;
解析配置文件以得到IP地址和子网掩码的值。 Parse the configuration file to get the values of IP address and subnet mask.
在本申请的一个优选实施例中,根据子网信息计算子网的IP地址的范围包括:In a preferred embodiment of the present application, the range of the IP address of the subnet calculated according to the subnet information includes:
使用公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,其中N为子网信息中包含的IP地址的个数;Use the formula N = 2^(32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
确定子网的IP地址的范围为配置文件中IP地址后连续N-1个IP地址。The range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
在本申请的一个优选实施例中,根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接包括:In a preferred embodiment of the present application, according to the calculated range of the IP address of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
调用RDMA的第一API并发送rdma_resolve_addr(cm_id,src_ip,dst_ip,timeout),其中src_ip是主机的IP地址,dst_ip是IP地址范围中的一个IP地址;Call the first API of RDMA and send rdma_resolve_addr(cm_id, src_ip, dst_ip, timeout), where src_ip is the IP address of the host and dst_ip is an IP address in the IP address range;
响应于接收到返回信息RDMA_CM_EVENT_ADDR_RESOLVED,调用RDMA的第二API并发送rdma_resolve_route(cm_id,timeout);In response to receiving the return information RDMA_CM_EVENT_ADDR_RESOLVED, the second API of RDMA is called and rdma_resolve_route(cm_id, timeout) is sent;
响应于接收到返回信息RDMA_CM_EVENT_ROUTE_RESOLVED,调用RDMA的第三API并发送rdma_connect(cm_id,arg);In response to receiving the return information RDMA_CM_EVENT_ROUTE_RESOLVED, the third API of RDMA is called and rdma_connect (cm_id, arg) is sent;
响应于接收到返回信息RDMA_CM_EVENT_ESTABLISHED,确定本机与IP地址范围中的一个IP地址建立连接成功。In response to receiving the return information RDMA_CM_EVENT_ESTABLISHED, it is determined that the local machine has successfully established a connection with an IP address in the IP address range.
在本申请的一个优选实施例中,还包括:In a preferred embodiment of the present application, it also includes:
响应于主机与子网建立连接成功,记录子网的IP地址;In response to the host successfully establishing a connection with the subnet, the IP address of the subnet is recorded;
响应于主机与子网建立连接失败,每经过阈值时间与建立连接失败的子网重新建立连接直到达到阈值次数。In response to the host failing to establish a connection with a subnet, the host re-establishes a connection with the subnet to which the connection failed after a threshold time has passed until a threshold number of times is reached.
在本申请的一个优选实施例中,还包括:In a preferred embodiment of the present application, it also includes:
响应于接收到断开与各个子网的连接的指令,将配置文件中的子网信息删除;In response to receiving an instruction to disconnect from each subnet, deleting the subnet information in the configuration file;
响应于检测到配置文件中没有子网信息,停止正在与子网建立的连接,并将已经建立的连接断开。In response to detecting that there is no subnet information in the configuration file, the connection being established with the subnet is stopped, and the established connection is disconnected.
基于上述目的,本申请实施例的第四个方面,提出了一种非易失性可读存储介质。图4示出的是本申请提供的非易失性可读存储介质的实施例的示意图。如图4所示,非易失性可读存储介质31存储有被处理器执行时执行如下方法的计算机程序32:Based on the above purpose, the fourth aspect of the embodiment of the present application provides a non-volatile readable storage medium. FIG4 is a schematic diagram of an embodiment of the non-volatile readable storage medium provided by the present application. As shown in FIG4, the non-volatile readable storage medium 31 stores a computer program 32 that performs the following method when executed by a processor:
在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;Create a configuration file in the preset location under the system directory and write the subnet information to be connected into the configuration file;
响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;In response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain subnet information;
根据子网信息计算子网的IP地址的范围;Calculate the range of IP addresses of the subnet based on the subnet information;
根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。 According to the calculated range of IP addresses of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively.
在本申请的一个优选实施例中,在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中包括:In a preferred embodiment of the present application, creating a configuration file in a preset location under a system directory, and writing the subnet information to be connected into the configuration file includes:
在系统的目录下的预设位置创建预设名称的配置文件,并记录配置文件的地址和名称;Create a configuration file with a preset name in a preset location under the system directory, and record the address and name of the configuration file;
将待连接的子网信息写入到创建的配置文件中,子网信息的格式为IP地址/子网掩码。Write the subnet information to be connected to the created configuration file. The format of the subnet information is IP address/subnet mask.
在本申请的一个优选实施例中,响应于接收到连接各个子网的指令,解析配置文件以获取子网信息包括:In a preferred embodiment of the present application, in response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain the subnet information includes:
响应于接收到连接各个子网的指令,在记录的地址中找到相应名称的配置文件;In response to receiving the instruction to connect to each subnet, finding the configuration file with the corresponding name in the recorded address;
解析配置文件以得到IP地址和子网掩码的值。Parse the configuration file to get the values of IP address and subnet mask.
在本申请的一个优选实施例中,根据子网信息计算子网的IP地址的范围包括:In a preferred embodiment of the present application, the range of the IP address of the subnet calculated according to the subnet information includes:
使用公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,其中N为子网信息中包含的IP地址的个数;Use the formula N = 2^(32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
确定子网的IP地址的范围为配置文件中IP地址后连续N-1个IP地址。The range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
在本申请的一个优选实施例中,根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接包括:In a preferred embodiment of the present application, according to the calculated range of the IP address of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively, including:
调用RDMA的第一API并发送rdma_resolve_addr(cm_id,src_ip,dst_ip,timeout),其中src_ip是主机的IP地址,dst_ip是IP地址范围中的一个IP地址;Call the first API of RDMA and send rdma_resolve_addr(cm_id, src_ip, dst_ip, timeout), where src_ip is the IP address of the host and dst_ip is an IP address in the IP address range;
响应于接收到返回信息RDMA_CM_EVENT_ADDR_RESOLVED,调用RDMA的第二API并发送rdma_resolve_route(cm_id,timeout);In response to receiving the return information RDMA_CM_EVENT_ADDR_RESOLVED, the second API of RDMA is called and rdma_resolve_route(cm_id, timeout) is sent;
响应于接收到返回信息RDMA_CM_EVENT_ROUTE_RESOLVED,调用RDMA的第三API并发送rdma_connect(cm_id,arg);In response to receiving the return information RDMA_CM_EVENT_ROUTE_RESOLVED, the third API of RDMA is called and rdma_connect (cm_id, arg) is sent;
响应于接收到返回信息RDMA_CM_EVENT_ESTABLISHED,确定本机与IP地址范围中的一个IP地址建立连接成功。In response to receiving the return information RDMA_CM_EVENT_ESTABLISHED, it is determined that the local machine has successfully established a connection with an IP address in the IP address range.
在本申请的一个优选实施例中,还包括:In a preferred embodiment of the present application, it also includes:
响应于主机与子网建立连接成功,记录子网的IP地址;In response to the host successfully establishing a connection with the subnet, the IP address of the subnet is recorded;
响应于主机与子网建立连接失败,每经过阈值时间与建立连接失败的子网重新建立连接直到达到阈值次数。In response to the host failing to establish a connection with a subnet, the host re-establishes a connection with the subnet to which the connection failed after a threshold time has passed until a threshold number of times is reached.
在本申请的一个优选实施例中,还包括:In a preferred embodiment of the present application, it also includes:
响应于接收到断开与各个子网的连接的指令,将配置文件中的子网信息删除;In response to receiving an instruction to disconnect from each subnet, deleting the subnet information in the configuration file;
响应于检测到配置文件中没有子网信息,停止正在与子网建立的连接,并将已经建立的连接断开。 In response to detecting that there is no subnet information in the configuration file, the connection being established with the subnet is stopped, and the established connection is disconnected.
此外,根据本申请实施例公开的方法还可以被实现为由处理器执行的计算机程序,该计算机程序可以存储在非易失性可读存储介质中。在该计算机程序被处理器执行时,执行本申请实施例公开的方法中限定的上述功能。In addition, the method disclosed in the embodiment of the present application can also be implemented as a computer program executed by a processor, and the computer program can be stored in a non-volatile readable storage medium. When the computer program is executed by the processor, the above functions defined in the method disclosed in the embodiment of the present application are performed.
此外,上述方法步骤以及系统单元也可以利用控制器以及用于存储使得控制器实现上述步骤或单元功能的计算机程序的非易失性可读存储介质实现。In addition, the above method steps and system units may also be implemented using a controller and a non-volatile readable storage medium for storing a computer program that enables the controller to implement the above steps or unit functions.
本领域技术人员还将明白的是,结合这里的公开所描述的各种示例性逻辑块、模块、电路和算法步骤可以被实现为电子硬件、计算机软件或两者的组合。为了清楚地说明硬件和软件的这种可互换性,已经就各种示意性组件、方块、模块、电路和步骤的功能对其进行了一般性的描述。这种功能是被实现为软件还是被实现为硬件取决于具体应用以及施加给整个系统的设计约束。本领域技术人员可以针对每种具体应用以各种方式来实现的功能,但是这种实现决定不应被解释为导致脱离本申请实施例公开的范围。It will also be appreciated by those skilled in the art that various exemplary logic blocks, modules, circuits and algorithmic steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given to the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or implemented as hardware depends on specific application and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for every specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the present application embodiment.
在一个或多个示例性设计中,功能可以在硬件、软件、固件或其任意组合中实现。如果在软件中实现,则可以将功能作为一个或多个指令或代码存储在计算机可读介质上或通过计算机可读介质来传送。计算机可读介质包括计算机存储介质和通信介质,该通信介质包括有助于将计算机程序从一个位置传送到另一个位置的任何介质。存储介质可以是能够被通用或专用计算机访问的任何可用介质。作为例子而非限制性的,该计算机可读介质可以包括RAM、ROM、EEPROM、CD-ROM或其它光盘存储设备、磁盘存储设备或其它磁性存储设备,或者是可以用于携带或存储形式为指令或数据结构的所需程序代码并且能够被通用或专用计算机或者通用或专用处理器访问的任何其它介质。此外,任何连接都可以适当地称为计算机可读介质。例如,如果使用同轴线缆、光纤线缆、双绞线、数字用户线路(DSL)或诸如红外线、无线电和微波的无线技术来从网站、服务器或其它远程源发送软件,则上述同轴线缆、光纤线缆、双绞线、DSL或诸如红外线、无线电和微波的无线技术均包括在介质的定义。如这里所使用的,磁盘和光盘包括压缩盘(CD)、激光盘、光盘、数字多功能盘(DVD)、软盘、蓝光盘,其中磁盘通常磁性地再现数据,而光盘利用激光光学地再现数据。上述内容的组合也应当包括在计算机可读介质的范围内。In one or more exemplary designs, the function can be implemented in hardware, software, firmware or any combination thereof. If implemented in software, the function can be stored on a computer-readable medium or transmitted by a computer-readable medium as one or more instructions or codes. Computer-readable media include computer storage media and communication media, and the communication media include any media that helps to transfer a computer program from one location to another. The storage medium can be any available medium that can be accessed by a general or special computer. As an example and not limiting, the computer-readable medium may include RAM, ROM, EEPROM, CD-ROM or other optical disk storage devices, disk storage devices or other magnetic storage devices, or any other medium that can be used to carry or store the required program code in the form of an instruction or data structure and can be accessed by a general or special computer or a general or special processor. In addition, any connection can be appropriately referred to as a computer-readable medium. For example, if a coaxial cable, optical fiber cable, twisted pair, digital subscriber line (DSL) or wireless technologies such as infrared, radio and microwaves are used to send software from a website, server or other remote source, the above-mentioned coaxial cable, optical fiber cable, twisted pair, DSL or wireless technologies such as infrared, radio and microwaves are all included in the definition of the medium. As used herein, disk and disc include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk, Blu-ray disc, wherein disks usually reproduce data magnetically, while optical discs reproduce data optically with lasers. Combinations of the above should also be included within the scope of computer-readable media.
以上是本申请公开的示例性实施例,但是应当注意,在不背离权利要求限定的本申请实施例公开的范围的前提下,可以进行多种改变和修改。根据这里描述的公开实施例的方法权利要求的功能、步骤和/或动作不需以任何特定顺序执行。此外,尽管本申请实施例公开的元素可以以个体形式描述或要求,但除非明确限制为单数,也可以理解为多个。The above are exemplary embodiments disclosed in the present application, but it should be noted that various changes and modifications may be made without departing from the scope disclosed in the embodiments of the present application as defined in the claims. The functions, steps and/or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present application may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.
应当理解的是,在本文中使用的,除非上下文清楚地支持例外情况,单数形式“一个” 旨在也包括复数形式。还应当理解的是,在本文中使用的“和/或”是指包括一个或者一个以上相关联地列出的项目的任意和所有可能组合。It should be understood that, as used herein, the singular forms "a", "an", and "the" are used unless the context clearly supports an exception. It is intended to include plural forms as well.It should also be understood that "and/or" used herein is meant to include any and all possible combinations of one or more of the associated listed items.
上述本申请实施例公开实施例序号仅仅为了描述,不代表实施例的优劣。The serial numbers of the embodiments disclosed in the above-mentioned embodiments of the present application are only for description and do not represent the advantages or disadvantages of the embodiments.
本领域普通技术人员可以理解实现上述实施例的全部或部分步骤可以通过硬件来完成,也可以通过程序来指令相关的硬件完成,程序可以存储于一种非易失性可读存储介质中,上述提到的存储介质可以是只读存储器,磁盘或光盘等。A person of ordinary skill in the art will appreciate that all or part of the steps to implement the above embodiments may be accomplished by hardware, or may be accomplished by instructing related hardware through a program, and the program may be stored in a non-volatile readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk, or an optical disk, etc.
所属领域的普通技术人员应当理解:以上任何实施例的讨论仅为示例性的,并非旨在暗示本申请实施例公开的范围(包括权利要求)被限于这些例子;在本申请实施例的思路下,以上实施例或者不同实施例中的技术特征之间也可以进行组合,并存在如上的本申请实施例的不同方面的许多其它变化,为了简明它们没有在细节中提供。因此,凡在本申请实施例的精神和原则之内,所做的任何省略、修改、等同替换、改进等,均应包含在本申请实施例的保护范围之内。 A person of ordinary skill in the art should understand that the discussion of any of the above embodiments is merely exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present application (including the claims) is limited to these examples; under the idea of the embodiments of the present application, the technical features in the above embodiments or different embodiments may also be combined, and there are many other changes in different aspects of the embodiments of the present application as above, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application shall be included in the protection scope of the embodiments of the present application.

Claims (20)

  1. 一种链路中子网管理的方法,其特征在于,包括以下步骤:A method for subnet management in a link, characterized by comprising the following steps:
    在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;Create a configuration file in the preset location under the system directory and write the subnet information to be connected into the configuration file;
    响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;In response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain subnet information;
    根据子网信息计算子网的IP地址的范围;Calculate the range of IP addresses of the subnet based on the subnet information;
    根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。According to the calculated range of IP addresses of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively.
  2. 根据权利要求1所述的方法,其特征在于,在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中包括:The method according to claim 1 is characterized in that creating a configuration file in a preset location under a directory of the system, and writing the subnet information to be connected into the configuration file comprises:
    在系统的目录下的预设位置创建预设名称的配置文件,并记录配置文件的地址和名称;Create a configuration file with a preset name in a preset location under the system directory, and record the address and name of the configuration file;
    将待连接的子网信息写入到创建的配置文件中,子网信息的格式为IP地址/子网掩码。Write the subnet information to be connected to the created configuration file. The format of the subnet information is IP address/subnet mask.
  3. 根据权利要求2所述的方法,其特征在于,响应于接收到连接各个子网的指令,解析配置文件以获取子网信息包括:The method according to claim 2, characterized in that, in response to receiving an instruction to connect to each subnet, parsing the configuration file to obtain the subnet information comprises:
    响应于接收到连接各个子网的指令,在记录的地址中找到相应名称的配置文件;In response to receiving the instruction to connect to each subnet, finding the configuration file with the corresponding name in the recorded address;
    解析配置文件以得到IP地址和子网掩码的值。Parse the configuration file to get the values of IP address and subnet mask.
  4. 根据权利要求3所述的方法,其特征在于,根据子网信息计算子网的IP地址的范围包括:The method according to claim 3, characterized in that calculating the range of the IP address of the subnet according to the subnet information comprises:
    使用公式N=2^(32-子网掩码)计算子网信息中包含的IP地址的个数,其中N为子网信息中包含的IP地址的个数;Use the formula N = 2^(32-subnet mask) to calculate the number of IP addresses contained in the subnet information, where N is the number of IP addresses contained in the subnet information;
    确定子网的IP地址的范围为配置文件中IP地址后连续N-1个IP地址。The range of IP addresses for the subnet is determined to be N-1 consecutive IP addresses after the IP address in the configuration file.
  5. 根据权利要求1所述的方法,其特征在于,根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接包括:The method according to claim 1 is characterized in that, according to the calculated range of the IP addresses of the subnet, the host calls the connection establishment mechanism to establish connections with the IP addresses in the range respectively, comprising:
    调用RDMA的第一API并发送判断链路是否连通的信息;Call the first API of RDMA and send information to determine whether the link is connected;
    响应于接收到表征链路连通的第一返回信息,调用RDMA的第二API并发送判断路由 是否解析成功的信息;In response to receiving the first return information indicating link connectivity, calling the second API of RDMA and sending the judgment route Information on whether the parsing was successful;
    响应于接收到表征路由解析成功的第二返回信息,调用RDMA的第三API并发送建立连接的信息;In response to receiving the second return information indicating successful route resolution, calling a third API of RDMA and sending information for establishing a connection;
    响应于接收到表征连接建立成功的第三返回信息,确定本机与IP地址范围中的一个IP地址建立连接成功。In response to receiving the third return information indicating that the connection is successfully established, it is determined that the local device has successfully established a connection with an IP address in the IP address range.
  6. 根据权利要求1所述的方法,其特征在于,还包括:The method according to claim 1, further comprising:
    响应于主机与子网建立连接成功,记录子网的IP地址;In response to the host successfully establishing a connection with the subnet, the IP address of the subnet is recorded;
    响应于主机与子网建立连接失败,每经过阈值时间与建立连接失败的子网重新建立连接直到达到阈值次数。In response to the host failing to establish a connection with a subnet, the host re-establishes a connection with the subnet to which the connection failed after a threshold time has passed until a threshold number of times is reached.
  7. 根据权利要求1所述的方法,其特征在于,还包括:The method according to claim 1, further comprising:
    响应于接收到断开与各个子网的连接的指令,将配置文件中的子网信息删除;In response to receiving an instruction to disconnect from each subnet, deleting the subnet information in the configuration file;
    响应于检测到配置文件中没有子网信息,停止正在与子网建立的连接,并将已经建立的连接断开;In response to detecting that there is no subnet information in the configuration file, stopping the connection being established with the subnet and disconnecting the established connection;
  8. 根据权利要求5所述的方法,其特征在于,还包括:The method according to claim 5, further comprising:
    当所述子网中的IP地址全部尝试与所述主机建立连接后,设定定时器,以基于定时器在设定时间后再次尝试与没有连接成功的IP地址建立连接,直到连接成功或达到最大重试次数。After all IP addresses in the subnet have attempted to establish a connection with the host, a timer is set to attempt to establish a connection with the IP addresses that have not been successfully connected after a set time based on the timer until the connection is successful or the maximum number of retries is reached.
  9. 根据权利要求5所述的方法,其特征在于,所述判断链路是否连通的信息为rdma_resolve_addr(cm_id,src_ip,dst_ip,timeout),其中src_ip是主机的IP地址,dst_ip是IP地址范围中的一个IP地址。The method according to claim 5 is characterized in that the information for determining whether the link is connected is rdma_resolve_addr(cm_id, src_ip, dst_ip, timeout), wherein src_ip is the IP address of the host and dst_ip is an IP address in the IP address range.
  10. 根据权利要求5所述的方法,其特征在于,所述第一返回信息为RDMA_CM_EVENT_ADDR_RESOLVED,所述判断路由是否解析成功的信息为rdma_resolve_route(cm_id,timeout)。The method according to claim 5 is characterized in that the first returned information is RDMA_CM_EVENT_ADDR_RESOLVED, and the information for determining whether the route is resolved successfully is rdma_resolve_route(cm_id, timeout).
  11. 根据权利要求9或10所述的方法,其特征在于,所述timeout是自定义的一个超时时间。The method according to claim 9 or 10 is characterized in that the timeout is a custom timeout period.
  12. 根据权利要求5所述的方法,其特征在于,所述第二返回信息为RDMA_CM_EVENT_ROUTE_RESOLVED,所述建立连接的信息为rdma_connect(cm_id,arg)。 The method according to claim 5 is characterized in that the second return information is RDMA_CM_EVENT_ROUTE_RESOLVED, and the information for establishing the connection is rdma_connect(cm_id, arg).
  13. 根据权利要求5所述的方法,其特征在于,所述第三返回信息为RDMA_CM_EVENT_ESTABLISHED。The method according to claim 5 is characterized in that the third return information is RDMA_CM_EVENT_ESTABLISHED.
  14. 根据权利要求5所述的方法,其特征在于,在所述第一返回信息、所述第二返回信息以及所述第三返回信息中的任意一个表示失败时,发出告警信息。The method according to claim 5 is characterized in that an alarm message is issued when any one of the first return information, the second return information and the third return information indicates a failure.
  15. 根据权利要求5所述的方法,其特征在于,在所述第一返回信息、所述第二返回信息以及所述第三返回信息中的任意一个表示失败时,在等待预定时长后重试。The method according to claim 5 is characterized in that when any one of the first return information, the second return information and the third return information indicates failure, retrying after waiting for a predetermined period of time.
  16. 根据权利要求1所述的方法,其特征在于,在获取到IP地址的范围后,还包括:基于RDMA CM连接机制依次对每个IP地址建立连接。The method according to claim 1 is characterized in that after obtaining the range of IP addresses, it also includes: establishing a connection for each IP address in turn based on the RDMA CM connection mechanism.
  17. 根据权利要求5所述的方法,其特征在于,从发起连接到连接成功共通过以下三个CM事件:RDMA_CM_EVENT_ADDR_RESOLVED、RDMA_CM_EVENT_ROUTE_RESOLVE、RDMA_CM_EVENT_ESTABLISHED;所述三个CM事件分别调用以下三个API后产生:rdma_resolve_addr、rdma_resolve_route、rdma_connect。The method according to claim 5 is characterized in that the following three CM events are passed from initiating the connection to successfully connecting: RDMA_CM_EVENT_ADDR_RESOLVED, RDMA_CM_EVENT_ROUTE_RESOLVE, and RDMA_CM_EVENT_ESTABLISHED; the three CM events are generated by calling the following three APIs respectively: rdma_resolve_addr, rdma_resolve_route, and rdma_connect.
  18. 一种链路中子网管理的装置,其特征在于,所述装置包括:A device for subnet management in a link, characterized in that the device comprises:
    写入模块,所述写入模块配置为在系统的目录下的预设位置创建配置文件,将待连接的子网信息写入配置文件中;A writing module, wherein the writing module is configured to create a configuration file at a preset location under a directory of the system, and write the subnet information to be connected into the configuration file;
    获取模块,所述获取模块配置为响应于接收到连接各个子网的指令,解析配置文件以获取子网信息;an acquisition module, the acquisition module being configured to parse the configuration file to acquire the subnet information in response to receiving an instruction to connect to each subnet;
    计算模块,所述计算模块配置为根据子网信息计算子网的IP地址的范围;A calculation module, wherein the calculation module is configured to calculate a range of IP addresses of a subnet according to the subnet information;
    连接模块,所述连接模块配置为根据计算得到的子网的IP地址的范围,主机调用建立连接机制分别与范围内的IP地址建立连接。The connection module is configured to, according to the calculated range of the IP address of the subnet, enable the host to call a connection establishment mechanism to establish connections with the IP addresses in the range respectively.
  19. 一种计算机设备,其特征在于,包括:A computer device, comprising:
    至少一个处理器;以及at least one processor; and
    存储器,所述存储器存储有可在所述处理器上运行的计算机指令,所述指令由所述处理器执行时实现权利要求1-17中任意一项所述方法的步骤。A memory storing computer instructions executable on the processor, wherein the instructions, when executed by the processor, implement the steps of the method according to any one of claims 1 to 17.
  20. 一种非易失性可读存储介质,所述非易失性可读存储介质存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求1-17中任意一项所述方法的步骤。 A non-volatile readable storage medium storing a computer program, wherein the computer program implements the steps of the method described in any one of claims 1 to 17 when executed by a processor.
PCT/CN2023/100829 2022-11-16 2023-06-16 Method and apparatus for managing subnets in link, and device and readable medium WO2024103716A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202211430496.7A CN115499489B (en) 2022-11-16 2022-11-16 Method, device, equipment and readable medium for managing sub-network in link
CN202211430496.7 2022-11-16

Publications (1)

Publication Number Publication Date
WO2024103716A1 true WO2024103716A1 (en) 2024-05-23

Family

ID=85116337

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/100829 WO2024103716A1 (en) 2022-11-16 2023-06-16 Method and apparatus for managing subnets in link, and device and readable medium

Country Status (2)

Country Link
CN (1) CN115499489B (en)
WO (1) WO2024103716A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115499489B (en) * 2022-11-16 2023-02-28 苏州浪潮智能科技有限公司 Method, device, equipment and readable medium for managing sub-network in link

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040049600A1 (en) * 2002-09-05 2004-03-11 International Business Machines Corporation Memory management offload for RDMA enabled network adapters
KR20080038809A (en) * 2006-10-31 2008-05-07 삼성전자주식회사 Apparatus and method for inter-process communication of communication system inside
US20140344329A1 (en) * 2013-05-20 2014-11-20 International Business Machines Corporation Communication System Employing Subnet Or Prefix To Determine Connection To Same Network Segment
WO2021064661A1 (en) * 2019-10-05 2021-04-08 Digital Energy Technologies Ltd. Computer systems and methods for managing ip addresses
CN114866515A (en) * 2022-04-21 2022-08-05 重庆紫光华山智安科技有限公司 IP address configuration method, device, electronic equipment and storage medium
CN115499489A (en) * 2022-11-16 2022-12-20 苏州浪潮智能科技有限公司 Method, device, equipment and readable medium for managing sub-network in link

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105634857A (en) * 2014-11-26 2016-06-01 中兴通讯股份有限公司 Link connectivity detecting method and device
CN106789966B (en) * 2016-12-05 2020-08-14 广州海格通信集团股份有限公司 Call service routing processing method and system
CN110769482B (en) * 2019-09-16 2022-03-01 浙江大华技术股份有限公司 Method and device for network connection of wireless equipment and wireless router equipment
CN113452736A (en) * 2020-03-26 2021-09-28 深圳迈瑞生物医疗电子股份有限公司 Patient monitoring system and method for establishing data communication connection in patient monitoring system
CN111585845B (en) * 2020-05-15 2021-08-31 苏州浪潮智能科技有限公司 Method, device and equipment for detecting network card node performance and readable medium
CN112689029A (en) * 2020-12-30 2021-04-20 海信视像科技股份有限公司 Method, device and equipment for acquiring IP address of group user
CN114567558B (en) * 2022-01-14 2023-08-18 苏州浪潮智能科技有限公司 Method, device, equipment and medium for configuring virtual network card by computer cluster
CN115348305A (en) * 2022-07-14 2022-11-15 苏州浪潮智能科技有限公司 Connection management method, system, computer device and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040049600A1 (en) * 2002-09-05 2004-03-11 International Business Machines Corporation Memory management offload for RDMA enabled network adapters
KR20080038809A (en) * 2006-10-31 2008-05-07 삼성전자주식회사 Apparatus and method for inter-process communication of communication system inside
US20140344329A1 (en) * 2013-05-20 2014-11-20 International Business Machines Corporation Communication System Employing Subnet Or Prefix To Determine Connection To Same Network Segment
WO2021064661A1 (en) * 2019-10-05 2021-04-08 Digital Energy Technologies Ltd. Computer systems and methods for managing ip addresses
CN114866515A (en) * 2022-04-21 2022-08-05 重庆紫光华山智安科技有限公司 IP address configuration method, device, electronic equipment and storage medium
CN115499489A (en) * 2022-11-16 2022-12-20 苏州浪潮智能科技有限公司 Method, device, equipment and readable medium for managing sub-network in link

Also Published As

Publication number Publication date
CN115499489B (en) 2023-02-28
CN115499489A (en) 2022-12-20

Similar Documents

Publication Publication Date Title
US10592464B2 (en) Methods for enabling direct memory access (DMA) capable devices for remote DMA (RDMA) usage and devices thereof
JP6091724B2 (en) Link health check method and apparatus
US8725879B2 (en) Network interface device
CN109922144B (en) Method and apparatus for processing data
EP3547715A1 (en) Method and apparatus for reducing continuous-wakeup delay of bluetooth loudspeaker, and bluetooth loudspeaker
WO2024103716A1 (en) Method and apparatus for managing subnets in link, and device and readable medium
WO2018077052A1 (en) Upgrading method and device for virtual switch
CN111953770B (en) Route forwarding method and device, route equipment and readable storage medium
US8156209B1 (en) Aggregation devices processing keep-alive messages of point-to-point sessions
CN114500633B (en) Data forwarding method, related device, program product and data transmission system
CN113595927A (en) Method and device for processing mirror flow in bypass mode
KR20170068533A (en) Method and apparatus for processing virtual card
CN113076281B (en) Method, system, equipment and medium for communication of Ceph kernel client
CN109600436A (en) A kind of distribution iscsi service implementing method, system and relevant apparatus
WO2017054734A1 (en) Locking file management method and device
CN109413142B (en) Method for realizing iSCSI virtual agent under L inux
EP4344259A1 (en) Session binding relationship processing method and apparatus, electronic device, and readable medium
US11638134B2 (en) Methods, systems, and computer readable media for resource cleanup in communications networks
CN110609866A (en) Method, apparatus and computer program product for negotiating transactions
EP4030679A1 (en) Sequence number synchronization method and apparatus
WO2016086876A1 (en) Packet processing method, network server and virtual private network system
CN105573935B (en) Level IO
CN111600814B (en) VFC interface configuration method and device
CN116760850B (en) Data processing method, device, equipment, medium and system
WO2021077967A1 (en) Network device management method, apparatus, and system