UDP Software for Ethernet _Lite

Master’s Thesis Report (20p) UDP Software for Ethernet _Lite Muhammad Asif [email protected] Department of Computer Science and Electronics Mä...
3 downloads 0 Views 3MB Size
Master’s Thesis Report (20p)

UDP Software for Ethernet _Lite

Muhammad Asif [email protected] Department of Computer Science and Electronics Mälardalen University, Västerås Sweden August 2005-09-01

Supervisor: Lennart Lindh [email protected]

1

Abstract The invention of wheel was a major break throw of its scientific age. Like wise we can consider internet is the one of the most influential Scientifics break throw of current age, which was only possible because of advance ever growing communication technologies .Communication between any two sources protocols can be deemed as backbone of the whole setup. Currently several protocol exist and are employed in the cutting age of the communication set up. Different protocols are invented because of different scenario of communication. UDP protocol is actively used in today’s worlds of communication, in real time with data transfer which can tolerate little loss of data and accuracy. Because of ever increasing need and significance of communication system, investigated the UDP software for Ethernet Lite in the embedded system by evaluated of behaviour of some important protocols UDP, IP, ICMP and ARP. One most important thing which we have done is that programme memory small as we can .The memory is 10KB with the UDP/IP.

Keywords: UDP, IP, ICMP, HTTP, ARP, Ethernet_Lite and communication.

2

Acknowledgements I am immensely grateful to Mr. Lennart Lindh, supervisor, for his ability to grasp and simplify complex subjects, and his patience in explaining them to me which I admire a lot. He has helped me a lot in many possible ways. He is the most helpful and a man of his words, I have ever seen. Without this great people, I would not have completed mine project successfully and in time. I have learnt many things from him which I inspire a lot .Overall he was very friendly to mine.

I am also very much thankful to Mr. Björn Thor for his cooperation in many ways during the thesis work especially in the part of the implementation.

I would also like to thank mine friends that supported and encouraged mine work during this thesis.

I would also like to thank mine parent to whom I have dedicated this work for their support and encouragement throughout these years. I am at this stage just because of them.

3

Table of Contents 1

Introduction..............................................................................................8 1.1 1.2 1.3 1.4

2

Problem Statement ...................................................................................................... 8 Procedure.................................................................................................................. 8 Goal ............................................................................................................................ 9 Contents of Report...................................................................................................... 9

Background ............................................................................................10 2.1 OSI Model................................................................................................................ 11 2.2 Network Layer .......................................................................................................... 12 2.2.1 Transport Layer ................................................................................................ 12 2.2.2 Data Link Layer................................................................................................ 12 2.2.3 Physical Layer .................................................................................................. 12 2.2.4 Session Layer.................................................................................................... 13 2.2.5 Presentation Layer ............................................................................................ 13 2.2.6 Application Layer ............................................................................................. 14 2.3 Point-To-Point Protocol (PPP) ................................................................................. 14 2.4 Internet Protocol (IP) ................................................................................................ 16 2.4.1 IP address.......................................................................................................... 18 2.5 Address Resolution Protocol (ARP)......................................................................... 19 2.6 Reverse Address Resolution Protocol (RARP) ........................................................ 20 2.7 Internet Control Message Protocol (ICMP) ............................................................. 21 2.8 Internet Group Management Protocol (IGMP) ........................................................ 24 2.9 Transmission Control Protocol (TCP)...................................................................... 24 2.9.1 TCP Header ...................................................................................................... 25 2.10 User Datagram Protocol (UDP)................................................................................ 27 2.10.1 UDP protocol header ........................................................................................ 27 2.10.2 CHECKSUM .................................................................................................... 28 2.10.3 UDP_LITE ....................................................................................................... 29 2.11 The Lightweight User Datagram Protocol (UDP_Lite) Header ............................... 29 2.12 File Transfer Protocol (FTP) .................................................................................... 30 2.13 Trivial File Transfer Protocol (TFTP) ...................................................................... 30 2.14 Hypertext Transfer Protocol (HTTP) ....................................................................... 31 2.15 ETHERNET PROTOCOL ....................................................................................... 32

3

CASE UDP ............................................................................................34 3.1 Hardware .................................................................................................................. 34 3.2 The P160 Communications Module Board .............................................................. 35 3.3 CPU (MICRO BLAZE)............................................................................................ 36 3.4 Ethernet..................................................................................................................... 37 3.4.1 Advantages of Ethernet .................................................................................... 38 3.4.2 Limits of Ethernet ............................................................................................. 38 3.5 OPB Ethernet Lite Media Access Controller (v1.01b)............................................. 39 3.5.1 Ethernet Controller ........................................................................................... 39 3.5.2 Features of Ethernet Lite MAC ........................................................................ 40 3.5.3 Intellectual property interface (IPIF) ................................................................ 40 3.5.4 OPB IPIF Interrupt ........................................................................................... 42 3.5.5 OPB IPIF Packet FIFO..................................................................................... 44 4

3.5.6 OPB IPIF .......................................................................................................... 45 3.5.7 Ethernet Lite Intellectual property.................................................................... 45 3.6 UDP .......................................................................................................................... 45 3.6.1 THE SOFTWARE IMPLEMENTATION ....................................................... 48 3.6.2 DESIGN ........................................................................................................... 48 3.6.3 Checksum.C...................................................................................................... 48 3.6.4 LINK LAYER .................................................................................................. 49 3.6.5 Ethernet_Lite.C ................................................................................................ 52 3.6.6 Main2.C ............................................................................................................ 56 3.6.7 Slip.C ................................................................................................................ 57 3.6.8 IP.C................................................................................................................... 59 3.6.9 ICMP.C............................................................................................................. 63 3.6.10 UDP.C .............................................................................................................. 64 3.6.11 Limitations ........................................................................................................ 65 3.7 System Setup ............................................................................................................ 66 3.8 System demonstration .............................................................................................. 68 3.8.1 The Ethereal Network Packet Analyzer ........................................................... 83 3.9 Bjorn System ............................................................................................................ 84 3.9.1 Result Comparison ........................................................................................... 85

4 5 6 7 8

Summary................................................................................................86 Conclusion .............................................................................................87 References..............................................................................................88 Abbreviations/acronyms .........................................................................91 Appendix ...............................................................................................92 8.1 8.2 8.3 8.4 8.5 8.6 8.7 8.8 8.9 8.10 8.11

Udp_header.h............................................................................................................ 92 Assigned.h................................................................................................................ 92 Config.h.................................................................................................................... 94 ICMP.h ..................................................................................................................... 95 IP.h............................................................................................................................ 95 ARP.h ....................................................................................................................... 95 Ethernet_Lite.h......................................................................................................... 96 Link.h........................................................................................................................ 96 Slip.h......................................................................................................................... 97 UDP_state.h.............................................................................................................. 97 CheckSum.h.............................................................................................................. 97

5

List of Figures FIGURE 1: VARIOUS PROTOCOL AT DIFFERENT LAYERS [4]................................................................................................ 10 FIGURE 2: IP HEADER [4]........................................................................................................................................................ 17 FIGURE 3: IP ADDRESS CLASSES [4] ...................................................................................................................................... 19 FIGURE 4: FORMAT OF AN ARP REQUEST /REPLY [9].......................................................................................................... 20 FIGURE 5: ICMP MESSAGE ENCAPSULATED WITH IN IP DATAGRAM 20 BYTES [4]. ...................................................... 21 FIGURE 6: ICMP FORMAT [21] ............................................................................................................................................... 22 FIGURE 7: FORMAT FIELDS IN IGMP MESSAGE [4] ............................................................................................................ 24 FIGURE 8: TCP HEADER [4]. ................................................................................................................................................... 25 FIGURE 9: UDP HEADER [17]................................................................................................................................................. 28 FIGURE 10: UDP_LITE HEADER [25]. ................................................................................................................................... 30 FIGURE 11: ETHERNET DATA FORMAT [37]......................................................................................................................... 33 FIGURE 12: VIRTEX II2MB 1000 DEVELOPMENT KIT [36]................................................................................................. 34 FIGURE 13: THE P160 COMMUNICATIONS M ODULE BOARD [35] .................................................................................... 35 FIGURE 14: BROADCOM ETHERNET INTERFACE CIRCUIT ON VIRTEX II2MB1000 DEVELOPMENT KIT [32].............. 36 FIGURE 15: M ICROBALZE RISC 32 BIT PROCESSOR SYSTEM INTERCONNECTS [38]...................................................... 37 FIGURE 16: ETHERNET _ LITE [37] ......................................................................................................................................... 39 FIGURE 17: OPB DEVICE USING THE FULL SET OF IPIF FEATURES [42]. ......................................................................... 41 FIGURE 18: A N OPB DEVICE USING ONLY IPIF FEATURE REQUIRED FOR THE REGISTER ACCESS [42]. ...................... 42 FIGURE 19: INTERRUPT STRUCTURE IN THE ETHERNET -CONTROLLER DEVICE [42]. .................................................... 44 FIGURE 20: IP STACK............................................................................................................................................................... 46 FIGURE 21: BLOCK DIAGRAM OF UDP/IP CORE [23]. ......................................................................................................... 47 FIGURE 22: SYSTEM SETUP ..................................................................................................................................................... 67 FIGURE 23: CONNECTION BETWEEN THE MEMORY CONTROLLER AND DUAL PORT RAM.............................................. 67 FIGURE 24: CREATE NEW PROJECT ....................................................................................................................................... 68 FIGURE 25: SELECT BOARD.................................................................................................................................................... 69 FIGURE 26: SELECT PROCESSOR............................................................................................................................................. 70 FIGURE 27: CONFIGURE PROCESSOR AND SYSTEM SETTINGS. .......................................................................................... 71 FIGURE 28: SELECTING EXTERNAL M EMORIES AND IO DEVICES..................................................................................... 72 FIGURE 29: SELECTING IO DEVICES 1. .................................................................................................................................. 73 FIGURE 30: SELECTING IO DEVICES 2. .................................................................................................................................. 74 FIGURE 31: A DDING INTERNAL PERIPHERALS. .................................................................................................................... 75 FIGURE 32: CONFIGURE SOFTWARE SETTING. ..................................................................................................................... 76 FIGURE 33 : SYSTEM SUMMARY............................................................................................................................................ 77 FIGURE 34: BASE SYSTEM BUILDER-FINISHED................................................................................................................... 78 FIGURE 35: HARDWARE PERIPHERALS. ................................................................................................................................ 79 FIGURE 36: BUSS CONNECTION............................................................................................................................................. 80 FIGURE 37: A DD ADDRESS. .................................................................................................................................................... 81 FIGURE 38: PORTS.................................................................................................................................................................... 82 FIGURE 39: XILINX CONFIGURED .......................................................................................................................................... 82 FIGURE 40: CLIENT CONFIGURED .......................................................................................................................................... 83 FIGURE 41: RESULT BY ETHEREAL ........................................................................................................................................ 84

6

List of tables TABLE 1:DESCRIPTION OF OSI LAYER.................................................................................................................................. 12 TABLE 2: POINT -TO-POINT PROTOCOL FRAME FORMAT [7]. ............................................................................................. 15 TABLE 3: DELAY, RELIABILITY AND THROUGH PUT BITS................................................................................................... 18 TABLE 4: A RANGE OF POSSIBLE VALUE EXISTS FOR THE FIRST OCTET OF EACH ADDRESS [11].................................. 19 TABLE 5: ICMP MESSAGE TYPES [4]..................................................................................................................................... 23 TABLE 6: FLAGS IN THE TCP HEADER AND THEIR DESCRIPTION [4]. ............................................................................... 26 TABLE 7: TFTP PACKETS TYPE [4]. ....................................................................................................................................... 31 TABLE 8: OPB IPIF INTERRUPTS CONDITIONS [42]. ........................................................................................................... 43 TABLE 9: RESULT COMPARISON............................................................................................................................................. 85

7

1 Introduction Communications between two people, there is need of natural language. The language is the actually set of rules, which is obeyed by the persons who are talking with each other. Like this if two machines communicate with each other they must have set rules. Communication affects every aspect of our life. Communication is possible by using different method. The most popular use of communication is the internet. Communication by the internet makes our life successive and fast. “A protocol is the special set of rules that end points in a telecommunication connection use when they communicate”. The internet protocol was first time specified in 1980. The only problem with the IPv4 is its limited address space 32 bits. In the 1990 the glowing topics in the research centres is the limited space of IPv4. In the mid 1990s, IPv6 was specified [RFC 1883] IPv6 increases Address length to 128 bit. In these days lot of user using the IPv4 but lot of user using the IPv6 and they are satisfied with address space [1]. 1.1

Problem Statement

There are some deficiencies in previous software’s. Lacks are: • Usage lot of memory (Lot of memory usage can decrease it performance). • Very complicated (One can say that it is not configurable). • Open source UDP software doesn’t have Checksum Calculation. • Doesn’t support for both big and little endian. 1.2

Procedure

The board V2MB1000 is used which provide perfect solution of the FPGA and system design .It has the one million gates Virtex-II FPGA.The P160 Communication Module Broadcom is fixed at the P160 communication module on the virtex-IIV2MB1000 development kit. The FPGA has the CPU (Microbalze), RAM, Bus, serial controller and Ethernet net controller. The TCP/IP stack is also placed on the FPGA. The RAM is connected to the CPU by using the instruction and data bus. The CPU is connected to the bus. The serial controller and Ethernet controller is connected to the bus. The Serial controller is connected to the RS232 interface and the Ethernet controller is connected to the PHY interface. Different protocols are implemented at the different layer. AT the link layer ARP is used which can be used to translate IP address to Ethernet address. The network layer is consists of 8

the IP and ICMP. The IP protocol which is implemented is the 4 bit version and also length field .ICMP is used to test the package transmit at the IP level. The ICMP is implemented in the form of ping programme and only handled the echo request. At the transport layer the protocol which is used is UDP. UDP protocol is used to provide the UDP echo service. In this implementation, tries to make memory as small as possible. 1.3

Goal

Key goal of thesis is to build up UDP software for Ethernet light. Associate goal of thesis is calculate IP Checksum furthermore to make it very simp le for users. It also reduces memory usage. Software will support both big and little endian and make successive communication with P160 Communication module on the Virtex-IIV2MB1000 development kit. 1.4

Contents of Report

The 2nd chapter an introduction of the protocol used in internet. The all protocols are described which can be implemented in internet on embedded system. The 3rd chapter first part describes the hardware and the second part describes the software, system setup and work with the EDK 7.2. At the end of report, there is summary and conclusion of report.

9

2 Background Communication without language is impossible, language is the actually set of rules, which is obeyed by the persons who are talking with each other. Like that if two machines communicate with each other they must have set of rules. “A protocol is the special set of rules that end points in a telecommunication connection use when they communicate [2] ”. These rules contain the information that the data packet are formatted and delivered to the host. The protocols are used for the data interchange at the hardware device level and also at the application programme level. Hardware protocols define how the hardware devices operate and work together. Software protocol defines how the programme communicates with each other [3]. For the internet different protocols are used at the different layers ,each layer briefly explained their

functionality to make communication success, the below figure describes different

protocol which are using in different networks.

Figure 1: various protocol at different layers [7].

10

2.1 OSI Model A significant distinctiveness familiar to all network architecture is the use of layered approach by means of regard to the achievement of various functions essential for communication between two devices. The layered approach which is used in the network in theses days is defined by the International Organization for Standardization (ISO) also called Reference Model for Open Systems Interconnection or OSI Model.The Open Standards Interconnect (OSI) model is theoretical furthermore which is used to explain the network in addition networking problem. The OSI model does not describe the networking software or full principles for such software. The OSI model consists of seven layers. Layers Application (Network Process to application ) Presentation (Data representation & Encryption) Session (Interhost Communications ) Transport (End to End connections and Reliability) Network (Path determination & Logical Addressing(IP)) Data Link (Physical Addressing(MAC & LLC))

Data Unit Data

Protocol DNS; FTP; TFTP; BOOTP; SNMP; LOGIN; SMTP; MIME; NFS; FINGER; TELNET; NCP; APPC; AFP; SMB

Data

Segments

TCP, ARP, RARP; SPX,NWLink,NetBIOS / NetBEUI,ATP

Segments

TCP, ARP, RARP; SPX,NWLink,NetBIOS / NetBEUI,ATP

Packets

IP; ARP; RARP, ICMP; RIP; OSFP; IGMP; IPX:NWLink,NetBEUI,OSI,DDP,DECnet Logical Link Control

Frames

• •

error correction and flow control manages link control and defines SAPs

802.1 OSI Model, 802.2 Logical Link Control

Media Access Control • •

Physical (Media, Signal and Binary Transmission)

Bits

communicates with the adapter card controls the type of media being used:

802.3 CSMA/CD (Ethernet),802.4 Token Bus (ARCnet),802.5 Token Ring,802.12 Demand Priority IEEE 802, IEEE 802.2, ISO 2110,ISDN

11

Table 1:Description of OSI layer

2.2 Network Layer This layer provides switching, addressing, internetworking, error handling, packet sequencing, routing technologies and creating logical paths for transmitting data from one node to another node. The most important protocol on this layer is the Internet Protocol (IP).The IP used to deliver datagram’s from source to destination which is provided in the IP address. The current version of the internet protocol is the version 4, which is replaced by the version 6 .The key feature of the IP version 6 an expanded address space to allow more network devices. The Internet protocol used at this layer to acknowledge problems with delivery of IP datagram’s within an IP network.

2.2.1 Transport Layer This layer provides apparent move of data connecting source system and destination system. It is accountable for continuous recovery, flow control as well as ensures complete data transfer. It hide from upper layers all the information associated to the real moving of packets and frames from one machine to another .This layer can also be used to provide delivery of packets from one device to another moreover delivery of packets in the proper sequence. Protocols such as the Transmission Control Protocol (TCP) and the User Datagram Protocol (UDP) are use on this layer.

2.2.2 Data Link Layer This layer is responsible for providing data transmission over a single connection from one system to another. Control mechanisms in the data link layer handle the transmission and synchronization of data units, known as frames, over a physical circuit. Functions operating in this layer allow data to be transmitted in a relatively error- free fashion over sometimes errorprone physical circuit. The data link layer is divided into two sub-layers the Medium Access Control (MAC) layer and logical Link Control (LLC) layer. The MAC sub- layer controls how a computer on the network gains access to the data and permission to transmit it. The LLC sub layer controls frame synchronization, flow control and error checking.

2.2.3 Physical Layer This layer is in charge for the real communication of a stream of bits crossways a physical medium moreover defines all the electrical and physical specification for devices. This include the layout of pins, voltages and cable specification, hubs, network adapters are physical devices

12

The physical layers are used for the following function •

Establishment and killing of a connections medium.



Contribution in the procedure whereby the communication resources are effectively shared among multiple users. For example, connection resolution and flow control.



Modulation or conversion between the representation of a digital data in user equipment and the corresponding signals transmitted over a communication channel[4].

2.2.4 Session Layer The session layer is used to manages, establishes and terminates communication sessions between computers. Communication sessions consist of service request and services response that occur between applications located in different network devices. It offer for either duplex or half duplex operation and establishes check pointing, adjournment, termination, and restart procedures[5].

2.2.5 Presentation Layer The presentation Layer provides a standard representation for sending data A-cross the Network .Data encoding, data compression, data encryption is done at this layer to present the data as service. The Newt layer is the Presentation Layer that provides a standard representation for sending data across the network and hence frees the application layer from having to contend with compatibility problems related to data representation. The top-most layer of the OSI model is the Application Layer. It supports applications and end-user processes. This layer provides application services for file transfers, e- mail and other network software services [5]. Based on the OSI model of network architecture, there are two identifiers associated with any given device on a network. These identifiers are necessary for routers to forward packets to their proper destinations over the network. They are MAC Address also called Physical Address or Ethernet Address, this identifier is unique. The Presentation layer transforms data to provide a standard interface for the Application layer. MIME encoding, data compression, data encryption and similar manipulation of the presentation is done at this layer to present the data as a service or protocol developer sees fit.

13

Examples: converting an EBCDIC-coded text file to an ASCII-coded file, or serializing objects and other data structures into and out of XML[6]. 2.2.6

Application Layer

The higher layer of the OSI model is the application layer and closet to the end user. it is used by the users to act together with the application and networks. The application layer provides services for file transfer, e- mail and other network software services. The application layer protocol are File Transfer Protocol, Simple mail transfer protocol and Hypertext Transfer Protocol.

2.3 Serial line Internet Protocol (SLIP) Serial Line Internet Protocol (SLIP) is a generally up-to-date encapsulation of the Internet Protocol considered to work over serial ports and modem connections. SLIP defines a series of characters that frame IP packets on a serial line. It’s purely a packet framing protocol moreover provides no addressing, packet type identification, error detection/correction and compression mechanisms. Because of that problem the SLIP has been change by the Point-toPoint protocol. The Serial Line Internet protocol does so little, though, it is usually very easy to implement. On microcontrollers, SLIP is still ideal way of encapsulating IP packets due to its very simple overhead. It quickly fixed on as an easy reliable way to connect TCP/IP hosts and routers with serial lines. SLIP is generally use on dedicated serial links and sometimes for dialup purposes, and is usually used with line speeds between 1200bps and 19.2Kbps. It is useful for allowing mixes of hosts and routers to communicate with one another (host- host, host-router and router-router are all common SLIP network configurations).The SlLP protocol classify two special characters END and ESC. SLIP requires a port configuration of 8 data bits, no parity, and EIA or hardware flow control. The END is octal 300 (decimal 219 and ESC is octal 333(decimal 219) .To drive a packet, a SLIP host basically starts sending the data in the packet. If a data byte is the similar code as END character, a two byte sequence of ESC and octal 334 (decimal 220) is send as an alternative. If it is same as an ESC character and two byte sequence of ESC and octal 335 (decimal221) is send as an alternative. When the last byte in the packet has been sent, an END character is then transmitted [8]. 2.3

Point-To-Point Protocol (PPP)

14

Point-to-Point Protocol (PPP) present a standard scheme for transport multi-protocol datagram’s above point-to-point links. PPP is consists of three main components [9]: Ø A technique for encapsulating multi-protocol datagram’s. Ø A Link Control Protocol (LCP) for setting up, configuring, and testing the data- link connection. Ø Network Control Protocols (NCPs) family for establishing and constructing different network- layer protocols. The point to point protocol utilizes the Enhanced error detection, automatic self configuration and looped link detection.

Table 2: Point-to-Point Protocol frame format [10].

Each frame starts and trimmings through a Flag Sequence, which is the binary sequence 01111110.

All executions always make sure for this flag, which is applied for frame

synchronization. Only one Flag Sequence is essential between two frames. Two repeated Flag Sequences stand for an empty frame, which is mutely discarded, and not calculated as a FCS error. The Address field consists of 8 bits and holds the binary Sequence 11111111. In this protocol the Individual station addresses is not allocated. The All-Stations address MUST always be recognized and received. Latterly, user can define address lengths and values. A frame with unrecognized Addresses is mutely discarded. The Control field consists of 8 bits and contains the binary Sequence 00000011 (hexadecimal 0x03), the Unnumbered Information (UI) command with the Poll/Final (P/F) bit set to zero. Utilize of other Control field values may be defined at a later Time. Frames by way of unrecognized Control field principles should be mutely discarded.

15

The Frame Check Sequence field evades to 16 bits (two octets) or to 32 bit (four octets). The FCS is transmitting least noteworthy octet first, which contain the coefficient of the highest term. The FCS field is intended over all bits of the Address, Control, Protocol, Information and Padding fields, not including any start and stop bits (asynchronous) nor any bits (synchronous) or octets (Asynchronous or synchronous) interleaved for transparency and also does not include the Flag Sequences nor the FCS field itself [10]. 2.4

Internet Protocol (IP)

Internet protocol is the workhorse of the UDP. All the UDP, TCP; ICMP AND IGMP data gets transmitted as IP datagram’s. The IP provide the unreliable and connection less datagram’s delivery service. By unreliable mean that the data there is no guaranteeing that the data is reaching at the destination. If data not reaching at the destination port. This error is handled by the simple algorithms, which is that take away the datagram’s and try to send the ICMP message back to the source. Connectionless mean that the every datagram’s are send independently, if a same sender sends the two data grams consecutively at the same destination. These datagram’s most probably reached out of order [7].

16

Figure 2: IP header [7]

The all fields which are presented in the figure (4) are not needed to use in the IP header. The all fields are measured in the amount in 32 bit words. The big endian byte ordering is used for binary integers in the UDP/IP headers as they traverse a netwo rk. In this ordering the 32 bits are transmitted in order, the bits from the 0 to 7 can be transmitted first, then the bits 8-15 ,then the bits 16-23 and bits 24-31 last. If binary integers are stored in the other format, which is little endian format, in this format the header values into the network byte order before transmitting. The length of the IP header can vary. The all fields are varying except the IP data field [11] .The shortest IP header will 20 bytes long, it can be varying to 60 bytes if other options are included. The header length is 4 bit field. The header length is the number of 32 bit word in the header. The type of service is consisting of the 8 bit. The first 3 bit is the precedence field, 4 TOS bits and unused bit which are 0.The the sender application to indicate the IP layer the priority of sending the data gram. The precedence filed is combined with the D (delay), T (throughput), and R (reliability) bits. These bits indicate to a router which route to take.

17

Table 3: Delay, reliability and through put bits

The total length is the length of the IP data gram measured in bytes. The fragment IP datagram’s consist of identification, flags, fragment off set. Fragmentation is used to break the large datagram’s into smaller size to reassemble at the destination. The identification indicates which datagram fragment belong together. This field is used to avoid the mismatch of the datagram’s. The flags are used to indicate the more fragment are arrive or no more datagram’s are sent. The offset is used to indicates the offset from the previous datagram’s, also use used by the receiver to put back the fragmented datagram altoge ther. TTL (time to live) indicates the amount of time that a datagram allowed to stay on the network. TTL is used to limit the life time of TCP segment and to end routing loops. TTL is set to a certain time to ensure that a packet stay on the network for only a set time [11]. 2.4.1 IP address The IP addresses are 32-bit numbers; the 32-bit addresses are actually four decimal number, one for the each byte of the address (like 150.00.11.).The 32-bit number is divided into two parts which is the network number and host number. The network number identifies the host network and the host number identifies a host on the network. There are three types of the IP addresses, unicast which is used to send the data on the single host, broad cast which is used to send the data on all hosts on the network which is used to send the data on the sets of the host that belong to the multicast group.

18

Table 4: A range of possible value exists for the first octet of each address [14].

There are five classes of IP addresses and each class can be determined by examining the first octet of the address and mapping that value in the table (3) [14]. Class A 0 Class B

7 bits netid

1 0 Class C 1 1 Class D 1 1 Class E 1

1

24 bits hostid 14 bits netid

16 bits hostid

1

21 bits netid

8 bits hostid

0

28 bits Multicast group ID

1

1

1

0

27 bits (reserved for future use)

Figure 3 : IP address Classes [7]

2.5

Address Resolution Protocol (ARP)

A data link such as Ethernet has addressing scheme (often 48-bit addresses) to transmit the Ethernet packet. Ethernet must generate 48-bit address and the internet protocol should have the 32-bit IP addresses, the address resolution protocol is used to translate between the two types of addresses. These 32-bit IP address are compatible for the Ethernet address by using the ARP. “ARP provides a dynamic mapping between an IP address and corresponding hardware address [7]”.

19

The address resolution is used to find the host in the network. There are four types of ARP messages [16] (e.g.). Ø ARP request Ø ARP reply Ø RARP request Ø RARP reply ARP protocol is a three layer protocol, with out the IP header. The Ethernet type field has the value 0x0806 to indicate an ARP, which indicates that ARP is the request or reply.

Figure 4: For mat of an ARP request/reply [12]

The hardware and protocol type are used to specify the fields in the ARP packets. The hardware type field specifies the type of hardware address, which is “1” for the Ethernet. And the protocol field specifies the type of the protocol used at the network layer. Its value 0x0800 for IP addresses. The Length of hardware address and length of protocol address fields specified the in bytes. In an Ethernet the IP address has the 6 bytes for the ARP request and 4 bytes for the ARP reply. The this code indicates whether the packet is an ARP Request (1) or an ARP Response (2), RARP request (3), or RARP reply (4).The senders Ethernet address is the layer 3 address of the source node .The senders protocol address and target hardware address are used in the ARP request, the response carries both the destination’s hardware and layer 3 addresses [12] [7]. 2.6

Reverse Address Resolution Protocol (RARP)

The diskless work stations do not know about their protocol address when they are booted .They only know about their hardware interface address(their attached physical address).To get their IP address the diskless system used the RARP protocol. RARP protocol is used by the diskless system to obtain their IP address when they now only the attached physical address. RARP read the hardware address (their attached physical address) from the interface card and then generate the RARP request for the system on the network to reply with the diskless 20

system IP address. The RARP request is broad cast which is generated for the system on the network and reply is unicast which is only generated for the system that generate the RARP request. The diskless system uses the RARP reply which is received at first. When the entire servers on the network reply at the same time they will increase the chance of collision on the network. The RARP packet format is same as the ARP packet, the difference is the 0*8035 which is used for the RARP request or reply and the second is the op field uses the value 3 for an RARP request and 4 for an RARP reply. 2.7

Internet Control Message Protocol (ICMP)

When the host data grams do not reach at the destination its mean there is an error in the transmission, the destination send report about datagram lost to the host port by using Internet control message protocol (ICMP). Internet control protocol (ICMP) is the integral part of the internet protocol (IP).ICMP messages are acted by the internet protocol (IP) or the higher layer level protocol (TCP or UDP). ICMP messages are sent due to the following reasons, when the source sent the datagram’s and these datagram’s does not reached at the destination port. When the gate way is full and it does not have the capacity to forward a datagram. This problem is created when the sender send the data so much fast as compared to the transmission rate of gateway. When the sender sends the datagram’s on the long route and the gate way is waiting for the datagram’s from the sender. The internet control message protocol (ICMP) sent to the host to inform that the datagram’s send on the shorter route. Sometimes data grams also lost and destination does not generate internet control message protocol (ICMP) its mean that’s it does not make the internet protocol (IP) reliable.

Figure 5: ICMP message encapsulated with in IP datagram 20 bytes [7].

21

Sometimes data grams also lost and destination does not generate internet control message protocol (ICMP) its mean that’s it does not make the internet protocol (IP) reliable.

Figure 6: ICMP format [25]

22

The different ICMP messages types are written below Type

code

0

0

3

echo reply

Query

Error

*

14 15

destination unreachable network unreachable host unreachable protocol unreachable port unreachable fragmentation needed but do not fragment bit set source route failed destination network unknown destination host unknown source host isolated destination network administratively prohibited destination host administratively prohibited network unreachable for TOS host unreachable for TOS communication administratively prohibited by filtering host precedence violation precedence cut off in effect

0

source quench

*

redirect redirect for network redirect of host redirect for type-of-service and

* * *

redirect for type-of-service and host

*

0 1 2 3 4 5 6 7 8 9 10 11 12 13

4

description

5 0 1 2 network 3

* * * * * * * * * * * * * * * * *

8

0

echo request

*

9 10

0 0

router advertisement router solicitation

* *

0 0 1 0

time exceeded time -to-live equals during transit time -to-live equals during reassembly

* * * *

0 1

parameter problem IP header bad required option missing

* *

11

12

13 0 timestamp request

*

Table 5: ICMP message types [7].

23

2.8

Internet Group Management Protocol (IGMP)

In some cases multicasting is preferred upon the broadcasting, because of less overhead on the hosts and there is less chance of error in communication. For multicasting need the IGMP. The Internet Group Management (IGMP) is used by the IP hosts to report their multicast group memberships to any immediately neighbouring multicast routers. IGMP is the integral part of the IP. The IGMP is encapsulated into the IP datagram’s and the IGMP has fixed size message.

Figure 7:

Format fields in IGMP message [7]

There are two types of the IGMP message which are type 1 and type 2.The type of the IGMP 1, when the query sent by multicast router (Host Membership Query).the type of the IGMP is 2, when the response sent by a hosts (Host Membership Report).The checksum is the 16-bit one’s compliment of the one’s complement sum of the 8-octet IGMP message. It is calculated as same as explain in case of ICMP. The group address is the class D IP address. In a query the group address is set to zero when sent, ignored when received. In the report, the group address field holds the IP host group address of the group being reported [28] [15]. 2.9

Transmission Control Protocol (TCP)

In lot of communication, the first requirement is that the data was sent in sequence, without error, secure and also free of duplication. All these requirements can be achieved by using the TCP. The TCP is used send stream of data from source to destination. TCP decide when to send and blocked data at their on convince, that’s clear by its name .The TCP breaks the data stream into the small units. These units called as segments. These segments sent from source to destination, also maintains with the timer. The source and destination must establish a TCP connection with each other. Its mean that the TCP is connection oriented protocol. TCP recover the damage, lost and out of order by the internet system. The segments was reached destination successfully. The destination sent acknowledge to the source. If the segments which are send by the source is not reached and the time is out. The source sent the segment

24

again .If the time is out and transmitter retransmit again, and at the destination the first fragment is reached with the delay and after that retransmit segment is reached. To avoid that problem at the destination, the sequence numbers are used to correctly order the segments. Sometimes user make sure that the data put in the TCP is transmitted .For this purpose a push function is defined .which make sure that the data is transmitted and also delivered to that point of the destination. The push function does not supply any information about the push point of the destination [11] [30]. 2.9.1 TCP Header The TCP header consist of the source port, destination port, etc which can be shown in the figure (11).

Source

Destination Port Sequence Number

Offse t

Reserve d

Acknowledge Number U A P R S F R C S S Y I Window G K H T N N

Checksum

Urgent Pointer Options Figure 8: TCP header [7].

The TCP source port number is the connection number on the source computer; this field describe the port of the sending process. The source port and the source IP address are function as the packet’s return address, when there is no information on the source port. TCP source port number is also optional, when it is not used, then it should be represented by zero values. TCP Destination Port is 16bits.The sequence number used to avoid the duplication of data. The data reached in wrong order at destination computer. The Sequence number is used by the destination computer to reconstruct the data back into its original position. If the acknowledgement is set, the sender must wait for the knowledge if the acknowledgement is not received the sender retransmit the data. The acknowledgement is sent when the connection is built, acknowledgement is used to make the transmission error free.

25

The data offset contains the TCP header length. It is measured in 32-bit which is equal to one word. It described where the data is started in the header. This field is reserved for the future field, because of that must be zero. There are six flags in the TCP header; each flag contains 1bit for the description of the flag.

Table 6: Flags in the TCP header and their description [7].

The window is used by the destination machine to tell the source machine that the how much data TCP will receive. TCP has a mandatory checksum. The checksum in the TCP covered the whole segment, which has the TCP header and TCP data. The calculation of the TCP header is same as the UDP header see section (2.7.2).The only difference between TCP checksum and UDP checksum, TCP check sum is optional and UDP checksum is mandatory. When the URG flag is set the urgent pointer is valid. The urgent pointer is the positive offset that must be added to the sequence number field of segment. To specify the last byte of the urgent data, TCP urgent mode is used to send the urgent data from the sender machine to receiver machine. The urgent mode is begun by sitting URG bit in TCP header and urgent pointer used to specify the last byte of urgent data. 26

The option is at the end of the TCP header. All options are covered by the checksum .Options are variable in length. Mostly 8 bit in length, also sometimes multiple of 8 bits in length. There are two types of the options Ø A single octet of option-kind. Ø An octet of option, an octet of option- length, and the actual option-data octets. The list of the options may be shorter than the data offset. Because of that at the end of the options there should be the puddings [7]. 2.10 User Datagram Protocol (UDP) The user datagram protocol (UDP) is defined by the US department of defence (DoD).UDP is defined by the RFC 786 written by John Postal [20].UDP is a connectionless( which means that the every data is send independently) and unreliable protocols. UDP protocols are used for the data transmission known as datagram’s from one computer to another computer which are interconnected with each other [21] . The UDP protocol provides the unreliable data transfer which can increase the throughput of the networks and decreases the average delay in the communication. In the UDP transmission the sender and receiver does not send any acknowledge about the datagram’s that are damage or lost .Its means that there is no need of re-transmission or recovery. If there is no need of retransmission or recovery of damage or lost packet’s then there is minimum delay during the transmission. UDP protocol is designed for the applications that are very much sensitive to the delay during the transmission. The UDP uses the ports to make the communication successive [22]. The port field is 16-bits in length and its value vary between the 0 and 65,535. The port 0 is reserved and do not be used. Ø Ports 1 through 1023 are named "well-known" ports and on Unix-derived operating systems binding to one of these ports requires root access. Ø Ports 1024 through 49,151 are registered ports. Ø Ports 49,152 through 65,535 are ephemeral ports and are used as temporary ports primarily by clients when communicating to servers. 2.10.1 UDP protocol header The UDP protocol is used to break the data stream into the datagram’s .The datagram’s is added with the source port, destination port, message length and also with the checksum.

27

Figure 9: UDP header

[20].

The UDP source port number is the connection number on the source computer; this field describe the port of the sending process. The source port and the source IP address are function as the packet’s return address, when there is no information on the source port. UDP source port number is also optional, when it is not used, then it should be represented by zero values. UDP destination port number identifies the ends point of the communication. This field is also used to forward the data when the packets arrived to the destination. This field contains information about the size of the message. UDP message length is consists of the length of the header and data. UDP is the error checking field .It is used to verify that the datagram’s which is send by the host is not corrupted by the processing to the destination. The error checking is performing by computing the same mathematical operation at the destination which is performed at the host. If there is any difference

between the mathematical operation which is done at the source

and the destination which shows that there is error occurred during the transmission of the packets. The internet Check sum algorithm is used to compute the checksum [21]. 2.10.2 CHECKSUM “The IP checksum is the 16 bit one's complement of the one's complement sum of all 16 bit words in the header” [11].The UDP at the sender side take the one’s compliments of the sum of the 16 bits word of the segment. The result is put into the checksum field segment. When the segment is arrived at the receiver side, all 16-bits word is added together with the checksum field segment. If the result is in the form of ones their no error, if there is only one or more than one bit are zero its mean that’s their no error in the segment. Example: [15]

28

The 16 bits words are 1110001110001100 1000110011001111 1101011001100110 The sum of the 16 bits words is 11100011001000001. The UDP at the sender side take the one’s compliments of the sum of the 16 bits word of the segment. In this example the result is 00011100110111110 .This result is put into the Checksum field segment. At the receiver side all 16-bits words segment are added with the checksum. The result is 1110001100100000 plus 00011100110111110. The result is 11111111111111111. Its mean there is no error. 2.10.3 UDP_LITE The key purpose for using UDP protocol is that it is so much sensitive to delay. In UDP there is not any process for recovery and re-transmission of packets. The re-transmission and recovery of the damage or lost packet’s decreased the delay sensitivity and also its simplicity. In lot of real time applications the packet which has error’s are needed rather than discarded, the packet with error will be utilized by the real time application to enhance the features (e.g. in audio and video transmission). The UDP_Lite is used to improve the packet loss, packet delay and also overall performance [28] . UDP_Lite provide a checksum with an optional partial convergence. The optional partial convergence divides the packet into two parts; one is the sensitive part and second is the insensitive part. Sensitive part means that the packet is covered by the checksum and insensitive mean that the packet is not covered by the checksum. When the error occurred in the sensitive part, the packet is discarded by the host port. When the error occurred in the insensitive part, the packet is not discarded by the host port [29]. UDP_Lite partial checksum only covers the sensitive part of the packet. The amount of the sensitive data in the packet is specified by sending application in the UDP_Lite header. The insensitive part is ignored. To avoid complexity the sensitive data is put at the beginning of the packet. The data is payload at the sender side and at the receiver side the data is received with the less discarded packets [30] . 2.11 The Lightweight User Datagram Protocol (UDP_Lite) Header The UDP_ Lite header is same as UDP header the only difference between these two is that the length field is replaced by the check sum coverage.

29

Figure 10:

UDP_Lite header [29].

The checksum field defines the number of bytes in the packet .This field is used to verify the error sensitive portion of the UDP datagram. Checksum coverage is the number of octets. It has the value between 0 to 7.If it has the value of zero its mean that the whole packet is covered by the checksum. If the UDP_Lite packet has the checksum with the value between 1 to 7 it must be discarded by receiver. 2.12 File Transfer Protocol (FTP) The FTP is used to copies a complete file or programme from one system to another system and to encourage indirect or implicit (via programme) use of remote computer over the internet. The data transfer by using the FTP is more reliable and efficient. FTP is used to download file from the server or upload file to the server. To use FTP need a account to login on server or need to use FTP with server that allows anonymous FTP, which is used to download software from computers where the user do not have the personal account. FTP designed to work at different hosts, running different operating system, using different file structure, and perhaps different character set. The FTP can be run over TCP and UDP. The FTP uses two TCP connections between the client and server. The control connection is built up for the client server session. A data connection is created and deleted as necessary [7]. 2.13 Trivial File Transfer Protocol (TFTP) TFTP is the trivial file transfer protocol .TFTP is used to transfer file from one system to another system, it is basic form FTP, used for bootstrapping system which do not have any mass storage device. The only thing that it can do is read or writes files to a remote server.

30

TFTP designed to use UDP, to make it simple and small. Implementation of the TFTP is so much simple, small and easy to implement. TFTP is implemented with UDP, IP and a driver device. TFTP is fit into read only memory. It can be used only with the UDP implementation. Any transfer between client and server starts when client ask the server to either read or write for the client. The first 2 byte is the opcode which identifies the packet type. TFTP has five types of packets.

Table 7: TFTP packets type [7].

The read request specifies the file which client want to read and the write file for the client. The mode consist of ASCII string net ASCII or octet. Each number contains a block number which can be used in the acknowledgement. The stop and wait protocol is supported by the TFTP. The final TFTP error message, with an opcode of 1server generated this message if the read or write request is fail.

2.14 Hypertext Transfer Protocol (HTTP) The Hypertext Transfer Protocol (HTTP) is layered over a reliable byte stream and for distributed, collaborative, hypermedia information systems [26]. HTTP has been in exercise

31

by the World-Wide Web global information enterprise since 1990. Primary Version of HTTP called as HTTP/0.9, was an easy protocol for raw data transport crosswise the Internet. HTTP communication consists of a request sent from the client to the server, followed by a response sent from the server to the client. Request and response considerations are articulated in a simple ASCII format. HTTP tolerates an open-ended set of methods and headers that designate the reason of a request. It builds on the regulation of reference provided by the Uniform Resource Identifier (URI), as a location (URL) or name (URN), for demonstrating the resource to which a method is to be functional. An HTTP request includes several elements: a method such as GET, PUT, and POST. Uniform Resource Locator (URL); a set of Hypertext Request (HTRQ) headers, with which the client specifies things such as the kinds of documents it is willing to accept, authentication information, etc; and an optional Data field, used with certain methods (such as PUT). The server parses the request, and captures action according to the specified method. It then sends a reply to the client, including [27]: Ø A status code to point out if the request succeeded, or if not, why not. Ø A set of object headers, meta- information about the ‘‘object’’ returned by the server. Ø

Data field, containing the file requested, or the output generated by a server-side script.

URLs may submit to various document types, but the key format is the Hypertext markup Language (HTML). HTML ropes the use of hyperlinks (links to other documents) furthermore also supports the use of inline images, URLs referring to digitized images (regularly in the Graphics Interchange Format (GIF) or JPEG format), which should be displayed along with the text of the HTML file by the user’s browser. HTTP is also damaged as a generic protocol for announcement stuck between user agents and proxies/gateways to other Internet systems, counting those supported by the SMTP, NNTP, FTP, Gopher, and WAIS protocols. In this manner, HTTP assigns basic hypermedia admittance to resources reachable from diverse applications. 2.15 ETHERNET PROTOCOL Ethernet data streams are break into the data packets which are called frames. Ethernet uses an access method called CSMA/CD (Carrier sense multiple access/Collision Detection).this is the system in which the sender listen the bus. When the two senders send at the same time at same bus as a result a collision is occur. Then the both senders back off and wait for a random 32

amount of time to retransmit the data packets. Because of retransmission there is delay is involves and sometimes it does not effect the speed of the transmission [15] .

Figure 11:

Ethernet Data Format [41].

The Preamble (PRE) field is consisting of the seven bytes. It is in the form of 101010.That tells the receiving station that a frame is coming and also synchronize .If an error is occurred in the transmission of the permeable field .This field will be transmitted completely. This field is not provided by the data packet, it is automatically generated by the Ethernet_lite MAC controller. At the reception side this field is automatically took it away from the data packet. The start Frame delimiter consists of one byte. This field is consisting of the alternative pattern of the ones and zeroes. At the end two consecutive 1 (10101011) .Which is used to indicates the start of the frame, and also that next bit is the left most bit of the destination address. This field is automatically generated by the Ethernet MAC and is not provided in the data packet. At the reception side this filed is automatically take away from the data packet. The destination address field is 6 bytes in length. If the least significant bit is 0 its mean that the destination address is individual or unicast, alternatively if it is one its mean that the destination address is group or multicast address. The Ethernet_Lite MAC supports transmission and reception of the unicast and multicast. The Source Address (SA) is 6 bytes in length. This field indicates the sending station. The source Address and the Destination address field are providing with the data packet and retained in the packets until at the receiving side. The Type/Length field is 2 bytes in length .it contain number of bytes in the data field except the padding. The Ethernet_Lite MAC does not perform any processing of the type/length field. This filed is transmitted the least significant bit first but with the high order byte first. The data field is the sequence of the n bytes. This filed contain the 0 to 1500 bytes in length. The pad field is varying from the 0 to 64 bytes. For the success CSMA/CD operation the frame length must be greater than the 64 bytes .If this less then 64 bytes then there is need of padding. Then this field is automatically inserted by the Ethernet_Lite MAC. 33

The frame checks sequence filed is 4 bytes. The value of contains a 32-bit cyclic redundancy check (CRC) value [30] [31].

3 CASE UDP The embedded system is consisting of V2MB1000 on which P160 communication module. In this case by using the ethereal who can account the analysis of the UDP and also their percentage? The memory size is 10 kb in this implementation try to make the memory small as can. 3.1

Hardware

The board V2MB1000 is used for the implementation of the web server. “The Virtex-II MB Development kit is the perfect solution for FPGA and system design that needs a quick, flexible, feature-rich prototype platform”.

Figure 12: Virtex II2MB 1000 development kit [40]

It has the one- million gates Virtex-II FPGA. IT has the P160 expansion module for the 110 user I/O that also enables applications like prototyping and testing. The vertex-II board

34

contain the 16Mx16DDR memory, Dip switches, reset switch, programme wash switch, TAG port and also one RS-232[17][24]. 3.2

The P160 Communications Module Board

The P160 Communications Module Boardcom is fixed at the P160 communication module on the Virtex-IIV2MB1000 Development Kit. The Broadcom circuit is used to convert the command from the Ethernet_Lite component to signals on the Ethernet cable [38]. It has the integrated Voltage regulator, and can be supplied by either a 2.5V or 3.3 v power supplies [40].

Figure 13:

The P160 Communications Module Board [39]

35

Figure 14: Broadcom Ethernet

interface circuit on Virtex II2MB1000 development kit

[36]. The USB core is inside the FPGA and the USB connector is on the P160 Communications Module board. The P160 Communications Module provides the RS232, I2C port and SPI port. The P160 Communications Module has the 2M x 32 Flash and 256Kx32 SRAM. The PS/2 keyboard connector is used for connecting a PS/2 compatible keyboard. 3.3

CPU (MICRO BLAZE)

The embedded system is consisting of the Micro Blaze Soft Processor core. The processor is the 32-bit RISC processor is a 32-bit processor supporting 32-bit bus width. The two 32-bit instruction formats are used in the micro blaze. The type A is the register-register instruction. 36

It consists on the opcode, one destination and two source registers. The type B is the registerImmediate instructions. It consists of the opcode, one destination and one source registers, and a source 16-bit immediate. It has 32x32bit general purpose register and two 32-bit special purpose register (programme counter and machine register).it has three-stage pipeline architecture. The on chip memory is the synchronous memo ry to access on chip Block ram. OPB peripheral are used for, Watchdog Timer, Interrupt Controller, UART, General purpose I/O, and Timer/counters.

Figure 15: Microbalze RISC 32 bit processor system interconnects [42].

3.4 Ethernet Ethernet originated at Xerox Corporation in the 1970s.The original Ethernet was developed as an experimental coaxial cable network, operate with a data rate of 3 Mbps using a carrier sense multiple access collision detect (CSMA/C D) protocol for LANs. First time it was describe in the article Ethernet: Distributed Packet Switching for Local Computer Networks by Robert M. Metcalfe and David R. Boggs at Xerox Palo Alto Research Centre, in July 1976 a publication of the association fo r Computing Machinery [44]. With the success of the Xerox Corporation Project it attract more attention from the filed of computer sciences and engineering. As a result in 1980,Digital Equipment Corporation(DEC),

37

Intel Corporation, and Xerox Corporation standardized Ethernet as 10 Mbps with the Ethernet version 1.0.These three companies jointly described in a document titled The Ethernet , a Local Area Network, Data link layer and physical layer specifications. The other name for this standard is DIX Ethernet. In 1985, the IEEE released original IEEE 802.3 standard which was very similar to the DIX Ethernet. The draft standard was approved by the 802.3 working group in 1983 and was published as an official standard in 1985(ANSI/IEEE Std 802.3-1985) [45]. The various form of the Ethernet use different physical topologies and cabling types. 3.4.1 Advantages of Ethernet Ethernet can transfer short messages as well as huge files from one embedded system to another embedded system which is connected with the same network. Embedded system can communicate in the network by the addition of an Ethernet controller chip. Ethernet does not depend on the speed of the Ethernet controller chip. Even 8-bit microcontroller cans ´communicate in an Ethernet network. Ethernet can make the communication by using the existing high level protocol or it can use an application specific protocol. Ethernet is easy to implement, manage, and maintain. All the embedded system in the network obey the Ethernet specification for the interconnecting ,exchanging data and managing network traffic, there is no need of design the hardware interface separately. Ethernet is much flexible, for example network is connected by using the twisted pair, fibre-optic, or coaxial cable. Hardware, software, and debugging tools and components for Ethernet are easily available and cheaper. The main reason for the popularity of Ethernet is low cost network implementation. In the Ethernet hardware manages the network traffic, so there is no need for the software to mange the network traffic. Ethernet provide so much fast communication between 10 Mb/s to 100 GB/s, in most of the embedded system 10 Mb/s is used. 3.4.2 Limits of Ethernet Ethernet is not good for the transfer of data that require the minimal delay. Sender waited to transmit data that require the minimal delay. Because of the sender have to wait to transmit data, which mean that if the network is busy the data transfer with the maximum delay and if the network is not busy the data will transfer with the minimal delay. On the Ethernet the data does not send at the specific time. Once the embedded system is connect with the computer on

38

the network. The computers on the network are allowing the transfer of data with minimal delay, but the problem is that the data taken by the embedded system is not real time. Ethernet does not transfer the small amount of data with good efficiency. Ethernet transfer data in the form of frames, each frame has 46 and 1500 data bytes. Each frame has 26 bytes of synchronizing, addressing, error detecting plus the data. If the sender has to transmit the single byte on the network, the frame must include the 26 bytes of overhead plus 45 bytes of padding. Ethernet is not best solution for the data transfer because most of the chip supports the low power, power consumption for an Ethernet controller chip can be 50 mill amperes or more a 5 volts. 3.5

OPB Ethernet Lite Media Access Controller (v1.01b)

The Ethernet_Lite MAC interface design is a soft intellectual property (IP) core which is implemented in the Virtex–II. The on-chip Peripheral bus (OPB) is used for the communication between the Ethernet_Lite MAC and processor. It provides the 10 Mbps, for the fast transmission 100 Mbps and which is called the fast Ethernet protocol. The OPB Ethernet Lite MAC is divided into two parts A) OPB IPIF B) Ethernet_Lite IP The IPIF the subset of the OPB bus is used to couple the Ethernet Lite MAC core and the OPB processor bus [21].

Figure 16: Ethernet_ Lite [41]

3.5.1 Ethernet Controller In embedded system which have capability to support Ethernet, in such a system CPU maintain communication with Ethernet controller. Here the only condition prevalent for CPU is the requirement of 8-bit external data bus microcontroller. The Ethernet_Lite MAC interface design is a soft intellectual property (IP) core which is implemented in the selected Xilinx Virtex and Spartan FPGAs. The Ethernet_Lite MAC

39

supports the IEEE std. 802.3 Media independent interface (MII) to industry standard physical layer (PHY) devices and communicates to a processor via an IBM on chip peripheral bus (OPB) interface. The Ethernet_Lite MAC interface design provides 10 Megabits per second (Mbps)100 Megabits per second(Mbps)(also known as Fast Ethernet).The Ethernet Lite MAC

is

designed as bit 0 is the most significant bit and is shown on the left of a group of bits, its mean that Ethernet Lite MAC is designed as a big endian device. The 4-bit transmit and receive interface to the external PHY, which is provided with bit 3 is the most significant and on the left of the bus. When the last bit of the EMAC Lite is transmitted and the EMAC Lite starts the timing of the inter frame gap. The on-chip Peripheral bus (OPB) is used for the communication between the Ethernet_Lite MAC and processor. It provides the 10 Mbps, for the fast transmission 100 Mbps and which is called the fast Ethernet protocol. 3.5.2 Features of Ethernet Lite MAC Ø 32-bit slave interface Ø Transmit and receive data dual port memory Ø Transmit and receive data dual port memory has memory mapped direct I/O interface Ø Dual port memory has independent internal 2K byte transmitter (TX) and receiver (Rx) Ø Transmitter and receiver dual port memory for holding data for one packet for each Ø CSMA/CD compliant operation at 10Mbps Ø CSMA/CD half duplex operation at 100 Mbps Ø Media independent interface (MII) for connection to external 10/100 Mbps PHY transceiver Ø Support unicast for the transmitter and receiver mode Ø Support broad cast for the transmitter and receiver mode Ø Auto Frame check sequence (FCS) field insertion on transmit mode and validation on receive mode 3.5.3 Intellectual property interface (IPIF) The IP interface (IPIF) block is the subset of OPB bus interface, those facilities the connection between the Ethernet_Lite IP modules to the On-Chip Peripheral Bus (OPB).An

40

intellectual property is a function targeted for implementation in a Xilinx FPGA. The interface seen by the IP is called the IP interconnect (IPIF).The Combination of the IPIF and the IP is called the Ethernet Lite device. The IPIF provides additional services, FIFO, DMA, Scatter Gather (automated DMA), software reset, interrupt support and OPB bus master access. These additional services are placed into the IPIF .In the IPIF modules, the read and write FIFOs, DMA/SG, Interrupt control and the reset block, attach to the IPIC inside and utilize the register and or SRAM interfaces and take advantage of the centralized address decoding. The glue in the Ethernet Lite device represents non-IPIC connection between the modules.

Figure 17: OPB Device using the full set of IPIF features [46].

The IP interconnect is the interface that give the IP access to the OPB or to services provided by the IPIF. The services are FIFO data buffering in both directions, DMA, scatter gather, address decoding, and interrupt handling. A slave IP need only the in and out data busses, a register interface decodes and read/write request and acknowledge signals by using the few register. Sometimes IP require an address-block decode and enough bits passed through to cover that address range for this purpose the IP require the SRAM interface.

41

There is so much simple function of the IPIF to give access OPB to some IP register which is shown in the Figure [23].

Figure 18: An OPB device using only IPIF feature required for the register access [46].

3.5.4 OPB IPIF Interrupt Interrupt is a signal to a computer that stops the execution of a running program so another action can be performed. A circuit that conveys a signal can stop the execution of a running program. In most of the configurations the IP generated the Interrupts. The number of the IP interrupts depends on the nature of the IP. In some configurations the interrupts are generated by the IPIF. If the IPIF includes the DMA/SG function the number of the interrupt generated by it is equal to the number of the channels. The number of the channel is variable its mean that the variable number of interrupts bit s into a single register, a hierarchical interrupt reporting structure for the device is used. The number of the interrupt which can be generated by the device is shown in the figure (22).

42

Table 8: OPB IPIF interrupts conditions [46].

The OPB IPIF has a function to collect all internal interrupts into a single peripheral device, by using the masking and ORing into to a single interrupt out put .The single interrupt out put is sent to the microprocessor system interrupt controller(ITNC).The interrupt source is module which combine all the interrupt and combine it into single interrupt output. The IPIF interrupt module consist of Device interrupt Source Controller (ISC) and the IP Interrupt Source Controller. When an interrupt signal is generated captured by the Interrupt Source Controller with the generation of the Interrupt-active signal which indicates that one or more interrupt is captured by the interrupt Source Controller (ISC).The IP Interrupt Source Controller parameterized how many interrupts needed by the IP. The IP Interrupt Source Controller contains the Interrupt Status register (ISR) and Interrupt Enable register (IER) functions .The registers are accessible by using the IPIF local bus interface.

43

Figure 19: Interrupt Structure in the Ethernet-Controller device [46].

3.5.5 OPB IPIF Packet FIFO The Packet FIFO (PFIFO) resides in the Xilinx Intellectual Property Interface (IPIF) which interfaces to a host bus structure such as the IBM OPB. The OPB IPIF packet FIFO has two function the Read PFIFO which is used to buffer data from the IP that to be sent to the ho st bus. Write PFIFO which is used for data from Host Bus to IP. The Virtex BRAM is the basic data storage medium for the FIFO. SRL16 elements are used as the memory medium for the 16 words of FIFO depth. For the proper functionality the memory is coupled with surrounding counters and logic. The PFIFO is used as a data buffering agent between the IP function and a Bus Master such as DMA/SG engine. The basic function of the Packet FIFO is the FIFO buffer. There is no need of the accessing agent

to provide the successive memory addresses

to sent data in and out from the Packet FIFO. Data is stored and read in a First in First out (FIFO) sequence. In the Ethernet for the retransmission and discard of the data the PFIFO is provided with the additional packet ma nagement control. The IPIF accesses the PFIFO module as the memory mapped registers and memory mapped FIFO.

44

The setting of the FIFO width, FIFO data depth (words), and IPIF data bus width and target family type is adjusted by the user. Direct Memory Access and Scatter Gather: Direct Memory Access and Scatter Gather is used by the IP input/output peripheral devices to get the automatic access to the memory and transfer of data id faster. Direct Memory Access (DMA) is used to transfer bounded number of seque ntial data between memory and an I/O device without the help of microprocessor. The processor prepares DMA operation in a system of buffers and their associated buffer descriptors, by specifying number of bytes to be transfer and the source and destination addresses. To get the higher level unit of data (e.g. packet or frame) transfer one or more DMA operation are combined with each other. These higher levels of data are then sent to the specified destination address. Scatter gather is used to do Direct Memory Access (DMA) data transfers of data that is written to non-contiguous areas of memory. Scatter/gather DMA uses multiple blocks at different memory addresses. The Scatter gather automation hardware processes the Buffer Descriptors and performs the DMA operations specified there in through activation of the DMA hardware. 3.5.6 OPB IPIF It provides a bi-directional interface between a user IP core and the OPB 32-bit bus standard. The OPB IPIF is compatible with IBM Core Connect 32-bit OPB. It can supports IP data widths from 8 bits to 32 bits with automatic byte steering. The processor prepares the DMA function with optional Scatter/Gather mechanization. It provide the WrFIFO and RdFIFO which is user configured and with optional IP packet. It several features like Local IP interrupt collection with the user S/W programmable enables/disables and S/W triggered reset generator for localized reset of user core. 3.5.7 Ethernet Lite Intellectual property The IPIF the subset of the OPB bus is used to couple the Ethernet Lite MAC core and the OPB processor bus [21]. 3.6

UDP

The software consists of IP stack and also includes the size of the buffers

45

Figure 20: IP

Stack

The graph shows the structure for the IP_stack and the function that function that begins with BTEL is in the Ethernet code. The UDP/IP is the core part .The lot of free implementation on the UDP/IP and TCP/IP in the market .To implement internet on embedded system is implemented by implementing the ARP, IP, ICMP, UDP. The data conversion mechanism from hardware to software described below

46

Figure 21: Block Diagram of UDP/IP core[23].

This figure shows the process of UDP and IP cores. Furthermore it describes all the sub components such as receiver, CRC checker or generator, receiver RAM, ROM, Packet Composer or interpreter, ARP lookup table, Transmitter RAM, and transmitter. First of all this process started from left to right direction, physically layer provides the source of the Ethernet connection at 10/100/1000 Mbps. Consequently the original interface between FPGA with the UDP or IP core and physical layer is way to use a media independent interface for the values of 10 or 100 Mbps Ethernet and Gigabit Media Independent Interface for Gigabit Ethernet. The functionality of the above interfaces is same to each other and compatible with the UDP or IP stack cores. In this diagram after the data passing from physical layer to receiver, its controls the new data and measure the new packet (preamble from Ethernet PHY). In this part when the new packet enter or detected the packet will be stored byte wise to the Receiver RAM (rx_ram).MAC addresses must check the receiver

and if these

address are similar to the core’s MAC address and broadcast those MAC address which are accepted , otherwise if the packets do not accept then it is rejected.

47

The CRC checker or generator blocks are similar and find the Cyclic Redundancy Check (CRC).The function of receiver RAM safe the packet for short time and in this packet including all the frame with Ethernet header, IP header etc. Those packets which have not correct MAC address will not screened in the receiver and do not safe in the Receiver RAM. The functionality of ROM in this process of UDP or IP to minimize the gate counts the design components which are measured as static in the transmitted Ethernet frame. These components are safe in a ROM such as the static IP header components are: Header length, differential services, protocol type, fragmentation offset and fragmentation flags. In this process of UDP or IP core packet Composer or Interpreter are the main control blocks and these blocks are similar to each other[23].

3.6.1 THE SOFTWARE IMPLEMENTATION To understand the software implementation the reader must go through chapter 2 of this report and also need to read the lot of RFC which can be recommended.

3.6.2 DESIGN The communication ports on this board is 100/10 Mb RJ45 Ethernet and 9 pin RS232. The Ethernet required ARP/RARP. ARP is used to translate IP address to Ethernet address and RARP is used to translate Ethernet address to IP address. But in this system the only needed the ARP reply. ICMP provides the echo command to test. 3.6.3 Checksum.C Since the vertex board is capable of handle 16bit data therefore and here checksum is handling 32 bit machine, therefore the overflows are added in the summing loop and then the 32 bit sum is folded into 16bits. #include "checksum.h" #include "Config.h" Unsigned short checksum (unsigned short *data, int Len, long sum) {

48

// Main summing loop While (len >1) { sum+=ntohs (*data++);// Convert a 16-bit quantity from network byte order to host byte order (Big-Endian to Little-Endian).

if (sum&0x80000000) sum= (sum&0xffff)+(sum>>16); len-=2; } // if we have any Add left-over byte if (len) { sum += (unsigned short) *((unsigned char *) data); } // Fold 32-bit sum to 16 bits while (sum >> 16) { sum=(sum&0xffff)+(sum >> 16); } return ~sum; } 3.6.4 LINK LAYER The link layer is responsible for the transmitting and receiving of data and also provides end to end validity of the data being transmitted [3]. The protocol used by the link layer consists of IP, ARP and RARP. In this system only IP and ARP is implemented and no need have translate of Ethernet address to IP address in this test system. Because the IP address of the target system is define in the code which 192.168.00.11. At the target system there is only Ethernet, the link layer is Ethernet. This protocol is preferred at the hardware because of its simplicity. In this implementation only use of ARP, ARP is used by the Ethernet protocol to translate IP address to Ethernet address. At the receiver side, when a package is received the Ethernet header is ignore and only data is passed to the next level. If the Etherne t controller received any message and ARP/RARP message is send to the ARP protocol. In the ARP code the RARP message is ignored and only sends ARP message. #include"config.h" #include"link.h" #include"arp.h" #include"arp_header.h"

49

#include"ethernet_lite.h" #include #include typedef struct { unsigned int addr; char ethaddr[6]; } tarp_tab; static tarp_tab arp_tab[MAX_ARP]={{0}}; static int index=0; int BTArpLkup(unsigned int addr,char *enet){ int i; for(i=0;iprottype)==0x0800){ switch(data->op){ 50

case ARP_REQ:{ int found=0; for(i=0;isender_iaddr){ found=1; } } if(!found){ arp_tab[index].addr=data->sender_iaddr; memcpy(arp_tab[index].ethaddr,data->sender_ethaddr,6); index++; index=i%MAX_ARP; } if(data->t_addr==htonl(IPADDR)) { sarp->t_addr=data->sender_iaddr; sarp->sender_iaddr=htonl(IPADDR); memcpy(sarp->t_ethaddr,data->sender_ethaddr,6); memcpy(sarp->sender_ethaddr,BTELaddr,6); sarp->op=ARP_RESP; BTELSendData(sarp->t_ethaddr,BTELaddr,(char *) sdata,sizeof(ARP_PKT),ETH_TYPE_ARP); } } break; case ARP_RESP: if(data->t_addr==htonl(IPADDR)){ for(i=0;isender_iaddr){ return; } } arp_tab[index].addr=data->sender_iaddr; memcpy(arp_tab[index].ethaddr,data->sender_ethaddr,6); index++; index=i%MAX_ARP; } break; case RARP_REQ: if(!memcmp(data->t_ethaddr,BTELaddr,6)){ data->t_addr=data->sender_iaddr; data->sender_iaddr=htonl(IPADDR); memcpy(data->t_ethaddr,data->sender_ethaddr,6); memcpy(data->sender_ethaddr,BTELaddr,6); data->op=RARP_RESP; } break; case RARP_RESP: break; } 51

} } } void BTArpSend(char *ethaddr){ } 3.6.5 Ethernet_Lite.C First of all, send frame function is built up to send the frames. The functions send frame has the destination address, source address and data. Write each byte to the EMAC Lite and send it. Loop on the status waiting for transmits to be complete. Check if Ethernet address is ok else returns -1. Get the length of the frame tha t arrived Read each byte from the EMAC Lite* acknowledge the frame .Initializes the BTEL Init and BTEL Poll , sending data in 8 bits and at the end error checking and the memory copy has been take place. #include #include "link.h" #include "ip.h" /*ip and ipcp*/ #include "ethernet_lite.h" #include "ip_header.h" #include #include #include char BTELaddr[6]={0x00,0x00,0x5e,0x00,0xfa,0xce};

void SendFrame(Xuint32 BaseAddress,char *eaddr, char *saddr,char *type,Xuint8 *FramePtr, unsigned Size) { unsigned i; /* * Write each byte to the EMAC Lite */ for (i=0; i < Size; i++) { XIo_Out32(BaseAddress + XEL_TXBUFF_OFFSET + (i*4), FramePtr[i]); } /* * The frame is in the buffer, now send it */ XIo_Out32(BaseAddress + XEL_TPLR_OFFSET, ((Size & XEL_TPLR_LENGTH_MASK_HI) >> 8)); XIo_Out32(BaseAddress + XEL_TPLR_OFFSET + 4, Size & XEL_TPLR_LENGTH_MASK_LO); 52

XIo_Out32(BaseAddress + XEL_ TSR_OFFSET, XEL_TSR_XMIT_BUSY_MASK);

/* * Loop on the status waiting for the transmit to be complete */ while (!XEmacLite_mIsTxDone(BaseAddress)); } void old_SendFrame(Xuint32 BaseAddress,char *eaddr, char *saddr,char *type,Xuint8 *FramePtr, unsigned Size) { unsigned i; /* * Write each byte to the EMAC Lite */ /*daddr*/ for (i=0; i < 6; i++) { XIo_Out32(BaseAddress + XEL_TXBUFF_OFFSET +(i*4), eaddr[i]); } /*saddr*/ for (; i < 12; i++) { XIo_Out32(BaseAddress + XEL_TXBUFF_OFFSET + (i*4), saddr[i-6]); } for (; i < 14; i++) { XIo_Out32(BaseAddress + XEL_TXBUFF_OFFSET + (i*4), type[i-12]); } /*data*/ for (; i < Size+14; i++) { XIo_Out32(BaseAddress + XEL_ TXBUFF_OFFSET + (i*4), FramePtr[i-14]); } Size+=14; /* * The frame is in the buffer, now send it */ XIo_Out32(BaseAddress + XEL_TPLR_OFFSET, ((Size & XEL_TPLR_LENGTH_MASK_HI) >> 8)); XIo_Out32(BaseAddress + XEL_TPLR_OFFSET + 4, Size & XEL_TPLR_LENGTH_MASK_LO); XIo_Out32(BaseAddress + XEL_TSR_OFFSET, XEL_TSR_XMIT_BUSY_MASK);

53

/* * Loop on the status waiting for the transmit to be complete */ while (!XEmacLite_mIsTxDone(BaseAddress)); }

Xuint16 RecvFrame(Xuint32 BaseAddress, Xuint8 *FramePtr,int Length) { Xuint16 LengthType; /*Xuint16 Length;*/ unsigned i; /* check if ethernet address is ok else return -1 */ /* * Get the length of the frame that arrived */ LengthType = XIo_In32(BaseAddress + XEL_RPLR_OFFSET); LengthType = LengthType fd=1; data->size=0; data->link_offset=14; /* size of ethernetheadder */ return data->fd; }

54

int BTELPoll(linkdata *data) { int type; char seth[6]; ETHLITE_HEADER *head=(ETHLITE_HEADER *) XPAR_OPB_ETHERNETLITE_0_BASEADDR+0x2000;

if(XEmacLite_mIsRxEmpty(XPAR_OPB_ETHERNETLITE_0_BASEADDR)==XFALSE){ type=RecvFrame(XPAR_OPB_ETHERNETLITE_0_BASEADDR,data>rbuff,MAX_LINK_SIZE); data->size=MAX_LINK_SIZE; switch(ntohs(type)){ case ETH_TYPE_ARP: case ETH_TYPE_RARP: /* XEmacLite_SendFrame(XPAR_OPB_ETHERNETLITE_0_BASEADDR, data>rbuff, 200);*/ BTArpEval(data->rbuff,data->sbuff); return 0; break; case ETH_TYPE_IP: //BTArpUpdate(data->rbuff,seth); return 1; } } return 0; }

int BTELSend(linkdata *data){ char ethaddr[6]; if(BTArpLkup(((IP_HEADER *)&data->sbuff[data->link_offset])->daddr,ethaddr)){ BTArpSend(((IP_HEADER *)&data->sbuff[data->link_offset])->daddr); return -1; } BTELSendData(ethaddr,BTELaddr,data->sbuff,data->ssize,ETH_TYPE_IP); } void BTELSendData(char *daddr,char *saddr,char *data,unsigned short size,short type){ memcpy(data,daddr,6); memcpy(data+6,saddr,6); memcpy(data+12,&type,2); if(sizesize=0; return data->fd; } int BTSlipPoll(linkdata *data) { unsigned char tmp; while(read(data->fd,&tmp,1)!=-1){ switch(tmp){ case SLIP_END: return 1; break; case SLIP_ESC: while(read(data->fd,&tmp,1)==-1){/* the data */ } switch(tmp){ case SLIP_ESC_END: tmp=0xc0; break; case SLIP_ESC_ESC: tmp=0xdb; break; } } data->rbuff[data->size]=tmp; data->size++; } return 0; } int BTSlipSend(linkdata *data){ int i; char slip_end=SLIP_END; char slip_end_esc[2]={SLIP_ESC,SLIP_ESC_END}; char slip_esc_esc[2]={SLIP_ESC,SLIP_ESC_ESC}; write(data->fd,&slip_end,1); for(i=0;issize;i++){ switch(0x00ff&(data->sbuff[i+data->offset])){ case SLIP_END: write(data->fd,slip_end_esc,2); break; case SLIP_ESC: write(data->fd,slip_esc_esc,2); 58

break; default: write(data->fd,&(data->sbuff[i+data->offset]),1); } } write(data->fd,&slip_end,1); data->ssize=0; } 3.6.8 IP.C The IP protocol which is implemented is 4 bit version and also length field if it has any data .The IP protocol which is implemented does not support type of service (TOS).In this implementation the datagram’s does not break down into the small size. Its mean that there is no need of fragmentation of IP datagram’s and also no need of Identification, flags, fragment offset. The checksum covered the whole IP header. IP checksum at the sender side is calculated by taking the following step. First of all the value of the checksum is set to zero. The 16-bit ones complement sum of the header is calculated and the result is stored into the checksum field. The same calculation is done on the receiver side, if the result is not all bit 1.IP discards the datagram’s, no error message is sent back to the sender. If there is no error the datagram’s are passé to the next level. The routing which is made only supports the link layer of the target system. Here IP header is of 20 bytes and it also check for the version and 4 bit header length(the minimum value for correct header is 5) and it is also checking routing table for routing interface. #include #include"config.h" #include"ip.h" #include"ip_header.h" #include"checksum.h" #ifdef ICMP # include"icmp.h" #endif #include"assigned.h" #ifdef UDP # include "udp.h" #endif #if defined (UDP) 59

# include "tcp_udp_head.h" #endif int BTIPEval (link *data){ int i; int data checksum; int dataihl; DEBUG ("ip 1\n\r");

if(data->data. sizedata.rbuff))||data->data. sizedata.rbuff)!=0x4){ DEBUG ("error 2\n\r");

return IP_ERROR_VERSION; } if ((dataihl=IP_HEAD_IHL(data->data.rbuff))data.rbuff)); if (datachecksum){ if (datachecksum==0xffff) datachecksum=0; if (datachecksum!=checksum((unsigned short *)data,dataihl*4,-1*datachecksum)){ DEBUG ("error 4\n\r");

return IP_OK; /*????*/ } }

60

if (ntohl(IP_HEAD_DADDR(data->data.rbuff))!=data->addr){ /* dec ttl check ttl!=0 */ /* recalk checksum */ /* route */ DEBUG ("error 5\n\r");

return IP_OK; } data->data.offset=dataihl*4; data->data.size=ntohs(IP_HEAD_LENGTH(data->data.rbuff))-dataihl*4; data->saddr=ntohl(IP_HEAD_SADDR(data->data.rbuff)); DEBUG ("IP 2\n\r"); switch (IP_HEAD_PROTOCOL(data->data.rbuff)){ #ifdef ICMP case IP_PROT_ICMP: BTIcmpEval (data); break; #endif /*asuif#ifdef TCP case IP_PRO T_TCP: { PSEUDO_HEAD *pseudo=(PSEUDO_HEAD *)data->data.rbuff; pseudo->zero=0; pseudo->prev=0; pseudo->next=0; pseudo->length=htons((short)data->data.size); BTTCPEval(data);/*,&pseudo);*/ /*asif } break; #endif*/ #ifdef UDP case IP_PROT_UDP:

61

{ PSEUDO_HEAD *pseudo=(PSEUDO_HEAD *)data->data.rbuff; DEBUG ("UDP\n\r"); pseudo->zero=0; pseudo->prev=0; pseudo->next=0; pseudo->length=htons((short)data->data.size); BTUDPEval (data);/*,&pseudo);*/ } break; #endif default: DEBUG ("Unknown \n"); } }

unsigned short ip_id=0;

int BTIPSend(char *data,int length,int offset,int type,int daddr){ int inr=0; /*check routingtable for routing interface */ IP_HEADER *head=(IP_HEADER *)&interface[inr].data.sbuff[interface[inr].data.link_offset]; head->version_IHL=0x45; head->TOS=0; head->length=htons(length+20); head->ID=htons(ip_id++); head->FLAG_FRAGOFFSET=ntohs(0x4protocol=type; head->headerChecksum=0; head->saddr=ntohl(interface[0].addr); head->daddr=ntohl(daddr);

62

head->headerChecksum=htons(checksum((unsigned short *)head,20,0));

memcpy(&(interface[inr].data.sbuff[20+interface[inr].data.link_offset]),&data[offset],length);

interface [inr].data.ssize=length+20; interface [inr].data.offset=0; interface [inr].send(&interface[inr].data); } 3.6.9 ICMP.C In this implementation, the ICMP used to test the package transmit at the IP level. The ICMP only handled the echo request. The ICMP Implemented in the form of ping programme. The programme sends an ICMP echo request message to a host, expecting ICMP echo reply to be returned. The checksum of the echo request covered the whole package, the checksum is calculated same as in the case .their is no echo reply message is generated by the target system. When the request message is received the data is copied to the transmission buffer .The type and message field is set to zero, the identifier and sequence number field must be echoed. After this the checksum calculation if the calculation is correct it will be passed to the IP layer. If an error is reported by the checksum then the echo request will inform the sender (Host) about the occurrence of the error and Reply to echo request, take corrective steps for error messages or ignore. #include "config.h" #include"icmp.h" #include"icmp_header.h" #include"checksum.h" #include"ip.h" #include"assigned.h" #include"link.h" char replydata[MAX_LINK_SIZE-20]; int BTIcmpEval(link *data){/* char *data,int length,int addr){*/ int length=data->data.size; ICMP_HEADER *head=(ICMP_HEADER *)(data->data.rbuff+data->data.offset); ICMP_HEADER *reply=(ICMP_HEADER *)replydata; if(head->checksum!=htons(checksum((unsigned short *) head,length,ntohs(head>checksum)*-1))){ return -1; } switch(head->type){ 63

case ICMP_TYPE_ECHO_REPLAY: if (head->code==ICMP_CODE_ECHO_REPLAY){ } else { /* error */ } break; case ICMP_TYPE_ECHO_REQUEST: if(head->code==ICMP_CODE_ECHO_REQUEST){ memcpy(replydata,head,length); reply->type=ICMP_TYPE_ECHO_REPLAY; reply->checksum=0; reply->checksum=htons(checksum((unsigned short*) replydata,length,0)); BTIPSend (replydata, length, 0, IP_PROT_ICMP, data->saddr); } else { /* error */ } break; } return 1; } 3.6.10 UDP.C In this implementation the UDP provide the UDP echo services. It copied the data and transmitted to the target system. It calculates the checksum at the sender side. If the incoming is error free, then should be passed to the next level. The checksum is the 16 bit one's complement of the one's complement sum of all 16 bit words in the header. The psueder is the 20 bytes. The check sum of the UDP covered the pseudo header, UDP header and the data. UDP is being matched for the length of data and having checksum operation by pseudo and then the echo service is defined as a datagram on UDP and destination listens for UDP datagram on UDP port. When a datagram is received, the data from it is sent back in an answering datagram. #include"config.h" #include"link.h" #include”ip_header.h" #include"tcp_udp_head.h" #include"checksum.h" #include"assigned.h" #include"udp_state.h"

static char replydata[MAX_LINK_SIZE-20]; void BTUDPSend(char *data ,UDP_CONNECTION *state,unsigned int dest,unsigned short port){

64

} int BTUDPEval(link *data){/*,PSEUDO_HEAD *pseudo){*/ int checksum_udp=0; UDP_HEADER *head=(UDP_HEADER *)(data->data.rbuff+data->data.offset); PSEUDO_HEAD *pseudo=(PSEUDO_HEAD *)data->data.rbuff; DEBUG("sport=%d dport=%d\nlength=%d,checksum=%d\n",ntohs(head>sport),ntohs(head->dport),ntohs(head->length),ntohs(head->checksum)); /* DEBUG("SADDR=0x%X DADDR=0x%X\n%d %d %d\n%d\n",ntohl(pseudo>saddr),ntohl(pseudo->daddr),pseudo->zero,pseudo->protocol,ntohs(pseudo>length),sizeof(PSEUDO_HEAD));*/ /* checksum_udp=checksum((unsigned short *) pseudo,sizeof(PSEUDO_HEAD),0);*/ checksum_udp=checksum((unsigned short *) data->data.rbuff,data->data.size+20,(1*ntohs(head->checksum))); DEBUG("0x%X 0x%X\n",checksum_udp,ntohs(head->checksum)); switch(ntohs(head->dport)){ #ifdef UDP_ECHO case UDP_ECHO_PORT: { UDP_HEADER *rhead=(UDP_HEADER *)&replydata[20]; PSEUDO_HEAD *rpseudo=(PSEUDO_HEAD *)replydata; rpseudo->length=head->length; rpseudo->saddr=pseudo->daddr; rpseudo->daddr=pseudo->saddr; rpseudo->zero=0; rpseudo->prev=0; rpseudo->next=0; rpseudo->protocol=IP_PROT_UDP; memcpy(&replydata[sizeof(UDP_HEADER)+20],(data->data.rbuff+data>data.offset+sizeof(UDP_HEADER)),data->data.size-sizeof(UDP_HEADER)); rhead->sport=ntohs(7); rhead->dport=head->sport; rhead->checksum=0; rhead->length=head->length; rhead->checksum=ntohs(checksum((unsigned short *)replydata,data->data.size+20,0)); BTIPSend(replydata,data->data.size,20,IP_PROT_UDP,ntohl(pseudo->saddr)); DEBUG("send \n"); } #endif } } 3.6.11 Limitations

65

The main advantage of the UDP protocol is support multicast or broad cast but this feature is not implemented. IGMP is not implemented because the IGMP protocol supports the multicast which is not implemented. 3.7

System Setup

Connect the RS232 Cable to DSUB9 and the other end is connected to the COM1 on the PC. The RJ45 via the CAT 5 Ethernet Cable is connected to the Ethernet Hub 10 Mbs and the PC is also connected with the Ethernet Hub 10 Mbs. JTAG port on the P160 communication Module are connected to the Xilinx Parallel cable IV be careful in this connection that the all cables are connected properly and correctly. And the second end cable of the Xilinx parallel cable IV is connected to the LPT1 in the PC via the parallel cable. The connection between the PC and MB 1000 Virtex-II Board is shown in the figure (27). Parallel Cable to LPT1 Xilinx Parallel cable IV

Ethernet Hub 10 Mbs CAT 5 Ethernet Cable

RJ45

JTAG

PC IP address 192.168.0.20 Subnet mask 255.255.255. 0 DSUB 9

RS232 Cable to Com1

MB 1000 Virtex-II Board

66

Figure 22: System

Setup.

The component in the FPGA is Micro blaze, Ethernet_lite, uartlite, two memory controllers for the block ram. Ethernet _Lite component is a controller without any interrupts and DMA. UART _Lite is a very simple UART and it is connected to the RS232 connector. The UART is connected to the DOPB bus on the CPU. It supports the 8-bit bus interface, also has the one receiver and transmitter. It has the configurable baud rate, number of data bits in a character for add or even and the parity can be configured for add or even. The memory controller is connected to the block ram.

CPU

Microblaze

Uart light

DLMB

Ethernet lite

ILMB

RAM

UDP/IP

Figure 23 :

Connection between the memory controller and dual port ram.

67

On the embedded system always try to make the ram .In this case the block ram is 32KB. 3.8

System demonstration

Xilinx design solution, Embedded Development Kit (EDK) 7.1version has been used for designing embedded programmable systems. First of all create the project File>new project then go to Base system builder. The XPS System Builder Wizard used to create system. Then name of the project and create a project folder. Choose a location (C:\ thorfinalv\lab\-system.xmp), Architecture: vertex2, Device size: XC, Package: fg456, Speed grade:-4

Figure 24 :

Create new project.

In the Base System builder-Welcome window select “I would like to create a new design”, after that press the next. Then Base System builder-select Board Window appeared, in these window three types of Board Vendor (Avnet, Memec Design and xilinx), the Board name (Vertex, Spartan) and the Board revision.

68

Figure 25 : Select Board.

In our case selected the Board Vendor Memec Design, Board name Virtex-II V2MB 1000 Development Board with P160 Comm. Module and the Board revision is 3.Then press the next. The next window which is appeared Base System Builder-select processor. The Base System Builder supports the Micro Blaze and PowerPC processor in the embedded system.

69

Figure 26: Select processor.

In that case the Micro Blaze processor chosen for the embedded system. Then press the next. Then the Base System Builder-Configure Processor appeared which is used to set the clock frequency, debug interface, cache and othe r feature of the embedded system.

70

Figure 27: Configure Processor and System settings.

In our case set the clock 24 MHz. The debug interface of the processor configuration set to no debug. The Local Data and instruction Memory selected to 32KB.Then press the next. Then the Base system builder-configure IO interface window is appeared.

71

Figure 28: Selecting External Memories and IO devices.

In our case select the RS232 with OPB UARTLITE, baud rate 9600 bits per second, data bits 8 and the parity bit is set to NONE. The SRAM_256Kx32 controlled by OPB EMC. Then press the next. Then the Base System Builder- Configure Additional IO Interfaces,

72

Figure 29: Selecting IO devices 1.

Select the Ethernet_MAC with OPB ETHERNET LITE, unset the IIC_Conector, SPI_Connector and LEDs_1Bit then press the next, then the Base System builder-configure additional IO interface window appeared.

73

Figure 30: Selecting IO devices 2.

74

Unselect

the

LED_7Segment,

Push_button_2Bit,

DIP_switches_8

Bit

and

DDR_SDRAM_16M X16.Then press the next, the Base System Builder-Add internal peripheral Window appeared.

Figure 31: Adding internal Peripherals.

75

Our design does not use any internal peripherals. Then press the next, the Base System Builder-Software Configuration appeared.

Figure 32: Configure Software setting.

For the Standard Input and Standard Output select the RS232. And then press the next, and then the Base System Builder-System Created Window appeared.

76

Figure 33 : System Summary.

That window provide the information about the processor on the embedded system, system clock frequency, debug interface, on chip memory , off chip memory, system busses. It also

77

shows the names of the peripherals on the system. Then press the “Generate”, after that the Base System Builder- finished Window appeared.

Figure 34: Base System Builder-Finished.

The system.ucf file provides information about pin location and correct implementation of system on the targeted system. The download.cmd file contains the commands to the JTAG downloader. The system.mhs file describes the hardware that implements the system. The fast_runtime.opt file contains the information about the runtime time options.

78

There are peripherals which are added, micro blaze 32-bit RISC processor, one opb_uartile, one bram_block, two lmb_bram_if_cntrl and one opb_ethernetlite.

Figure 35 :

Hardware Peripherals.

Then make the buss connection. In the fig below there is three master connection and four slave connection.

79

Figure 36 :

Buss Connection.

All components which are added in the peripherals are added with the base address and high address, and also with size to map in the memory.

80

Figure 37 :

Add Address.

Now the external and internal connection is made and these connection is also explain well in figure (30)

81

Figure 38: Ports.

Then the all the software and hardware codes are added. Then the update bit stream on the xilinx Platform studio, when it has been done successfully. Then open the Impact, first of all create new project.Then configure the device. The configured the device via the Boundary scan module. In the boundary-scan module select automatically connect to cable and identify boundary scan chain. The xilinx is configured

Figure 39 :

Xilinx Configured.

82

And then download the bitstraem. After this programme it when the programming is succeeds. Then open the Multi-thread Clint/Server Socket Class Demo. Set the server port to 7 and choice the socket type UDP and also give the correct server address. All this is shown in the figure (32)

Figure 40 :

Client Configured.

3.8.1 The Ethereal Network Packet Analyzer The Ethereal network packet analyzer is used to capture the networks packets (like UDP, TCP, ARP and etc) and also used to display the data packets in detailed. It also provides the feature like, debug protocol implementations, examine security problems and troubleshoot network problems. To take the capture packets in running position displays. First of all go to Capture>interfaces on the main window of the Ethereal then the Ethereal: The “Capture Interfaces” dialog box is appeared .On this window capture option is clicked then the Ethereal: Capture from broad com is appeared [41] .

83

When stop this option the main window is filled with the protocols type and also with the source addresses, destination addresses and with information.

Figure 41 :

Result by Ethereal.

3.9 Bjorn System The Bjorn system consists of internet on embedded system. In this system the web page download on the embedded system .The board V2MB1000 is used, which is provided with the P160 communication module broad com. The V2MB1000 consists of one million gates Virtex-IIbFPGA. The FPGA consist of CPU (Micro blaze), RAM, busses, Ethernet and serial controller. The RS232 interface is connected to the serial controller on the FPGA. The serial controller is connected to the bus. The PHY interface is connected to the Ethernet controller. The Ethernet controllers connected to the bus. The CPU and RAM connected to the bus. Different protocols are implemented at the different layer to download webpage on the embedded system. The arithmetic Request Protocol (ARP) is implemented at the link layer to translate IP address to Ethernet address. The IP protocol with 4 bit version is implemented, ICMP is used to test the packages transmit at the IP level. The ICMP is implemented in the form of ping programmed and only handled the echo request. At the transport layer the protocol which is used is TCP and UDP. TCP is the workhorse protocol in this

84

implementation and the UDP protocol is used to provide the UDP echo service. In these implementations try to make memory as small as possible, this is 20KB. 3.9.1 Result Comparison By the comparison of the Asif system and Bjorn system the result is shown in the table below. Result

Memory size

protocol

Bjorn

17912B

TCP/IP

Asif

9509B

UDP/IP

Table 9: Result comparison

The difference in the TCP/IP and UDP/IP is the 8403 B which is the half of the TCP/IP. In the both cases the busses take the 2608 B, data takes the 58B in UDP/IP moreover 2268B in TCP/IP and text takes the 6843B in UDP/IP moreover 13036B in TCP/IP.

85

4 Summary Protocols are required to make machine communicate with each other. Internet protocol has been made standard for the communication over the internet. Therefore we also required a protocol to communicate the embedded system (Virtex-IIV2MB1000). Enhancement of UDP software has been done as the previous software was high on demand with the memory and was less configurable due to complexity. The other lacking of the software was checksum calculation and big/little endian. The brief description of different protocols like IP, ARP, ICMP, IGMP, TCP, UDP, UDP_Lite, FTP, TFTP, and Ethernet protocol has been done to understand the basic communication of protocols. We have used a hardware VII2MB1000 and communication module P160 Boardcom, CPU micro blaze has been described and the Ethernet limitation and usage has been described, On-chip peripheral bus (OPB) has been discussed. Controller internal working has been defined. Commenting on UDP, ICMP, ARP and Ethernet_Lite has been done. System setup has been done to check the UDP software. Connection between dual port and memory has been made to show the usage of UDP/IP. Xilinx design solution, Embedded Development Kit (EDK) has been used for designing embedded programmable systems. System demonstration has been done. Ethereal network packet analyzer has been used to capture the network packets to check the performance of the network. Bjorn system has been explained for TCP/IP and at the end comparison of TCP/IP and UDP/IP has been done. UDP/IP has been found efficient with size as it almost reduces the size of TCP/IP by half. The lacking of UDP/IP is as it did not support multicast and broadcast transmission.

86

5 Conclusion UDP software for Ethernet light is build. It calculates IP checksum which make it simple for users and more secure than open source previous software’s. Software uses less memory and supports both big and little endian. It is reconfigurable software and makes successive communication with P160 Communication module on the Virtex-IIV2MB1000 development kit. The problem with the UDP protocol is that it can discard lot of packets if the channel is so much noisy. The UDP protocol is best for the embedded system because of that the embedded system channel is not so much noisy. The UDP/IP protocol implemented with the so much less memory size as compared to the TCP/IP implementation. For example, if you are using system which has less memory then UDP/IP is better than TCP/IP. Systems which don’t have TCP/IP Protocol it can use UDP/IP for TFTP, BOOTP and other protocols. The xilinx EDK (Embedded Development Kit) provide the best software solution for the creation of Soc designs. In this software, Ethereal network packet analyzer is used to capture the networks packets (like UDP, TCP, ARP and etc),debug protocol implementations, examine security problems, troubleshoot network problems and also used to display the data packets in detailed. One can download free from internet. The main advantage of the UDP protocol is support multicast or broad cast but this feature is not implemented. IGMP is not implemented because the IGMP protocol supports the multicast which is not implemented.

87

6 References [1] Herbert T, “The Linux TCP/ IP Stack: Networking for Embedded Systems”, CHARLES RIVER MEDIA, INC 10 Downer Avenue. Hingham, Massachusetts 02043 USA, ISBN: 158450-2843, 1st Edition, 2004. [2] http://searchnetworking.techtarget.com/sDefinition/0, sid7_gci212839, 00.html, 2005-1022 [3] Richrd J. Staron “Networking Complete”, Sybex Inc,1151 Mariana Village Parkway, Almeda, CA 94501,ISBN 0-7821-2914-5,2001. [4] http://en.wikipedia.org/wiki/OSI_model#Layer_1:_Physical_Layer,2006-07-12. [5] http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/introint.htm#xtocid16,200607-12. [6] http://en.wikipedia.org/wiki/OSI_model#Layer_6:_Presentation_Layer,2006-07-13. [7] Stevens W. R., “TCP/IP Illustrated Volume 1 the Protocol”, Addison Wesley Longman, Inc, ISBN 0-201-63346-9(v.1), February, 2000. [8] J. Romkey, “RFC1055 A Nonstandard for Transmission of IP Datagrams over Serial Lines”, June l988. [9] W. Simpson, “RFC1661 the Point- to- Point Protocol (PPP)”, July 1994. [10]

W. Simpson, “RFC1662 PPP in HDLC-like Framing”, July 1994.

[11]

Nagule Matthew G, “Illustrated TCP/IP” ISBN 0-471-19656-8, 1998.

[12]

http://www.rhyshaden.com/arp.htm, 2006-02-05.

[13]

Finlayson, Mann, Mogul, Theimer “RFC 903A Reverse Address Resolution Protocol”

Stanford University, June 1984. [14]

Norton’s .P. “Complete Guide to Networking”, SAMS 201West 103rd Street

Indianapolis, Indiana 46290 USA, ISBN0-672-31593-9, Second Edition, October 1999. [15]

http://www.netfor2.com/checksum.html, 2005-09-06

[16]

http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/ip.htm, 2005-10-22

[17]

Xilinx “Logic Core” Micro Blaze Risc 32-Bit Soft Processor, August 21, 2002.

[18]

J. Postel “RFC792 Internet Control message protocol”, September 1981.

[19]

W. Fenner “RFC 2236 Internet Group management Protocol”, November 1997.

[20] Postel .J. “RFC768User Datagram Protocol” Information Science Institute, 28 August 1980. [21] Dr.Feit .S. “TCP/IP (Computer network protocol)” McGraw-Hill, 11 West 19th Street, New York, NY 10011, ISBN 0-07-022069, 1998.

88

[22]

http://en.wikipedia.org/wiki/Udp, 2006-06-12.

[23] Andreas Löfgren, Lucas Lodesten, Stefan Sjöholm, Hans Hansson, “ analysis of FPGAbased UDP/IP stack parallelism for embedded Ethernet connectivity” ,Department of Computer Science and Electronics, Mälardalen University, Västerås, Sweden. [24] http://www.netfor2.com/checksum.html, 2005-09-06. [25] R. Braden, D. Borman, C. Partridge, “RFC 1071Computing the Internet Checksum” , September 1988. [26] R. Fielding, “RFC 2616 Hypertext Tranfer Protocol – HTTP1.1”, June 1999. [27] Jeffrey C.Mogul, The Case for Presistent-Connection HTTP, [email protected] [28] Singh .A, Konrad .A, and Joseph A.D, “Performance Evalution of UDP Lite for Cellular Video,” Workshop on Mobile Multimedia Communications for Digital Audio and Video, 1999. [29] Larzon et al, “The Light Weight User Datagram Protocol (UDP_Lite)”, RFC 3828, July 2004.Workshop on Mobile Multimedia Communications for Digital Audio and Video (), 1999. [30] Larzon .L.A, Degermark .M, Pink S, “UDP Lite for Real Time Multimedia Applications”, HP Laboratories HPL-IRI-1999-001, April, 1999. [31] http://www.protocols.com/pbook/tcpip2.htm, 2005-09-21. [32] http://fcit.usf.edu/network/chap2/chap2.htm, 2005-10-02. [33] http://www.javvin.com/protocol10GigE.html, 2005-10-04. [34] http://www.erg.abdn.ac.uk/users/gorry/course/inet-pages/arp.html, 2005-10-25. [35] OPB Ethernet Lite Media Access Controller (v1.01b), www.xilinx.com, DS441 November 10, 2004. [36] BROADCOM, BCM5221 PRODUCT BRIEF, 10/100BAS E-TX SINGLECHANNAEL SIGNI-PHY TRANSCEIVER. [37] http://www.lammertbies.nl/comm/cable/modular.html, 2005-10-08 [38] Richard S, Warnicke Ed, Lamping ULF, “Ethereal User Guide V2.0.2(16134) for Ethereal 0.10.12,2004-2005 [39] Memec Design, “P160 Communications Module User Guide” Version 2.0, December 2002 [40] Memec Design, “Virtex-IIV2MB1000 Development Kit user guide”, version 3, December 2002.

89

[41] Ethernet controller Xilinx Logic Core, “OPB Ethernet Lite Media Access Controller”, DS441 (v1.5) November 7, 2002. [42] http://www.xilinx.com/ipcenter/catalog/logicore/docs/microblaze_risc_32bit_proc_final. pdf, 2006-02-05. [43] J.Reynolds, “RFC 959 File Transfer Protocol”, October 1985. [44] Axelson j. “Embedded Ethernet and Internet Complete” Madison, WI, USA: Lakeview Research, ISBN 1931448, 2003. [45] http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/ethernet.pdf, 2006-02-05 [46] http://www.xilinx.com/ipcenter/catalog/logicore/docs/opb_ipif.pdf, 2006-02-05

90

7 Abbreviations/acronyms IP-Internet protocol ARP-Address resolution protocol RARP-reverse address resolution protocol ICMP-Internet control message protocol IGMP-Internet group management protocol TCP-Transmission control protocol UDP-User data protocol FTP-File transfer protocol TFTP-Trivial transfer protocol TTL-Time to live DoD-Department of defence RFC-Request for comments WrFIFO-Write FIFO RdFIFO-Read DMA-Direct memory access Bps-Bit per Second Kbps-Killo Bits per Second HTTP-Hypertext Transfer Protocol RRQ-Read Request WRQ-Write Request URI-Uniform Resource Identifier URL-Uniform Resource Locator HTRQ-Hypertext Request SMTP-Small Mail Transfer GIF-Graphics Interchange Format CSMA/CD PRE-Premeable Field SA-Source Adress MAC-Media Access Controller

91

8 Appendix The headers files are defined below. 8.1 Udp_header.h The Source port, destination port, length and checksum in this header consist of 16 bits in this header file. #ifndef UDP_HEAD_H #define UDP_HEAD_H typedef struct { unsigned int sport:16; unsigned int dport:16; unsigned int length:16; unsigned int checksum:16; } __attribute__((packed)) UDP_HEADER;

#endif 8.2 Assigned.h #ifndef ASSIGNED_H #define ASSIGNED_H /* rfc 1340 Assigned Internet Protocol Numbers Decimal ------0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

Keyword Protocol References ------- ----------------Reserved [JBP] ICMP Internet Control Message [97,JBP] IGMP Internet Group Management [43,JBP] GGP Gateway-to-Gateway [60,MB] IP IP in IP (encasulation) [JBP] ST Stream [49,JWF] TCP Transmission Control [106,JBP] UCL UCL [PK] EGP Exterior Gateway Protocol [123,DLM1] IGP any private interior gateway [JBP] BBN-RCC-MON BBN RCC Monitoring [SGC] NVP-II Network Voice Protocol [22,SC3] PUP PUP [8,XEROX] ARGUS ARGUS [RWS4] EMCON EMCON [BN7] XNET Cross Net Debugger [56,JFH2] CHAOS Chaos [NC3] UDP User Datagram [104,JBP] MUX Multiplexing [23,JBP] DCN-MEAS DCN Measurement Subsystems[DLM1]

92

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41-60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88

HMP Host Monitoring [59,RH6] PRM Packet Radio Measurement [ZSU] XNS-IDP XEROX NS IDP [133,XEROX] TRUNK-1 Trunk-1 [BWB6] TRUNK-2 Trunk-2 [BWB6] LEAF-1 Leaf-1 [BWB6] LEAF-2 Leaf-2 [BWB6] RDP Reliable Data Protocol [138,RH6] IRTP Internet Reliable Transaction [79,TXM] ISO-TP4 ISO Transport Protocol Class 4 [63,RC77] NETBLT Bulk Data TransferProtocol [20,DDC1] MFE-NSP MFE Network Services Protocol [124,BCH2] MERIT-INP MERIT Internodal Protocol [HWB] SEP Sequential Exchange Protocol [JC120] 3PC Third Party Connect Protocol [SAF3] IDPR Inter-Domain Policy Routing Protocol[MXS1] XTP XTP [GXC] DDP Datagram Delivery Protocol [WXC] IDPR-CMTP IDPR Control Message Transport Proto [MXS1] TP++ TP++ Transport Protocol [DXF] IL IL Transport Protocol [DXP2] Unassigned [JBP] any host internal protocol [JBP] CFTP CFTP [50,HCF2] any local network [JBP] SAT-EXPAK SATNET andBackroom EXPAK [SHB] KRYPTOLAN Kryptolan [PXL1] RVD MIT Remote Virtual Disk Protocol [MBG] IPPC Internet Pluribus Packet Core [SHB] any distributed file system [JBP] SAT-MON SATNET Monitoring [SHB] VISA VISA Protocol [GXT1] IPCV Internet Packet Core Utility [SHB] CPNX Computer Protocol Network Executive [DXM2] CPHB Computer Protocol Heart Beat [DXM2] WSN Wang Span Network [VXD] PVP Packet Video Protocol [SC3] BR-SAT-MON Backroom SATNET Monitoring [SHB] SUN-ND SUN ND PROTOCOL-Temporary [WM3] WB-MON WIDEBAND Monitoring [SHB] WB-EXPAK WIDEBAND EXPAK [SHB] ISO-IP ISO Internet Protocol [MTR] VMTP VMTP [DRC3] SECURE-VMTP SECURE-VMTP [DRC3] VINES VINES [BXH] TTP TTP [JXS] NSFNET-IGP NSFNET-IGP [HWB] DGP Dissimilar Gateway Protocol [74,ML109] TCF TCF [GAL5] IGRP IGRP [18,GXS] 93

89 90 91 92 93 94 95 96 97 98 99-254 255

OSPFIGP OSPFIGP [83,JTM4] Sprite-RPC Sprite RPC Protocol [143,BXW] LARP Locus Address Resolution Protocol [BXH] MTP Multicast Transport Protocol [SXA] AX.25 AX.25 Frames [BK29] IPIP IP-within-IP Encapsulation Protocol [JXI1] MICP Mobile Internetworking Control Pro. [JXI1] AES-SP3-D AES Security Protocol 3-D [HXH] ETHERIP Ethernet-within-IP Encapsulation [RXH1] ENCAP Encapsulation Header [148,RXB3] Unassigned [JBP] Reserved [JBP]

*/ #define IP_PROT_ICMP 0x01 #define IP_PROT_UDP 0x11 #define UDP_ECHO_PORT 7 #define TCP_WEB_PORT 80 #define IP_PROJECT_PORT 1001 #endif 8.3 Config.h #ifndef CONFIG_H #define CONFIG_H #define MAX_LINK_SIZE 512 #define MAX_INTERFACE 1 #define MAX_ARP 3 #define TCP_MAX_CONNECTIONS 4 #define DEBUG print /*(void) */ #define SEM_TCPIP 1 /*#define SLIP*/ #define ETH #define ICMP /*#define IP_PROJECT #define TCP_WEBSERVER*/ #define UDP

94

#define UDP_ECHO #define IPADDR (0xc0a8000b) /*192.168.00.11*/ #if 1 #define ntohs(x) x #define ntohl(x) x #define htons(x) x #define htonl(x) x #endif #endif 8.4 ICMP.h #ifndef ICMP_H #define ICMP_H 1 #include"link.h" int BTIcmpEval(link *data); #endif 8.5 IP.h #ifndef IP_H #define IP_H #include"link.h" int BTIPEval(link *data); int BTIPSend(char *data,int length,int offset,int type,int daddr); #define IP_OK 1 #define IP_ERROR_VERSION -1 #define IP_ERROR_IHL -2 #endif 8.6 ARP.h #ifndef ARP_H #define ARP_H #include"arp_header.h" #define ARP_REQ 1 #define ARP_RESP 2 #define RARP_REQ 3 #define RARP_RESP 4 int BTArpLkup(unsigned int addr,char *enet); void BTArpEval(ARP_PKT *data,char *sdata); void BTArpSend(char *ethaddr); #endif 95

8.7

Ethernet_Lite.h

#ifndef ETHERNET_LITE_H #define ETHERNET_LITE_H 1 #include "link.h" #define ETH_TYPE_IP 0x0800 #define ETH_TYPE_ARP 0x0806 #define ETH_TYPE_RARP 0x8035 int BTELInit(linkdata *data,int port); int BTELPoll(linkdata *data); int BTELSend(linkdata *data); void BTELSendData(char *daddr,char *saddr,char *data,unsigned short size,short type); extern char BTELaddr[6]; typedef struct { char daddr[6]; char saddr[6]; unsigned int type:16; char data[1500]; unsigned int length:16; char control; } __attribute__((packed)) ETHLITE_HEADER; #endif 8.8 Link.h #ifndef LINK_H #define LINK_H 1 #include"config.h" typedef struct{ char sbuff[MAX_LINK_SIZE]; char rbuff[MAX_LINK_SIZE]; int fd; unsigned int size; unsigned int offset; unsigned int link_offset; unsigned int ssize; } linkdata; typedef int (*pollfunc)(linkdata *data); typedef int (*sendfunc)(linkdata *data); typedef struct { linkdata data; pollfunc poll; sendfunc send; 96

unsigned long addr; unsigned long saddr; } link; extern link interface[MAX_INTERFACE]; extern int nrinterface; #endif 8.9

Slip.h

#ifndef SLIP_H #define SLIP_H 1 #include "link.h" #define SLIP_ESC (0xdb) #define SLIP_END (0xc0) #define SLIP_ESC_END (0xdc) #define SLIP_ESC_ESC (0xdd) int BTSlipInit(linkdata *data,int port); int BTSlipPoll(linkdata *data); int BTSlipSend(linkdata *data); #endif 8.10 UDP_state.h #ifndef SLIP_H #define SLIP_H 1 #include "link.h" #define SLIP_ESC (0xdb) #define SLIP_END (0xc0) #define SLIP_ESC_END (0xdc) #define SLIP_ESC_ESC (0xdd) int BTSlipInit(linkdata *data,int port); int BTSlipPoll(linkdata *data); int BTSlipSend(linkdata *data); #endif 8.11 CheckSum.h #ifndef CHECKSUM_H #define CHECKSUM_H unsigned short checksum(unsigned short *data, int len,long sum); #endif

97

98