6
Introduction to Industrial Ethernet, Part 2. Part 1 was featured in Issue 3, Fall 1999. If you would like a copy, please send your request to [email protected] INTRODUCTION The push to incorporate Industrial Ethernet or even “plain vanilla” Ethernet into control networks implies that by making that choice completes the selection process. As mentioned in a previous article, Ethernet II and IEEE 802.3 are strictly data link layer technologies which do not guarantee the deliv- ery of messages over a network or between networks. Protocol stacks such as TCP/IP or SPX/IPX provide that functionality and without them Ethernet would be useless. With the immense interest in the Internet and the potential of at- taching control networks to the Internet, the protocol stack of choice is TCP/IP because it pro- vides the foundation for the Internet. This article addresses issues related to the IP portion of the TCP/IP stack as it applies to control networks. THE TCP/IP STACK Actually TCP/IP is a set of proto- cols defined by a series of RFCs (request for comments) that have evolved over the years. In general the Internet Protocol (IP) is used to route messages between net- works and, therefore, properly resides at the network layer of the OSI Reference Model. Transmission Control Protocol (TCP) sits on top of IP and is used to guarantee the delivery of mes- sages. Above TCP is the applica- tion layer. The services of the presentation and session layers of the OSI Reference Model are in- corporated into the application layer. Therefore, the reference model for TCP/IP-based systems actually consists of only five layers. Technologies such as Ethernet II and IEEE 802.3 reside at the lower data link and physical layers of the same model. DATA ENCAPSULATION The data sent over wires is repre- sented as frames. An Ethernet II frame consists of a preamble, source and destination addresses, type field, data field and a frame sequence check field. You can lump these fields into Ethernet header, data and trailer fields The IP data sits above the data link layer and its data, called a data- gram, is inserted into the data field of the Ethernet frame. The data- gram has it own header and data fields but no trailer field. Above the IP layer is the transport layer where TCP and User Datagram Protocol (UDP) reside. Data from this layer is likewise applied to the data portion of the IP datagram. TCP applies segments while UDP applies datagrams. Both TCP and UDP have headers as well. Finally above the transport layer is the application layer which needs to INTRODUCTION TO THE INTERNET PROTOCOL How does IP impact control networks? By George Thomas, Contemporary Controls Volume 1 • Issue 4 Winter 1999 the EXTENSION A Technical Supplement to control NETWORK 1 Application Presentation Session Transport Network Data Link Physical Ethernet ARCNET ARP IGMP ICMP OSPF RIP Internet Protocol Token Ring FDDI RTP RTCP Transmission Control Protocol User Diagram Protocol TELNET FTP SMTP DNS SNMP DHCP Figure 1. The TCP/IP stack is actually a set of protocols. IP resides at the network layer of the OSI Reference Model shown on the left.

Introd to Internet Protocol

Embed Size (px)

DESCRIPTION

Introd to Internet Protocol

Citation preview

  • Introduction to Industrial Ethernet, Part 2.

    Part 1 was featured in Issue 3, Fall 1999. If you would like a copy,please send your request [email protected]

    INTRODUCTIONThe push to incorporate IndustrialEthernet or even plain vanillaEthernet into control networksimplies that by making that choicecompletes the selection process. Asmentioned in a previous article,Ethernet II and IEEE 802.3 arestrictly data link layer technologieswhich do not guarantee the deliv-ery of messages over a network orbetween networks. Protocol stackssuch as TCP/IP or SPX/IPX providethat functionality and without themEthernet would be useless. Withthe immense interest in theInternet and the potential of at-taching control networks to theInternet, the protocol stack ofchoice is TCP/IP because it pro-vides the foundation for theInternet. This article addressesissues related to the IP portion ofthe TCP/IP stack as it applies tocontrol networks.

    THE TCP/IP STACKActually TCP/IP is a set of proto-cols defined by a series of RFCs(request for comments) that haveevolved over the years. In generalthe Internet Protocol (IP) is usedto route messages between net-works and, therefore, properlyresides at the network layer of the OSI Reference Model.Transmission Control Protocol(TCP) sits on top of IP and is used

    to guarantee the delivery of mes-sages. Above TCP is the applica-tion layer. The services of thepresentation and session layers ofthe OSI Reference Model are in-corporated into the applicationlayer. Therefore, the referencemodel for TCP/IP-based systemsactually consists of only fivelayers. Technologies such asEthernet II and IEEE 802.3 resideat the lower data link and physicallayers of the same model.

    DATA ENCAPSULATIONThe data sent over wires is repre-sented as frames. An Ethernet IIframe consists of a preamble,source and destination addresses,type field, data field and a framesequence check field. You can

    lump these fields into Ethernetheader, data and trailer fields TheIP data sits above the data linklayer and its data, called a data-gram, is inserted into the data fieldof the Ethernet frame. The data-gram has it own header and datafields but no trailer field. Abovethe IP layer is the transport layerwhere TCP and User DatagramProtocol (UDP) reside. Data fromthis layer is likewise applied to thedata portion of the IP datagram.TCP applies segments while UDPapplies datagrams. Both TCP andUDP have headers as well. Finallyabove the transport layer is the application layer which needs to

    INTRODUCTION TO THE INTERNET PROTOCOLHow does IP impact control networks?By George Thomas,Contemporary Controls

    Volume 1 Issue 4Winter 1999

    theEXTENSIONA Technical Supplement to con t ro l NETWORK

    1

    ApplicationPresentation

    Session

    Transport

    Network

    Data LinkPhysical Ethernet ARCNET

    ARP

    IGMP ICMP

    OSPF

    RIP

    Internet Protocol

    Token Ring FDDI

    RTPRTCP

    TransmissionControl Protocol

    User Diagram Protocol

    TELNET FTP SMTP DNS SNMP DHCP

    Figure 1. The TCP/IP stack is actually aset of protocols. IP resides at thenetwork layer of the OSI ReferenceModel shown on the left.

  • Figure 2. The wrapping of data into thedata field of the next immediate lowerlayer is called encapsulation.

    insert its own data into the dataportion of the transport layer aswell as its own header.

    This application data is simply re-ferred to as data since there is nodefined structure in terms of theTCP/IP stack. That is why if twoapplication data structures are dif-ferent, communication betweenthese applications will not be ef-fective even with strict adherenceto TCP/IP standards.

    This wrapping of data within thedata field of the next immediatelower layer of the protocol stack iscalled encapsulation while the un-wrapping of the same data at thereceiving side is called demulti-plexing. In order to reduce confu-sion on what is the actual data wewill say that frames are sent overthe data link layer. The IP sendsout datagrams to the data linklayer in the form of packets. Apacket can be a datagram or afragment of a datagram. The TCPsends segments while the UDP

    sends datagrams. Finally, the appli-cation sends data. To further addto the confusion, the terms packetand frame are sometimes used in-terchangeably.

    THE INTERNET PROTOCOLThe Internet Protocol provides thebasic unit of data transfer, providesaddressing, routing and fragmenta-tion. The Internet Protocol residesat the network layer and sends andreceives blocks of data called data-grams received from upper layersoftware. IP feeds these datagramsto its attached data link layerwhich sends and receives thesedatagrams as a series of packets. A datagram is analogous to a first-class letter sent in the Post. Ingeneral, it will reach its destinationbut there is no formal acknowl-edgement that the letter was re-ceived like there would be witheither registered or certified mail.IP utilizes a best effort or con-nectionless delivery servicebetween source and destinationaddresses. It is connectionlessbecause there was no formalsession established between thesource and destination before thedata was sent. Packets can be lostas they traverse the network or net-

    works thereby corrupting data-grams. It is not the responsibility ofIP to guarantee the delivery of mes-sages and, therefore, IP is frequent-ly termed an unreliable deliveryservice. That may be a little harshof a criticism of IP but it is the re-sponsibility of the transport layerand not the network layer to guar-antee end-to-end message delivery.IP is simply responsible for the ad-dressing and routing of datagrams.

    ROUTERS AND HOSTSUnlike repeaters that operate at thephysical layer and bridges thatoperate at the data link layer,routers operate at the networklayer. A router is used to intercon-nect two networks together toform an internet. An internet is ageneral term used to denote a col-lection of networks. It is not to beconfused with the Internet whichis the public network that requiresstrict addressing standards in orderfor different systems to communi-cate. With a control network, wemay want to keep it completelyprivate and not connect it to theInternet or the corporate internet(sometimes called an Intranet) butif we do we will need a router.This is being mentioned herebecause IP is a routable protocoland routers are used to implementthe protocol.

    The end-to-end devices on the in-ternet are called hosts. If two hostsare on the same local network, thenmessages are routed directly involv-ing no routers. If the two hosts areon different networks, a router mustpass the message. This is called in-direct routing.

    IP ADDRESSINGThe IP is responsible for sourceand destination addresses and itsstructure is defined in RFC 761.IPv4 is the most common versionof addressing and it uses 32-bit ad-

    2

    USER DATA

    USER DATA

    APPLICATION DATA

    APPLICATION DATA

    APPLICATION DATA

    APPLICATION

    ETHERNETDRIVER

    ETHERNET

    TCP

    IP

    APPLHEADER

    TCPHEADER

    TCPHEADER

    TCPHEADER

    IPHEADER

    IPHEADER

    ETHERNETHEADER

    ETHERNETTRAILER

    ETHERNET FRAME

    46 TO 1500 BYTES

    TCP SEGMENT

    IP DATAGRAM

  • dressing. The newer IPv6 calls for128-bit addressing and was devel-oped because the explosive growthof the Internet will soon depletethe inventory of possible 32-bit ad-dresses. IPv6 will not be discussedhere since there is ample confu-sion in simply discussing 32-bit IPaddressing.

    An IP address must not onlyaddress a particular host but a par-ticular network as well. The IPaddress must not be confused withthe Ethernet II address which is a48-bit address sometimes calledthe MAC address. The MACaddress is used to facilitate com-munication only at the data linklayer. The IP address facilitatescommunication over networks andmust be universally recognized,even if the host is an Ethernet IInode attached to a local areanetwork or a serial port attachedto a modem.

    Figure 3. Address classes define the splitbetween network and host IDs.

    The format of the address is but is shown asone 32-bit address split up as fourbytes. However, each byte is

    shown as a decimal number from0 to 255. Therefore, an IP addressis usually represented asXXX.XXX.XXX.XXX. This addresscan be shown as a binary or hexa-decimal number as well but thedecimal-dot-decimal notation is themost popular. Therefore, the rangeof addresses is from 0.0.0.0 to255.255.255.255. An example of anaddress would be 128.8.120.5 butlooking at the address it is hard totell which is the network addressand which is the host address.

    There are five classes of IP ad-dresses: A, B, C, D, E. Class D isfor multicasting, a message fromone host to many hosts, and classE is reserved for experiments. Thatleaves classes A, B and C whichare the most important. Thesethree classes break up the 32-bitaddress field into defined addressranges for the netid and hostid.You need to examine the very firstbyte of the IP address to deter-

    mine the class. If the first bit ofthis byte is a 0 then this is a classA address. In a class A address thefirst byte identifies the networkand the remaining three bytesidentifies the host. That means youcan have 16,277,214 hosts forevery network!

    If the first two bits of the first byteare a 10, then this is a class Baddress. With class B addressesthe first two bytes identify thenetwork and the remaining twobytes identify the host. This pro-vides a slightly more reasonable65,534 host addresses.

    If the first three bits of the firstbyte are a 110, then this is aclass C address. With class C ad-dresses the first three bytes identi-fy the network and the remainingbyte identifies the host. This pro-vides a reasonable 254 hosts.

    Class D and class E addresses canbe identified in the same way. Aclass D address has a leading bitpattern of 1110 while a class Eaddress has a leading bit patternof 11110.

    There are also other reserved ad-dresses. Regardless of class, a hostaddress of all 1s is reserved for abroadcast message to all hosts onthat network while a host addressof all 0s is reserved to mean thisnetwork. Network address 127 isalso reserved and is used for loop-back testing. This effectivelywastes 16 million possible hostaddresses. Network address 0 isreserved as well.

    If the control network is tobecome part of the public Internetthen strict adherence to the classaddressing rules must be followed.Usually these addresses will beissued by the corporate networkadministrator or by an InternetService Provider (ISP). But what ifthe control network is to becomestrictly a private network? Cannotany addressing scheme work? Yes,any address scheme could workbut there is even an RFC guidelinefor this situation. According to RFC 1918, only non-routable IP addresses should be used. These

    3

    Class A

    AddressIdentifier Network Address

    Class B

    Class C

    Class D

    Class E

    Host Address

    7 bits of network address 24 bits of host address

    14 bits of network address 16 bits of host address

    21 bits of network address 8 bits of host address

    Multicast address in the range of 224.0.0.0 - 239.255.255.255

    Class E - Reserved for future use

    0

    10

    110

    1110

    11110

    First byte Last three bytes

    First two bytes Last two bytes

    First three bytes Last byte

  • addresses, which a router will notpass, are as follows:

    10.0.0.0 to 10.255.255.255

    172.16.0.0 to 172.31.255.255

    192.168.0.0 to 192.168.255.255

    Class A : 1-127Class B : 128-191Class C : 192-223Class D : 224-239Class E : 240-254

    Figure 4. The class of an IP address canbe quickly identified by observing onlythe first byte.

    IP HEADERIP transmits and receives data-grams. Within the datagram is aheader and the data portion of thedatagram. The minimum size ofthe IP header is 20 bytes consist-ing of five 32-bit words. The firstthree words provide control infor-mation while the remaining twowords provide address informa-tion. An optional field can followthe address information. The infor-mation in the header is as follows:

    Version: A four-bit field identifiesthe IP version. A 4 identifies IPv4while a 6 identifies IPv6.

    Header Length: A four-bit field in-dicates how many four-byte wordsare in the header. The headerlength cannot exceed 60 bytesthereby allowing 40 bytes foroptions.

    Type of Service: Of the eight-bitfield only six bits are used. TheDelay bit indicates the datagramshould be processed with lowdelay by the router. TheThroughput bit requests highthroughput while the Reliability bitrequests high reliability. There are

    three other bits to indicate prece-dence. These bits are set at higherlayers of the protocol stack andare suggestions given the router.This looks like a nice feature forcontrol networks since control net-works require low delay and highreliability. However, it is not clearthat routers even look at thesebits. It appears that this was afeature with great promise butnever really implemented. This isto be rectified in IPv6.

    Total Length: The total length ofthe datagram including the headercannot exceed 65,535 bytes. This16-bit field is for the datagramitself and not the packet length inthe data link layer. If this datagramis larger than the maximum packetlength that can be sent, the data-gram will need to be fragmentedinto manageable successivepackets. In this case the totallength field will represent thelength of the fragment sent and notthe length of the original datagram.

    Datagram Identification: Aunique 16-bit identifier assigned bythe host will accompany the data-gram. This is necessary in order forthe receiving host to reassemblefragmented datagrams. All frag-

    ments will contain the same data-gram identifier.

    Flags: Three bits are reserved forflags but only two are used. TheDont Fragment bit tells the routernot to fragment the datagram. If thiscannot be done an error message isreturned. The More Fragments bit isused in the fragmentation process.A 1 means that the datagram beingsent is actually a fragment of alarger datagram. A 0 means thateither the datagram is not fragment-ed (first and only datagram) or itsthe last fragment. Receiving hostsneed this information in order to reassemble fragments.

    Fragment Offset: Thirteen bits areused to indicate which fragment isbeing sent. Fragmentation is theprocess of breaking up large data-grams into manageable packets.Ideally you would like to restrictdatagram size to packet size inorder to avoid fragmentation. WithEthernet II the maximum packetsize is 1500 bytes. This is called itsMaximum Transmission Unit (MTU)and within a private or localnetwork the MTU is known andcan be adhered to. The problemoccurs between networks.Intermediate networks may have alesser MTU requiring the router to

    4

    DA CRCSA

    IP Options (may be null) Padding

    Type0800 IP Header and Data

    Ethernet Data Field

    Source IP address

    Vers Hlen Service Type Total Length

    Identification

    Time to Live Protocol Header Checksum

    Flags Fragment Offset

    IP Datagram Data (up to 65535 bytes)

    Destination IP address

    Figure 5. The IP datagram consisting of aheader and data is inserted into theEthernet data field.

  • fragment the original message eventhough it was originally sent un-fragmented. The router does thefragmentation on his own (as longas the datagram was not marked asdo not fragment) and the frag-ments must be recombined at thedestination host. Routers do not re-combine fragments.

    The default MTU is 576 bytes andall routers must be able to handlethat size transmission. By restrict-ing the datagram to 576 bytes, itwill never need to be fragmented.Of course that puts an undue re-striction on the Ethernet IInetwork since packets can be aslong as 1500 bytes. So for localnetworks set the maximum data-gram size to the local networks

    MTU. If the datagram is to be sentbeyond the local network set themaximum datagram size to 576bytes. For control networks, frag-mentation may never be an issuesince control information packetsare usually short not exceeding256 or 512 bytes. Fragmentationshould be avoided since it increas-es data latency and increases thechances of a corrupted datagramsince multiple packets must besent per datagram.

    If fragments are to be sent it isnecessary to load in the fragmentoffset. Notice that with every frag-ment the IP header is resent withjust a slight modification. The frag-ment offset will change on everyfragment and possibly along withone flag bit. Fragments must besent in eight-byte multiplesbecause there are only13 bits avail-able for identifying fragments anddatagrams can be 64KB in length.For example, if the first fragment is1024 bytes long, the fragmentoffset of the next fragment will in-dicate that the accompanying frag-ment begins the 1025th byte of theoriginal datagram. With knowledgeof the datagram identifier, fragmentoffset, the source IP address andthe fragments themselves, the com-plete datagram can be reassembledby the receiving host even if thefragments are received out oforder. That is the true strength ofthe IP. Packets can take differentroutes to the intended destinationand still be reassembled into theoriginal datagram.

    Time to Live: This eight-byte fieldis strictly used by the routers toprevent a datagram from a faultytransmission sequence to endlesslycirculate around an internet.Originally the unit of measure wasseconds because it was believedthat it would take a router one ormore seconds to process a data-gram from its queue. Once the

    datagram was processed, the routerwould decrement this field by theamount of time that occurred.However, in practice modernrouters are much faster then earlyrouters and usually process thedatagram within a second but onlydecrement the field by one (theminimum amount). Therefore, thefield has come to be treated as ahop counter. A hop being an in-stance of a datagram beingprocessed by a router. The originat-ing host sets the Time to Live fieldand each router decreases it byone. If a router decrements thecount to zero it will discard thedatagram and inform the originat-ing host that the datagram failed toreach its destination.

    Protocol: The eight-bit protocolfield informs the upper layer proto-col that the received datagram isfor its use. Usually the upper layerprotocol is TCP or UDP but thereare other protocols as well thatcould be sending and receivingdata. The protocol field providesthis distinction.

    Header Checksum: The completeIP header is checked for integritywith the aid of the 16-bit headerchecksum. The originating hostapplies the checksum and allrouters check the header for in-tegrity and regenerate a newchecksum when the datagram isresent. A new checksum is re-quired since the Time to Live fieldwould have been changed by therouter. Finally, the checksum isagain reconfirmed by the receiv-ing host.

    Source/Destination Address: The32-bit source and destination ad-dresses are included in the header.These are the IP addresses and notMAC addresses.

    5

    What Defines TCP/IP?

    The TCP/IP stack and its associatedprotocols are described in Request forComments (RFCs). There are about 2700RFCs in existence and unlike manyindustrial control standards these arefree! You can simply download themfrom the Internet. One possible location ishttp://www.ietf.org. Which RFCs do youneed? Matthew Naugle, in his bookIllustrated TCP/IP, suggests as mandatoryreading RFCs 1122, 1123 and 1812.These will give a good overview but youcan always seek out others once you findan index. You can also author your ownRFC by following the instructions andformat in RFC 1543. Most of the RFCsoriginate from the working groups (WGs)of the Internet Engineering Task Force(IETF). Some RFCs obsolete prior RFCs. Ifyour control strategy is based upon theTCP/IP protocol, it is recommended thatyou document which RFCs are importantto your system. These documents mightbe the only documents available thatdefine your system's compliance.

  • IP Options: There may be nooptions in which case this field isnull or there can be optionsusually intended for router useonly. The option fields must be atleast 32-bits in length and must bepadded to that amount if shorter.

    ARPAs mentioned before, the IP routesdatagrams between source anddestination addresses in the formof packets over a data link layer.The data link does not understanddatagrams nor does it understandIP addresses. It does know,however, its own MAC addressand knows how to communicateto other MAC addresses when toldto do so. Somehow we need toinform each host what IP addressits MAC address or physicaladdress has been assigned and weneed to inform the same host allthe other physical address assign-ments on the local network inorder to have communication.

    Usually the host IP address-physi-cal address assignment is stored innon-volatile memory or in a file.Using a 32-bit DIP switch for as-signment is not practical.Sometimes a serial port on thedevice is used for programmingthe IP address but once pro-grammed all other hosts on thelocal network must still need tolearn the assignment.

    The Address Resolution Protocol(ARP) is used for learning physicaladdress assignments. ARP has itsown structure and does not usethat of IP. ARP directly communi-cates to the data link layer and,therefore, must be aware of thevarious types of network adaptersthat are available.

    When a host needs to send a data-gram to another host on a localnetwork, it first checks its ARPtable to determine the physicaladdress for that IP destinationaddress. If one is found, the data-gram transmission proceeds. Ifnone is found, an ARP request ismade. An ARP request consists ofa broadcast message to all hosts onthe local network. Within the ARPrequest is the originators IP andphysical addresses as well as therequested IP address. Since it is abroadcast message, all hosts havethe opportunity to learn the IPaddress and physical addresspairing of the requestor which canbe appended to that hosts ARPtable. Only the host with the re-quested IP address responds to the ARP request by providing its IP address and physical addresspairing. This message is sent as aunicast message back to the re-questor. Once the physical addressis known by the requestor, thedatagram can be sent.

    SUMMARYThe IP is responsible for the end-to-end delivery of datagrams overan internet. It also provides hostand network addressing and themeans for fragmenting datagramsinto manageable packets. IP is aroutable protocol and much of its

    complexity is due to its ability toroute packets directly within alocal network or indirectlythrough routers. Routers are notideal for a control network sincethey reduce determinism and in-crease data latency. Still to acceptTCP as a transport layer for anEthernet control network requiresacceptance of IP as well. By un-derstanding the limitations of IP, acontrol network can still be de-signed using the TCP/IP family ofprotocols. This is especially true ifthe control network is restricted tothat of a private or local network.

    REFERENCESIllustrated TCP/IP, Matthew Naugle, 1998, Wiley Computer Publishing

    Practical Networking With Ethernet, Charles E. Spurgeon, 1997, International Thomsom Computer Press

    International Standard ISO/IEC 8802-3 ANSI/IEEE std 802.3, 1996, The Institute of Electrical and Electronic Engineers, Inc.

    TCP/IP Clearly Explained, Pete Loshin, 1997, Academic Press

    TCP/IP Illustrated, Volume 1, The Protocols, W. Richard Stevens, 1994,Addison-Wesley Publishing Company

    6

    www.ccontrol.com