Summary of solutions for OPNET errors


When using the OPNET Modeler software, you will encounter many strange errors. This article collects some errors that you encounter when using the software.


Packet pointer references unowned packet(<pk_id>) 错误

The screenshot of why this error caused the program to interrupt is shown in the figure below.
Insert image description here
As can be seen from the above figure, the OPNET core function that causes the error is op_pk_send(), which is the function that sends packets.
Open the product documentation of the OPNET Modeler software by clicking Help -> Product Decumentation in any editing window. If it cannot be opened, please refer to the article: Modify the default opening browser of the OPNET Help document & configure the IE Tab plug-in for the Edge browser .
After opening the product documentation, find the op_pk_send() function under Programmers Reference——>Discrete Event Simulation——>Packet Package. Its description is shown in the figure below.
Insert image description here
The op_pk_send() function forwards the specified data packet through the output packet stream, arranges the data packet to arrive at the destination module within the current simulation time, and releases the ownership of the data packet through the calling process. This function carries two parameters, the first parameter is a pointer of Packet* type, and the second parameter is the output packet stream, which is shaped.
Errors that may be encountered when using this core function are also listed below the function, as shown in the figure below.
Insert image description here
One of them is Packet pointer references unowned packet(<pk_id>). which will be introduced in this article.
So how to solve this error? Let’s first take a look at why I reported the error. The error code part is as follows.

for(i=0;i<10;i++)
{
    
    
	op_pk_send(ptr,i);
}

I wrote this code to send a packet on several packet streams. However, each packet has its own ID. Although multiple packet pointers can point to this packet at the same time, once the packet is sent , it cannot be sent again . For packages that are no longer owned, send and destroy operations cannot be performed, but access and remove operations can still be performed.
Therefore, the solution to the error is: either send the package once, or create a new package before each sending, and then send the package .
The following code creates a format packet before each sending, and then sends the packet, so that no error will be reported.

for(i=0;i<10;i++)
{
    
    
	ptr = op_pk_create_fmt("aaa");
	op_pk_send(ptr,i);
}

Standard function stack imbalance error

The screenshot of why this error caused the program to interrupt is shown in the figure below.
Insert image description here
The reason for this error is very simple. Check your function block. Each function body has a FIN and a FOUT, or a FIN and a FRET. If the function does not return a value, there must be a FIN at the beginning of the function and a FOUT at the end of the function; if the function has a return value, there must be a FIN at the beginning of the function and at least one FRET in the function body (of course there can be multiple FRETs) , but only one is actually returned).


Invalid Memory Access error

The screenshot of why this error caused the program to interrupt is shown in the figure below.
Insert image description here
There are many reasons for this error. It is usually caused by the irrational use of pointers. Carefully check whether the pointers in your program have out-of-bounds access and other problems. When it is difficult to solve, you should use ODB debugging to slowly find the cause of the error. For debugging, please refer to the article: Introduction to OPNET Modeler Debugging .


The above is a summary of solutions to OPNET errors. It will be updated later. I hope the ideas provided in this article can help you!

Guess you like

Origin blog.csdn.net/weixin_42570192/article/details/131173376