A year ago, I wanted to play PSP games (MHP3) with my friends online, but I didn't want to spend any money to buy an ICA card or other PSPXLink NICs, therefore, we decided to study the feasibility of developing PSP online software by ourselves. Download MengZone, a popular online software on the network, and install it and analyze it. The most important thing is that there is a WinPcapDll. dll library in the installation directory. Because I had some knowledge about WinPcap before, knowing that it can be used to capture network data of the NIC, and then MengZone introduced a USB online function, I went to query the PSP plug-in required for USB connection, ADHocToUSB. Its function is to intercept the data sent by PSP through the wireless network card, then transmit the data to the PC through USB. The PC also needs to run a software called Bridge for Nic bridging. In this way, the data transmitted from USB can be sent to the NIC (or reverse transmission ), in theory, WinPcap can be used for capture and processing (transmitted to other PCs over the Internet ).
After the analysis, I directly started writing code for testing. The programming language I used was C #, so I found a Managed class library of WinPcap: Pcap.net, which has very powerful functions, and meets my needs. This is the only third-party class library used for software development. After a simple test, PSP game data is captured successfully, but several problems are encountered in the middle. The first problem is through Pcap. the data captured by Net is two-way, that is, the data sent out and received is captured. What I only need to capture is the data sent from PSP to the PC. Otherwise, the whole software cannot run normally, so I checked the Pcap. NET source code, which has a PacketDeviceOpenAttributes. noCaptureLocal: add this parameter to solve the problem. The second problem is that Windows can create a virtual network card called Microsoft Loopback Driver for testing. It can be used as a dedicated data network card for PSP, but in this way, it will increase the burden on the software settings, so that people who do not know the computer can not use the software at all, so it is best to use the current Nic, however, WinPcap will capture all the network data through this NIC (here is an aside, some popular P2P Control Software in China, such as P2P Terminator and jusheng network management, it also uses WinPcap for ARP spoofing. After WinPcap captures the network packet, it can modify and forge the packet data ), this requires the WinPcap packet filtering function (do not judge the Mac address of the packet source, which is very inefficient. For PSP games, the data volume is quite large, there will be a very serious problem of running efficiency), So Google (when querying, ensure the accuracy of keywords to improve your hit rate, developers must use Google ), I found P in a White Paper on SONY's official website. The SP network protocol is Sony Computer Entertainment Inc and the code is 88C8. createFilter ("ether proto 35016") to create a packet filter. At this point, the PSP game data acquisition is complete. Next, process the network. Because there is no server (or no server), the software is both a server and a client. You can choose to create a host or add a public IP address to another created server, firewall issues need to be considered for network processing here (most PCs are in the firewall, so you do not need to consider this issue if you directly use ADSL to access the Internet, the firewall penetration function is required (this function requires a third-party server for transit, although the firewall penetration is achieved, but it is not used up ). In addition, PSP games have a large amount of data and are frequently sent (around 15kb/S on average). I use all clients (including servers) data is sent to the server and then forwarded to other clients except the sender. Therefore, as the server side, bandwidth becomes a bottleneck, which is difficult to solve by technical means, although the P2P data transmission method can be used to reduce the workload, the data processing workload is quite large. Here we will talk about another data transmission method I have considered. Method 1:
Method 2:
From the figure above, we can see that the bandwidth pressure on the master server is significantly reduced. Theoretically, the first method requires 6 Mbps of bandwidth for the server to basically ensure the smoothness of the 4-person online, the second method is about 3 M bandwidth (each client ). However, the first method only requires 2 mbps bandwidth for non-server clients. To be continue ......