MC68VZ328 smart home gateway solution
introduction The smart home network is another high-tech product brought to people by the information age. It uses the existing computer network technology to connect various home appliances and devices inside the home, and provides people with rich, diverse, personalized, convenient, comfortable, safe and efficient services through the network. Home networking is also an important part of the entire social informationization. The basic structure of the intelligent home network system is shown in Figure 1. The exchange of home internal information and home external information is undoubtedly the purpose of home networking, and its implementation needs to design an ideal home gateway. 1 home gateway The home gateway acts as an interface between the home network and the Internet, as shown in Figure 2. The home gateway should have the following basic functions: 1 as a physical interface that connects all external access networks to the home and connects the home internal network to the outside; 2 to enable residential users to access a variety of home services (including existing and future possible services) platform; 3 Assign IP addresses to devices in the home network. Devices in each home network must have unique IP addresses (only for internal use within the home network). For this type of home-only IP, only the home gateway can be used. Configuration 4 routing function, the complexity of the home network makes it possible to have multiple sub-protocols with different physical protocols. The home gateway must have the function of routing, and send the bandwidth information from the Internet to the corresponding device, and also realize the communication between devices. And division of labor and cooperation; 5 shared broadband connection, enabling multiple PCs and other information devices within the home to effectively share broadband access. 2.1 Hardware Architecture of Intelligent Home Gateway The hardware architecture of the smart home gateway is shown in Figure 3. The intelligent home gateway hardware system uses Motorola's 68VZ328 processor chip, with 4MB of Flash and 2MB of SDRAM memory, provides RS232/RS485, USB, I/O and Ethernet interfaces, and can easily expand a variety of smart home networks. Physical interface. 2.2 Software Architecture of Intelligent Home Gateway 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 window operating system is designed according to the actual needs in the home gateway system; and since the network function is not implemented in the PPSM system, it is added when the PPSM system is modified. The TCP/IP protocol stack allows network functions to be implemented in this operating system. 3 embedded TCP / IP protocol stack development The implementation of the TCP/IP protocol stack in the embedded system is hardware hardening and software implementation. The hardware mode means that the TCP/IP protocol stack is implemented by hardware. The embedded system is directly connected with the hardware chip of the TCP/IP protocol stack, and the protocol conversion is realized by it, thereby connecting with the Internet. But this undoubtedly increases the hardware cost. For some single embedded devices, connecting a complete TCP/IP hardware stack is a great waste, and the added cost is difficult to negotiate. It is a huge Waste, and the added cost is unacceptable. Therefore, in this system, the choice of software to implement the embedded TCP/IP protocol has greater advantages. The advanced operating system can support the TCP/IP protocol family, but the PPSM system we chose is not supported. Therefore, the TCP/IP protocol family must be added according to the actual needs of the system. When adding the TCP/IP protocol family, a unique TCP/IP protocol family is designed according to the characteristics and functions of the system, and the parts related to the requirements are implemented, and the unnecessary protocols are not supported. Secondly, the protocols used are based on the specific The application made the necessary modifications. Combined with the actual situation of the system, the finite machine model for constructing embedded TCP for controlling actions is shown in Fig. 6. Modifications and simplifications have been made where it is not necessary for embedded systems, but still maintain consistency with standard TCP protocols. When designing the embedded Web server, only the HTTP protocol is supported in the TCP in the system. The embedded system stores the current real-time data such as data collection and running parameters into the relevant position of the webpage in the memory. For any TC connection, only the HTTP protocol is sent to the wind page service at a time, and each web page size is limited to one data packet without the splitting of the IP packet. As an embedded Web server, the TCP connection is only in the state of passive service, so the standard TCP finite state machine can actively create the SYN-ENT state of the connection, and actively close the connected FIN-AIT1, FIN-AIT2, CLOSING, TIME-AIT. The state is omitted. In the design, the CLOSED state is also removed, so that it is in the LISTEN state at the beginning to listen to the client's connection request, avoiding active or passive open operations, which is more efficient for embedded situations. In the process of establishing a connection in 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 the passive opening, and the other party initiates the connection. When it receives the SYN data slice, it sends a SYN+ACK data slice and confirms that it has received the SYN of the other party, which changes to the SYN+RECIVED state. After receiving an empty data piece containing only ACK returned by the other 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, the port number, the IP address, the serial number, the window size, and the like, and the response control block TCB structure represent different connections, and multiple connections are established for different client requests, one-to-one correspondence, and concurrent execution. It is not realistic to implement such a complicated operation in the embedded TC palace. Therefore, the current state of the TCP connection is not recorded in the design, and multiple TCP connections are not established separately. The analysis is as follows: After a message is sent from the lower layer protocol, the information in the segment and the information in the TCP cannot be compared for processing. Since the information about the connection established in the past is not remembered, the connection is not known. Whether or not there is a state, etc., only based on the relevant information (control bits and presence or absence of data) in the received packet, the connection state is judged to respond. The overview of the connection is, to a certain extent, only for the client PC, giving it the illusion that a connection exists. Because the embedded server end does not store the connected information, it is equivalent to the existence of no connection, and responds to all connections, so that multiple connections can be realized under the condition of limited system resources. In the TCP connection, if one party terminates abnormally or closes a connection due to a crash or the like, a half-open connection problem occurs. Since the abnormal party loses the stored information, if either party sends the data, the other party will reply to the reset signal. Connection reset. For embedded systems, when the client is abnormal and the embedded system sends data, it will be reset to the reset signal. When the embedded system is abnormal and restarts, it has no effect because it does not store information. When the network times out and loses packets, it is usually resent between the timeout retransmission mechanism. After the embedded system sends the packet, the packet is not saved. This does not consider the retransmission problem. After the packet is lost, the client can't receive the confirmation packet, and the packet sent for itself is lost, and the timeout is retransmitted. The embedded system responds to the concurrent packet at this time, and the reliability can still be guaranteed. The embedded system does not memorize the serial number of the TCP connection. In addition to initializing the serial number when establishing the connection for the first time, the serial number is determined according to the value in the other party's packet, so it cannot recognize the duplicate message and responds as usual. The processing of this repeated message is handed over to the other party for processing, and the basic work requirements can still be met. For the HTTP service that relies on the TCP connection, the embedded server only responds to the client request on the server side, and the received one packet datagram can be transmitted, so there is no need to consider the out-of-sequence problem. ... 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, and in the next step, the control function of using the telephone to the home gateway will be gradually added. In this way, people can use the smart home gateway to realize the functions that people can only achieve on the Internet when they can't access the Internet. Promotion Power Station for EU Promotion Power Station For Eu,Portable Power Station,Solar Power Station,Power Station For Laptop Guangzhou Fengjiu New Energy Technology Co.,Ltd , https://www.flashfishbatteries.com
2 Implementation of intelligent home gateway
The software architecture is shown in Figure 4.
In this system, the embedded TCP/IP protocol stack implements protocols such as ARP, IP, ICMP, TCP, UDP, and HTTP. The basic protocol handler is as shown.
In the operating system, in order to prevent confusion caused by the old repeated connection request, this situation can be handled by resetting the RESET control message. After receiving the reset RESET signal, if it is in the non-synchronized state (SYNRECIVED, SYN-SEND), it will return to the LISTEN state; if it is in any kind of synchronization state, it will terminate the connection abnormally and notify its users to cancel in the system. CLOSE state, so when receiving the reset RESET control message, it returns to the LISTEN state. The actual state does not remember the current state, so no operation is required, and the RESET message is never reset because it is always in the passive state.
When designing a TCP finite state machine, a process is used to initiate a process for each input state. When an event occurs, TCP uses the current state to select an appropriate process. The process processes the input event and updates the current state variable value, that is, each state corresponds to a process. When an input segment arrives, TCP calls the process corresponding to the current state for processing. The program is mainly as follows: