1、Light-Weight IP (LwIP),LwIP Module Outline,A brief primer on TCP/IP and the BF536/7 EMACWhat is LwIP?How to use LwIP in VisualDSP+ and VDK configurationHow to trace and improve performanceSummary,A Brief Primer on the OSI, TCP/IP and BF537 EMAC,ApplicationProtocolTCP/IP StackEMAC Device DriverBF536/
2、7 EMACPHY Transceiver,Web Server, Ogg Vorbis, Contiki, Theora etc.HTTP, FTP, Telnet etc.lwIP, 3rd PartyEMAC core is providedSMSC LAN83C185, Realtek RTL8201, etc.,Layer 7 (Application)Layers 3, 4, 5 and 6 (Network, Transport, Session & Presentation)Layer 2 (Data Link)Layer 1 (Physical),TCP/IP Stack H
3、eader Structure,header structure,-,-,-,MAC Header,IP Header,TCP/UDP-Header,DATA,Trailer,data link layer,IP Header,TCP/UDP-Header,DATA,network layer,DATA,TCP-Header,DATA,transport layer,respectively,DATA,application layer,UDP-Header,TCP/IP Stack supports the transport and network layer,Application ru
4、ns on top of the TCP/IP Stack,ADSP-BF536/7 Ethernet MAC peripheral supports the data link layer,Data Encapsulation,Layer 1 - Physical,Consists of the physical and electrical interface to the network: PHY Transceiver, 10BASE-T connector, 100BASE-TX, switches, and routersPHY transceiver performs elect
5、rical signal conditioning for transmission over the medium: RJ45 cable4-wire MII and 2-wire RMII Management Interface allows layer 2 devices such as the BF536/7 EMAC to monitor and control PHY operation.,Blackfin Ethernet System Overview,Layer 2 Data Link,Enables functional and procedural aspects of
6、 network data transfer as well as physical layer error checkingTwo sub-layers on BF536/7 Blackfin processorsEMAC peripheral is Media Access Control (MAC)EMAC device driver is Logical Link Control (LLC),Layer 2 Data Link EMAC Device Driver,Configures / monitors the EMAC peripheral and DMA engine to h
7、andle the flow of Ethernet frames between memory buffers and the PHYOversees the following core functions: Ethernet address and frame filtering Chained DMA transfers Interrupt management Collision detection,Layers 3-6 TCP/IP,LwIP is included free with VisualDSP+ LwIP The Light-weight IP stack is a m
8、ulti-threaded TCP/IP implementation using VDK Compliant with the system services model Built into VisualDSP+ See www.sics.se/adam/lwip/ for further information Additional implementations are available from 3rd parties,Layer 7 Application,Contains the session protocol, high-level software application
9、 and user interfaceLwIP provides an API based on BSD sockets and runs under VDKExample applications running on the ADSP-BF537 EZ-KIT Lite: HTTP server HTTP client for streaming audio (Ogg Vorbis),LwIP Stack - Overall Structure,Consists of three major componentsTCP/IP library itselfInterface library
10、to the kernel that is being usedDriver library to connect the stack to the Ethernet controllerLwIP protocol suite runs under VDK,LwIP TCP/IP Stack,Kernel Interface,Library,Ethernet,Library,Application,BF537,EMAC,VDK,Folder Structure In VisualDSP+,TCP/IP STACK,Documentation based on html,Examples for
11、 ADSP-BF537,Host programs and Source Code for the examples,Source Code of the TCP/IP Stack,Driver for ADSP-BF537,LwIP Project Wizard,Generates VDK-based application which uses the stackCan generate an application for the BF537 EZ-KitProvides code needed to initialize and start the stack operatingIf
12、DHCP is being used, it will also wait until the IP address is obtained,Configuration Plug-In - General Tab,Displays the name of the associated configuration fileAllows you to specify the protocols to be supported by the build stackEliminating a protocol will reduce the size of the stackControls the
13、level of statistical data that the stack will accumulate,Configuration Plug-In - IP Tab,IP Forward allows forwarding of IP packets across network interfacesIP options allows for optional IP payload dataIP Fragmentation allows for segmenting of packets.IP Reassembly enables re-assembling of fragmente
14、d packetsSupport for multiple networks,Configuration Plug-In - Network Tab,Optional Static IP support for non-DHCP environmentConfigurable number of buffers to match expected loading on adapterSeparate configurations for multiple netowrks,Configuration Plug-In - TCP/UDP/ARP Tab,Configurable number o
15、f UDP and TCP connections Configurable number of open socket connectionsConfigurable maximum size of TCP segment supportedConfigurable maximum TCP receive window supportedConfigurable maximum number of address resolution mapping entries supported,Configuration Plugin - Debug Tab,Specify the level of
16、 debug checking and reporting the stack should provideSpecify which events the stack should provide,Configuration Plugin - Memory Tab,Configurable pool sizes Each frame stored in a linked list of pool buffers Setting pool buffer size too low increases processor overheads Setting pool buffer size too
17、 high increases memory overheadsConfigurable memory heap size used by stack for non-pool buffer memory requests,BSD Sockets Under LwIP,Good introduction to sockets is Beejs Guide to Network Programming http:/www.ecst.csuchico.edu/beej/guide/net/Core BSD Sockets functions socket() - get socket descri
18、ptor bind() - associate socket with a port on the local machine connect() - connect to a remote machine listen() - wait for someone to connect to the local machine accept() - acknowledge remote connection attempt and create a new descriptor send() - send data to remote machine recv() - receive data
19、from remote machine close() - close opened socket,Automatically Generated LwIP Application Template,Default boot thread that initializes LwIP stack and underlying Ethernet MAC and PHY drivers is in lwip_sysboot_threadtype.c (generated by the wizard),void lwip_sysboot_threadtype_RunFunction(void *inP
20、tr) . . ./ stack initialization. . ./* Add Application Code here */,Example Application,Retrieving data from an HTTP server is as easy as on a UNIX workstation,#define DEST_PORT 80 #define DEST_IP “192.168.0.2”char in_buffer100; int socket_fd; struct sockaddr_in dest_addr; char http_request = “GET /
21、index.htmlrnrn“; dest_addr.sin_family = AF_INET; dest_addr.sin_port = htons(DEST_PORT); dest_addr.sin_addr.s_addr = inet_addr(DEST_IP);socket_fd = socket(AF_INET, SOCK_STREAM, 0); / open a socketconnect(socket_fd, (struct sockaddr*),Tracing of TCP/IP Stack Activity,Windows application provided to ca
22、pture and display tracing informationConfigurable number of events to be saved in a circular bufferEvents displayed in real time unless display is pausedContents of trace buffer can be saved to a file or all events can be written to a file in real timeTracing currently only shows sent and received p
23、ackets,Support for File I/O Over TCP Connections,Sample application showing how to re-direct standard C/C+ I/O over TCP connectionsProvides source for a STDIO device driver to route I/O requests over TCP connectionsWindows server application is also provided to service requestsConsole output displayed in text boxNo user authentication supportedFile access can be restricted to part of the host system,