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 />

Identifying an <strong>IP</strong> Packet<br />

When the simple_mac process model receives a stream interrupt, it needs to decide whether the<br />

packet is from the ARP layer or from the receiver. This is done based on the input stream index.<br />

Refer to the transition macros PACKET_FROM_<strong>IP</strong> <strong>and</strong> PACKET_FROM_NTWK defined in the Header<br />

block (Code Blocks / Header Block or button) of the process model. The relevant lines are<br />

reproduced below.<br />

/***** Transition Macros ******/<br />

#define PACKET_FROM_<strong>IP</strong> (in_strm == SMC_IN_STRM_INDEX_FROM_ARP)<br />

#define PACKET_FROM_NTWK (in_strm == SMC_IN_STRM_INDEX_FROM_RCV)<br />

/* Macro corresponding to stream indices */<br />

#define SMC_OUT_STRM_INDEX_TO_ARP 0<br />

#define SMC_OUT_STRM_INDEX_TO_XMT 1<br />

#define SMC_IN_STRM_INDEX_FROM_ARP 0<br />

#define SMC_IN_STRM_INDEX_FROM_RCV 1<br />

Note: The stream indices do not have to be hard-coded like this. Instead the MAC process can<br />

perform a graph walk at initialization <strong>and</strong> determine these values <strong>and</strong> store them as state variables.<br />

This approach was not used for this lab for the sake of simplicity.<br />

Determining the Destination MAC Address<br />

Every packet from the ARP layer will have an ICI of type ip_mac_req associated with the stream<br />

interrupt. The destination address of the packet will be specified in the dest_addr field of the ICI.<br />

Note:<br />

• Since the ARP module reuses the ICI, the MAC layer SHOULD NOT destroy the ICI after<br />

h<strong>and</strong>ling the packet.<br />

• For broadcast packets, the dest_addr field will be set to <strong>IP</strong>C_PHYS_ADDR_BROADCAST.<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 />

34

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

Saved successfully!

Ooh no, something went wrong!