22.11.2014 Views

Understanding TCP/IP Model Internals and Interfaces

Understanding TCP/IP Model Internals and Interfaces

Understanding TCP/IP Model Internals and Interfaces

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

1508 <strong>Underst<strong>and</strong>ing</strong> <strong>TCP</strong>/<strong>IP</strong> <strong>Model</strong> <strong>Internals</strong> <strong>and</strong> <strong>Interfaces</strong><br />

Coding Changes<br />

Make the Necessary Coding Changes to H<strong>and</strong>le a Packet from <strong>IP</strong><br />

1. Open the function block (Code Blocks / Function Block or button) of the simple_mac<br />

process model.<br />

2. Scroll down to the simple_mac_packet_from_ip_h<strong>and</strong>le function (line 105).<br />

3. Edit the function as follows. (Lines to be added are in bold).<br />

FIN (simple_mac_packet_from_ip_h<strong>and</strong>le (ip_pkptr));<br />

/* Get the ici associated with the interrupt. The */<br />

/* destination address of the packet will be specified */<br />

/* in the ici. */<br />

arp_ici_ptr = op_intrpt_ici ();<br />

/* Get the destination address from the ici. */<br />

op_ici_attr_get_int32 (arp_ici_ptr, "dest_addr", &dest_addr);<br />

/* Print a trace Message */<br />

if (SMC_LTRACE_ACTIVE)<br />

{<br />

sprintf (msg, "Destination Address: %d", dest_addr);<br />

op_prg_odb_print_major ("Received a Packet from <strong>IP</strong>",<br />

msg, OPC_NIL);<br />

}<br />

/* Create the MAC Packet. */<br />

mac_pkptr = op_pk_create_fmt ("simple_mac");<br />

/* Set the source <strong>and</strong> dest addresses in the packet */<br />

op_pk_nfd_set_int32 (mac_pkptr, "source address", my_address);<br />

op_pk_nfd_set_int32 (mac_pkptr, "dest address", dest_addr);<br />

/* Encapsulate the <strong>IP</strong> Datagram in the MAC Packet */<br />

op_pk_nfd_set_pkt (mac_pkptr, "data", ip_pkptr);<br />

/* Send the packet out to the transmitter. */<br />

op_pk_send (mac_pkptr, SMC_OUT_STRM_INDEX_TO_XMT);<br />

FOUT;<br />

CONFIDENTIAL – RESTRICTED ACCESS: This information may not be disclosed, copied, or transmitted in any format without the prior written consent of OPNET Technologies, Inc.<br />

© 2010 OPNET Technologies, Inc.<br />

35

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!