Subject: Re: [manet] A question concerning the DSR Opnet code

From: Jay J Lee <[email-masked]>
Date: Fri, 09 May 2003 21:04:19 -0400

In OPNET, "DATA" packets are usually generated by configuring either the 
typical (FTP, HTTP and etc.) or the custom application models. You could 
create a custom application which will generate a stream of UDP 
packets.  The obvious advantage of this method is that you do not have to 
modify the code.  Consult the OPNET product documentation for the detailed 
description of the custom application model.

If you still have to modify the code, look for the kernel procedures for 
handling packets which should look like "op_pk_...".  Basically you want to 
make multiple copies of the packet using "op_pk_copy()" before it is sent 
out through "op_pk_send()".

Good luck, - Jay

At 02:58 PM 5/9/2003 -0400, you wrote:
>Hi,
>
>     I'm modifying a DSR OPNET code that I downloaded from NIST (It's a
>Unix-based code, called nist_dsr_model.tar.pl). I have a question about
>how to generate a stream of DATA packets and send them from the source to
>destination. I'm not sure if this isn't the right venue for this
>OPNET-related question, but appreciate whatever advice and help you can
>give me.
>
>     I've noticed that in this DSR code, after a route is found,
>the source sends a single data packet to the destinatin on that route. In
>other words, it seems that each source-destination connection session only
>transmits one data packet.
>
>     What I'd like to do is to send a stream of data packets (say, 10 of
>them) from src to dest. To that end, I've been going over the code to see
>where the first DATA packet is created. Because I'm very new with OPNET, I
>have been unable to find it. So far, I'm narrowing my search down to the
>dsr_upper_layer_data_arrival function, in the dsr_routing_layer process,
>and the Enter executive of the Upper_Layer state in the same processs. I
>have a hunch these two places are where I'm most likely to find that
>generator of the data packets. But so far, I haven't pinpointed the exact
>lines yet.   My hope is that once I know how this single data packet is
>generated, I'll be able to modify it (maybe some sort of for loop to let
>it run 10 times?) to get a stream of DATA packets.
>
>     So could someone with OPNET programming experience give me some help
>on that? Maybe someone can tell me what "catchy words" or KPs in the
>OPNET code I should be looking for with regard to generating DATA packets?
>Thanks in advance.
>
>-Ed
>
>
>
>
>_______________________________________________
>manet mailing list
>[email-masked]
>https://www1.ietf.org/mailman/listinfo/manet

_______________________________________________
manet mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/manet

---

From: Jay J Lee <[email-masked]>
Date: Wed, 14 May 2003 11:54:04 -0400

Ed,

Please post your OPNET specific questions to the 
[email-masked] or [email-masked] where other 
OPNET experts can give you more insights.  I will also try to answer some 
of your questions in those mailing lists rather than going off in the MANET 
mailing list.

- Jay

At 12:44 AM 5/14/2003 -0400, you wrote:
>Hi Jay,
>
>      Thanks so much for your reply. I'm now providing below more details
>and hope you can help me create a stream of data packets.  And, because it
>seems the contributed DSR model that I'm using right now already uses
>its custom application that sends a data packet, I'm going to just go ahead
>and modify it instead of using the OPNET-provided TCP/HTTP application.
>
>      1) This model has the followig node model:
>
>
>       receiver_sink                      src (with the "I" icon)
>
>
>                        dsr_interface
>
>
>                        dsr_routing_layer
>
>
>                        wlan_mac_dsr_interface
>
>
>                        wlan_mac_dsr_Sep00
>
>
>     wireless_lan_receiver_0                   wireless_lan_transmitter_0 
>
>
>
>In the above model, I'm focusing on dsr_interface, dsr_routing_layer,
>and wlan_mac_dsr_interface, and am not touching wlan_mac_dsr_Sep00, which
>I believe deals with the MAC layer transmissions and is not what I'm
>concerned with.
>
>    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
>
>     2)With some degree of certainty, I've now narrowed down my search for
>the generator of upper-layer data packets to the following. It seems to me
>that the upper-layer data packet is recieved (not generated, but received)
>in a state called "tx" in dsr_interface, and it gets passed to a state
>called "Upper_Layer_Arrival" in dsr_routing_layer, where the upper-layer
>data packet gets encapsulated in a routing-layer data packet for
>transmissions later.
>
>    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
>
>     3)Specifically, the code in the Enter exec of  the
>         dsr_interface-->tx state is the following:
>
>     // Inside the tx state         (Call it State 3)
>
>     // extract the packet from the source stream
>     pk_ptr=op_pk_get(FROM_SRC_STRM);
>
>     if (TRANSMIT) { //TRANSMIT is a SV & a model attribute default at Yes
>         // compute randomly a destination dsr address
>         destination_dsr_address=(int)op_dist_outcome(address_dist);
>         // check that this destination is not "myself"
>         while (destination_dsr_address==my_dsr_address) {
>             destination_dsr_address=(int)op_dist_outcome(address_dist);
>         }
>         // create and install an ici to communicate the
>         //    dsr address of the packet destination to the dsr process model
>         iciptr = op_ici_create("Dsr_Dest_Ici");
>         op_ici_attr_set(iciptr,"Packet_Destination",destination_dsr_address);
>         op_ici_install(iciptr);
>
>         // send the packet to the DSR layer
>         printf("A packet to send to Node %d\n",destination_dsr_address);
>         op_pk_send (pk_ptr,TO_ROUTING_LAYER_STRM);
>
>         // and update statistics
>         op_stat_write(stat_packet_transmited,++packet_transmited);
>     }
>     else {  // if the node should not send any new packet
>         op_pk_destroy(pk_ptr)   // destroy packet
>     }
>
>    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
>
>     4)And the code in the Enter exec of
>         dsr_routing_layer-->Upper_Layer_Arrival state is the following:
>
>     // Inside the Upper_Layer_Arrival state    (call it State 4)
>     // extract the packet from the stream coming from the upper layer
>     pk_ptr = op_pk_get(FROM_UPPER_LAYER_STRM);
>
>     // extract the dsr address of the packet destination from the ici
>     //   associated strm interrupt
>     ici_dest_address = op_intrpt_ici();
>
>     op_ici_attr_get(ici_dest_address,"Packet_Destination",
>                                                &destination_dsr_address);
>
>     // call the transmit data function
>     dsr_upper_layer_data_arrival(pk_ptr, destination_dsr_address);
>     // Note: in the function definition, it's
>     // dsr_upper_layer_data_arrival(Packet* data_pk_ptr,
>     //                              int     destination_dsr_address);
>
>    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
>
>     5)I inserted many printf lines throughout the node model to try to
>trace how states transition from one to another. I am fairly certain to
>say that from State 3 to State 4, it undergoes the following transition:
>
>      State 3(i.e., the tx state) returns to the "idle" state of the
>dsr_interface process, which then goes to State 4 (the
>Upper_Layer_Arrival state) of the dsr_routing_layer process.
>
>So, as you see, the only state between 3 and 4 is the idle state of the
>dsr_interface process. (A side note here: I was kind of expecting a
>transition from the idle state of dsr_interface to the idle state of
>dsr_routing_layer before reaching the Upper_Layer_Arrival state (i.e.,
>State 4), but appearantly that's not the case. Is there any reason why
>this is not so?)
>
>    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
>
>      6)In State 4, the function call dsr_upper_layer_data_arrival()
>has  some commands which are related to creating a routing-layer data packet,
>i.e., the following lines appear in that function:
>
>     // Create the data packet which is going to transport the upper layer
>     //   packet, and set its Type field
>     pk_ptr=op_pk_create_fmt("Dsr_Data");
>     op_pk_nfd_set(pk_ptr,"Type",DATA_PACKET_TYPE);
>
>     // insert the upper layer data in the dsr data packet
>     op_pk_nfd_set(pk_ptr, "data", data_pk_ptr);
>     ...
>     ...
>
>where data_pk_ptr is the first argument in the function definition of
>dsr_upper_layer_data_arrival().
>
>    *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
>
>      7)So, State 3 above is as far back as I can trace to where the
>upper-layer data packet comes from. Again, State 3, with its use of
>"pk_ptr=op_pk_get(FROM_SRC_STRM)", tells me this upper-layer data packet
>comes from somewhere still "further up". And this is where I got lost: I
>don't know where this "further-up" place is.
>
>      So I'm wondering, if it's not too much to ask, if you could help me
>find the true source of where the true point of origin of the data packet
>might be located. And, what I'd like to achieve is to generate a stream of
>such data packets (say 10) to be transmitted to the same destination in my
>simulations.  If you could give me some directions on how to do that, I'll
>be very grateful. I've been trying to do it with a number of things
>myself, with your suggestions. For example, one thing I did was that at
>the end of the State 3 code, following the last statement in the "if"
>clause, (i.e., op_stat_write(stat_packet_transmited,++packet_transmited) ),
>I tried to add the following lines:
>
>         cp_pk_ptr=op_pk_copy(pk_ptr);  // a copy of the current data packet
>         op_pk_send(cp_pk_ptr,TO_ROUTING_LAYER_STRM+1);
>         op_stat_write(stat_packet_transmited,++packet_transmited);
>
>just to see if I can somehow generate a second data packet. Of course, it
>failed when running the simulation, and the following error occurs:
>
><<< Program Abort >>>
>   * Time:      00:18:55 Wed May 14 2003
>   * Product:   modeler
>   * Package:   process (dsr_interface) at module (top.Office
>Network.mobile_node_11.dsr_intf)
>   * Function:  sim_err_print (severity_level, str0, str1)
>   * Error:     Packet pointer references unowned packet (0)
>                T (0.114926), EV (193), MOD
>                     (top.Office Network.mobile_node_11.dsr_intf),
>                      KP (op_pk_copy)
>
>
>Which indicates the op_pk_copy is wrongfully used.
>
>       So Jay, you are my savior if you can help me with my problem in
>OPNET coding here. I don't yet have a good understanding of how the logic
>behind state transitioning works yet, which I believe may be the key to
>solve this issue (am I correct?). Your and expertise and guidance is very
>much needed and appreciated.
>
>       Thanks again, and hope to hear from you soon. I apologize for
>dumping all this on you.
>
>Best,
>
>Ed
>
>-------------------------------------------------------------------------
>
>On Fri, 9 May 2003, Jay J Lee wrote:
>