Navigation bar
  Start Previous page  20 of 35  Next page End Home  10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30  

Embedded Web Server for the CR16
National Semiconductor
Jeff Wright
20
2.
IPv4_T holds the IP header information.
typedef struct ipv4_t{
    
UBYTE       Ver_HL; 
// Version and Header length byte                    
    
UBYTE       ToS;              // Type Of Service                                 
    
UWORD       Length;           // Total datagram length                           
    
UWORD       Ident;         
// Fragment Identification field                     
    
UBYTE       FlgsOffst;        // Flags and MS offset bits                          
    
UBYTE       Offst;            // LS offset bits                                    
    
UBYTE       TTLive;           // Time-To-Live byte                                 
    
UBYTE       Protocol;         // Transport Protocol byte                           
   
UWORD       HdCkSum;          // One's compliment header checksum                
   
QUADB_T     SrcIP;            // Source IP address   
   
QUADB_T     DestIP;           // Destination IP address                         
} IPv4_T;
Figure 13.  IP’s Header structure
Two IPv4_T structures are created during initialization – one for transmit and one for receive.
Operation is straightforward: the flags IPSEND and IPRECV are monitored for input from TCP,
while also monitoring the flags DLRECV and DLSEND for the Link layer.  When a segment is readied
to send by TCP (IPSEND flag is set), IP will:
1.
Compute the total datagram length and record this number in the Length field…
2.
Compute the header checksum and record it in the HdCkSum field…
3.
Flag the Link layer by setting the DLSEND flag in DLAPI_T to send the datagram.
Upon receiving a datagram from the Link layer (DLRECV flag set), IP will:
1.
Confirm that the header checksum is correct.  If incorrect, the datagram is ignored…
2.
Compute the TCP segment length for use by the Transport layer (TCP or UDP), or ICMP 
3.
Copy the protocol number for multiplexing…
4.
Flag the appropriate layer (Transport or ICMP) that a datagram has been received.
NOTE: This IP does not currently support fragmentation.  
ICMP (Internet Control Message Protocol)
ICMP (Internet Control Message Protocol) is a required and integral part of IP, although it logically
sits above it.  ICMP messages are transmitted in IP datagrams just like TCP and UDP messages.  All
IP’s are required to implement certain minimum ICMP features.  This implementation supports the
following ICMP message types:
·
8
-
Echo Request (used by ping)
·
10
-
Router Solicitation
To facilitate future expansion, ICMP functions are conveniently tabulated as shown in Figure 15. 
Every host MUST implement an ICMP Echo server function that receives Echo Requests and sends
matching Echo Replies.  The IP source address in an ICMP Echo Reply MUST be the same as the
Microcontroller.com White Papers Previous page Top Next page