• 沒有找到結果。

Client-Server Networking Architecture

在文檔中 穩定與指向機構之研究 (頁 53-57)

CHAPTER 4 ROBOTIC SAFEGUARD SYSTEM AND

4.6 Client-Server Networking Architecture

In the client-server architecture, the Network Class Library is the fundamental element of the program organization of this thesis. By utilizing the classes, the NETCOMM program can be constructed. As shown in Figure 38, it is very clear to show that there are some classes created in NETCOMM program. Where, “arrow” represents the inherited relationship between two classes. According to the inheritable feature of the object, a subclass will inherit all behaviors of parent class and own some private data or member functions different from the parent class. For example, the class RobotArmClient inherits the class TStreamSocket, such RobotArmClient owns the network communication capability provided by TStreamSocket.

Because the supervision is applied, it is necessary to monitor the returned information and give its command simultaneously. We adopt Full-Duplex Communication to let the information be sent back and the command be provided, therefore they won’t interrupt each other.

Because the central supervised computer processes all messages and information, the burden will be heavy. As the workload is growing and can’t be handled, the task of performing supervising can’t be done

41

continuously. The controlled-end will produce some unexpected situations. Central-supervised hierarchical architecture is an ideal way to solve the above problem. The concept is “central monitoring and distributed control”. That means the local-end will still function well when the centrally controlled-end goes wrong. By achieving this, the efficiency of the system will be much higher. The client-server mode for the network is very similar to this kind of hierarchical architecture, so it is suitable for remote supervision application. As follows, some classes of this program, and their main functions will be introduced.

4.6.1 Client

RobotArmClient inherits TStreamSocket, so it also inherits all behaviors except private methods. RobotArmClient has the capabilities for giving commands, and transmitting and receiving data.

The class segments are also shown in Figure 38. The most important member function of RobotArmClient is ProcessRead(). It is similar to an interpreter but it performs the tasks after receiving data. Another important issue is that RobotArmClient and RobotArmServer must be coordinated with each other, so they must have the same protocol. The content and rule of the protocol will be mention in next section. After both sides have same protocol, ProcessRead() can make the right explanation, execute right commands and transmit correct data.

The class will be used with other programs. So we use class RobotArmClient to do the integration to eliminate the difficulty and complexity.

4.6.2 Server

42

RobotArmServer inherits TStreamSocket as RobotArmClient does, and the most methods are the same as RobotClient. Some methods will be redefined in RobotArmServer, but will not be in RobotArmClient, such as the member function BeforeCloseSocket().

BeforeCloseSocket() doesn’t only handle the normal disconnection, but also charges emergency handling abnormal disconnection, so it’s a very important function.

The forming factor of service model is finding some restrictions and drawbacks in a two-layer architecture. For example, it is hard to share the same procedures or objects, the problems of security, and the main restriction from the browser. So service model is a good solution for it. Service model is divided into three layers, which are source service, agent service, and target service. The advantages of this model are easy to manage clients, powerful interface management, better security, and multipurpose, and so on. Two cases indicate some advantages of server model.

Although two-layer architecture for client-server application programs is simple and convenience to develop, it is not perfect. There are still some restrictions in it. First, it is hard to mange clients. For example, because client application programs could be anywhere on the Internet, if you change a little, you must to update all client application programs. The work isn’t easy to do. Second, it is hard to share the same procedures. Third, there are some security problems.

Fourth, if the client is an applet, it can’t connect anywhere except the place which the applet is loaded. The reason is to prevent security problems. So in this case, two-layer architecture is not suitable but three-layer architecture is. Three-layer architecture is that adds a layer

43

between source-end and target-end. Figure 39 indicates three-layer architecture. Clearly to say, they have the relationship of control-end and controlled-end. Three-layer architecture is without the restrictions of two-layer architecture. First, the whole architecture is hierarchy. If it is designed properly, the change of some services provided by second layer changes doesn’t affect the other services. If the change is internal operation rather than interface, no services are needed to change. Second, agent server indicating the server of second layer is designed for multipurpose, so its services can be shared with clients, which is applied for various purpose. Third, source-end doesn’t directly connect to the target-end, so there is no back door that allows users to have a chance to destroy target-end. We can say that the three-layer architecture is securer than the two-layer architecture.

Fourth is that the coding of clients become simpler.

Before the two cases are started, we must do some preparatory work. There is a test program used to test the three-layer architecture and protocol in Figure 40 (a). The purpose of the test program is to make sure the whole architecture is okay, and the server of second layer can parse the incoming messages, and dispatch the message correctly. The test program can be used not only as source-end but also as target-end, so the agent server can cooperate with test program to simulate the operation of three-layer architecture. In Figure 40 (b), there is a smaller window, and its functions provide all defined types.

After the “send” button is depressed, it makes a frame, and sent it to target-end. Server design is not an easy work. Some factors must be considered. For instance, the security issue is an important part of network programming. We use some ways considered to achieve the

44

purpose of protection. Another issue is how to make the server robust, if the server is not robust, there may be a big trouble, because the agent server of second layer is the kernel of the whole architecture.

Once the agent server is broken down, the whole works must be affected. This is why we use Java to write the agent server. We can utilize exception handling to prevent any condition that could happen to server. From the test program, the agent server’s problems can be found out in advance. The following are two cases for the robotic safeguard networking study.

在文檔中 穩定與指向機構之研究 (頁 53-57)

相關文件