Recently, many netizens asked how to configure the dual-protocol stack. Let's take a look at the following articles. We all know that the speed of network development is amazing, and the functions and applications of the format are dazzling. Behind these features and applications are the support of many network protocols. Here we will focus on the use of Visual C ++ 6.0 development environment on Windows platform for Embedded TCP/IP protocol stack development and simulation debugging methods. It explains in detail how to use Winpcap to receive and send IP data packets and how to configure dual-protocol stack on Windows.
1 Introduction
With the wide application of the Internet, embedded devices support TCP/IP to connect to the Internet and communicate with the outside world, therefore, the TCP/IP protocol stack must be supported in the embedded system. although the current commercial embedded operating systems, such as VxWorks, QNX, pSOS, and VRTX, all provide TCP/IP-based network components, to meet the needs of various applications, the implementation is too complex and requires a large amount of system resources. the resources of embedded systems are limited, and their applications and functions are relatively simple and targeted. Therefore, a complete TCP/IP network protocol component is not required, you only need to implement some of the Protocols related to the requirements, and do not need to support those that are not used. on the other hand, for some specific embedded systems, you even need to optimize the TCP/IP protocol stack or write the desired network protocol in the TCP/IP protocol stack. the TCP/IP protocol stacks of commercial embedded systems that cannot provide open source code are difficult to meet users' Configuration Requirements, you need to develop and customize the embedded TCP/IP protocol stack that suits your system requirements.
2 embedded protocol stack development and debugging
Generally, the development and debugging of embedded systems use their corresponding development and debugging tools to connect the computer and the target machine for cross-Development and debugging. for example, Tornado, a widely used VxWorks embedded real-time operating system development tool, is a powerful cross-development tool that allows you to debug applications on the target machine using a graphical interface on a computer.
However, even if we use an excellent embedded development environment like Tornado, we still cannot cope with large programs such as the cross-debugging protocol stack. It is time-consuming and labor-consuming to develop and debug the program, this greatly increases the difficulty of system development and the Development and debugging cycle. if the development of the embedded TCP/IP protocol stack can be developed and simulated on the Windows platform in the early stage, it will be a very meaningful task.
Although the embedded TCP/IP protocol stack is based on an embedded operating system, in addition to receiving and sending data packets, it almost does not directly deal with the underlying hardware. therefore, it is completely feasible to simulate, debug, and run the TCP/IP protocol stack on the Windows platform. It can be used to develop and debug most of the functions and then transplanted to the embedded system, the functions and performance of the entire embedded software system can be achieved through further debugging and testing. such a development process can greatly improve the development efficiency and reduce the development cycle.
3. Run the embedded protocol stack on Windows
Before configuring the dual-protocol stack, let's take a look at the content of running the embedded protocol stack on the Windows platform. To debug and run the TCP/IP protocol stack on Windows, you must first create a Win32 Application project in the Visual C ++ 6.0 development environment to simulate the embedded system, the embedded TCP/IP protocol stack runs in this Win32 application. in this way, we use a process on Windows to simulate a multi-task embedded operating system.
A multi-task embedded operating system requires task management, memory management, and inter-task communication mechanisms such as semaphores and message queues. therefore, to run an embedded TCP/IP stack on a Windows platform, you must also provide the basic functions of the preceding multi-task embedded operating system.
In a multi-task embedded operating system, a task is the most basic unit for scheduling. It participates in resource competition and allocates CPU resources between tasks, the System Schedules CPU time slices for each task in a loop manner. In the macro view, it seems that a number of tasks are processed concurrently to form a multi-task operating system. on a general operating system platform such as Winodows, threads are the smallest entity involved in CPU time slice resource competition. Therefore, we use threads to simulate a task in an embedded operating system. tasks can be created, deleted, and controlled by calling the Win32 API functions provided by the Windows platform to create, delete, and control threads.
In a multi-task operating system, tasks need to coordinate and cooperate with each other. This requires a mechanism for inter-task communication for synchronization and mutual exclusion. in embedded systems, semaphores, events, and message consumption mechanisms are generally provided for inter-task communication. similarly, Win32 APIs on Windows provide functions for semaphores, events, and message mechanisms for inter-process/thread communication.