introduction

The smart home network is another high-tech product brought to people by the information age. With the help of the existing computer network technology, it connects all kinds of household appliances and equipment inside the home to provide people with various rich, diverse, personalized, convenient, comfortable, safe and efficient services through the network. Family networking is also an important part of informationization of the whole society. The basic structure of the smart home network system is shown in Figure 1.

It is undoubtedly the purpose of home networking to realize the exchange of home information and home external information, and its implementation needs to design an ideal home gateway.

1 Home gateway

The home gateway serves as the interface between the home network and the Internet, as shown in Figure 2. The home gateway should have the following basic functions:

â‘  As a physical interface that connects all external access networks to the inside of the home and at the same time connects the internal network of the home to the outside;

â‘¡A platform that enables residential users to obtain various home services (including existing and future services);

â‘¢ Allocate IP addresses for devices in the home network. Each device in the home network must have a unique IP address (limited to the internal use of the home network). For this kind of IP limited to home use, only the home gateway can come Configuration

â‘£Routing function, the complexity of the home network makes it possible that there are multiple sub-protocols with different physical protocols. The home gateway must have a routing function to send bandwidth information from the Internet to the corresponding devices, and can also achieve communication between devices. And division of labor and cooperation;

⑤Broadband connection sharing enables multiple PCs and other information devices in the home to effectively share broadband access.

2 Realization of Smart Home Gateway

2.1 Hardware architecture of smart home gateway

The hardware architecture of the smart home gateway is shown in Figure 3.

The smart home gateway hardware system uses Motorola's 68VZ328 processor chip, with 4MB Flash and 2MB SDRAM memory, provides RS232 / RS485, USB, I / O and Ethernet interfaces to the outside, and can easily expand a variety of smart home networks Physical interface.

2.2 Software architecture of smart home gateway

The software architecture is shown in Figure 4.

In the software system of the home gateway, the PPSM system provided by Motorola is selected. Since the PPSM system does not provide a window system, a proper set of window operating system is designed after making appropriate modifications according to the actual needs in the home gateway system; and because the PPSM system does not implement network functions, it is added when the PPSM system is modified The TCP / IP protocol stack has been added so that network functions can be implemented in this operating system.

3 Development of embedded TCP / IP protocol stack

There are two ways to implement the TCP / IP protocol stack in the embedded system: hardware curing and software implementation. The hardware means that the TCP / IP protocol stack is implemented in hardware, and the embedded system is directly connected to the TCP / IP protocol stack hardware chip, which implements the protocol conversion and connects it to the Internet. However, this undoubtedly increases the hardware cost. For some single-function embedded devices, connecting a complete TCP / IP hardware negotiation stack is a great waste, and the added cost is difficult to negotiate, which is a huge Wasted, and the added cost is unacceptable. Therefore, in this system, the use of software to achieve embedded TCP / IP protocol has greater advantages.

The advanced operating system can support the TCP / IP protocol family, but the PPSM system we selected is not supported, so the support function for the TCP / IP protocol family must be added according to the actual needs of the system. When adding the TCP / IP protocol family, the unique TCP / IP protocol family is designed according to the characteristics and functions of the system to realize the parts related to the needs, and the unneeded protocols are not supported; secondly, the protocols used are based on the specific The application makes the necessary modifications.

In this system, the embedded TCP / IP protocol stack implements ARP, IP, ICMP, TCP, UDP, HTTP and other protocols. The basic protocol processing procedures are as shown.

Combined with the actual situation of the system, a finite machine model for building embedded TCP for control actions is shown in Figure 6. Modifications and simplifications have been made in places that are unnecessary for embedded systems, but still maintain consistency with standard TCP protocols.

When designing an embedded Web server, only the HTTP protocol is supported in TCP in the system. The embedded system stores the current real-time data such as data collection and operating parameters in the relevant location of the web page in the memory. For any TC connection, it only supports the HTTP protocol to send the wind page service every time, and limits the size of each web page to one data packet, without splitting the IP packet. As an embedded Web server, TCP connection is only in passive service state, so you can use the standard TCP finite state machine to actively create the SYN-ENT state of the connection, and actively close the connection FIN-AIT1, FIN-AIT2, CLOSING, TIME-AIT The state is omitted. In the design, the CLOSED state is also removed, and it is in the LISTEN state from the beginning to monitor the client's connection request, avoiding the active or passive open operation, which is more efficient for embedded occasions.

In the process of establishing a connection with the three-way handshake, the embedded system, as the server side of the listening state, is always the passive side, which is equivalent to the LISTEN state after passive opening, waiting for the other party to initiate the connection. When it receives the SYN data slice, it sends out the SYN + ACK data slice and confirms that it has received the other party's SYN, and then it becomes the SYN + RECIVED state. After receiving an empty data piece containing only ACK returned by the opposite party, the three-way handshake is completed, and the ESTABLISHED state is entered, and then TCP data communication can be performed.

In the operating system, in order to prevent the old repeated connection request from causing confusion, you can use reset RESET control text to deal with this situation. After receiving the reset RESET signal, if it is in a non-synchronized state (SYNRECIVED, SYN-SEND), it returns to the LISTEN state; if it is in any one of the synchronized states, it abnormally terminates the connection and informs its users to cancel in the system CLOSE state, so when the reset RESET control message is received, it returns to the LISTEN state. During actual processing, the current state is not memorized, so no operation is required, and the RESET message is never sent because it is always in a passive state.

In the operating system, the port number, IP address, serial number, window size, etc. and the response transmission control block TCB structure represent different connections, and establish multiple connections for different client requests, one-to-one correspondence, and concurrent execution. However, it is not realistic to implement such complicated operations in the embedded TC palace, so the current state of the TCP connection is not recorded in the design, nor are multiple TCP connections established separately. The analysis is as follows: after a message is sent from the lower layer protocol, the information in the message segment and the information in TCP cannot be compared for processing, because the relevant information of the connection established in the past is not remembered, so the connection is not known. Whether it exists and where it is, etc., only based on the relevant information in the received packet (control bits and the presence or absence of data), to determine the connection status and respond. To a certain extent, the overview of the connection is only for the client PC, giving it the illusion that a connection exists. The embedded telegrapher terminal does not store the connection information, which is equivalent to no connection, and responds to all connections before it can realize multi-connection under the condition of limited system resources.

In TCP connection, if one party abnormally terminates or closes a connection due to crash or other reasons, it will cause the problem of half-open connection. Because the abnormal party loses the stored information, if either party sends data, the other party will reply to the reset signal. Connection reset. For the embedded system, when the client is abnormal and the embedded system sends data, it will be returned with a reset signal; when the embedded system is abnormal and restarts, it has no stored information, so there is no impact.

When a timeout occurs and a packet is lost on the network, the timeout retransmission mechanism is generally used for retransmission. However, after the embedded system sends the packet, the packet is not saved, and the issue of retransmission is not considered. When the packet is lost, the interpreter can not receive the confirmation packet, and it retransmits it for the loss of its own packet, and the embedded system responds to the concurrent packet at this time, and the reliability can still be guaranteed.

The embedded system does not remember the serial number of the TCP connection. In addition to initializing the serial number when the connection is first established, the serial number is determined based on the value in the packet sent by the other party. Therefore, it cannot identify duplicate messages and responds as usual. Handing over the processing of this repeated message to the other party can still meet the basic work requirements. For HTTP services that rely on TCP connections, the embedded server only responds to client requests on the server side, and a received packet datagram can be transmitted, so there is no need to consider out-of-order problems.

When designing and implementing a TCP finite state machine, a process-driven scheme is used to start a process for each input state. When an event occurs, TCP uses the current state to select an appropriate process. This process processes input events and updates the current state variable value, that is, each state corresponds to a process. When an input message segment arrives, TCP calls the process corresponding to the current state to process. The procedure is mainly as follows:

…

if (SYN_IN && port_right) tcp_send_SYN_ACK 0;

else if (SYN_IN && port_num_wrong) tcp_send_RST_ACK 0;

else if (ACK_IN && port_num_right && have_data) http_process (tcp_ACK);

else if (FIN_IN && port_num_right && have_data) http_process (tcp_FIN);

else if (FIN_IN && port_num_right && no_data) tcp_send_FIN 0;

else

…

4 Summary

In this solution, only the network control function of the home gateway is implemented. In the next step, the control function of the home gateway using the telephone will be gradually added. In this way, people only need to use the phone when they cannot access the Internet, and they can realize the functions that people can only achieve on the Internet through the smart home gateway.

Non-detachable Earphones

In-Ear Wired Earbuds,Earphones With Mic,In-Ear Noise-Isolating Earbuds,Wired Earphones With Microphone

Dongguang Vowsound Electronics Co., Ltd. , https://www.vowsound.com