1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

Embedding TCP_IP Working Through Implementation Challenges

254 998 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 254
Dung lượng 7,36 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Device Drivers Physical hardwareTCP, UDP IP, ARP, ICMP PPP,SLIP, Ethernet User data Physical Devices AppHeader TCP Segment Application dataTCP Header Application dataTCP Header IPHeader

Trang 1

Embedding TCP/IP

Working Through Implementation Challenges

Micriµm

Trang 2

Renesas Technology & Solution Portfolio

Trang 3

Introduction : Objectives

Block 1 : What is a TCP/IP stack?

Block 2 : Embedded system requirements

Block 3 : LAN = Ethernet

Block 4 : ARP Operation

Block 5 : Hardware/Software setup

Block 6 : IPv4 Addressing

Block 7 : IPv6 Addressing

Block 8 : Troubleshooting connection

Agenda

Trang 4

 Learn to use TCP/IP properly from the start.

 Understand the requirements difference to perform IP

connectivity versus IP performance.

 Perform TCP/IP networking activities Record network traffic

and analyze results.

Trang 5

Block 1

What is a TCP/IP stack?

Trang 6

What is a TCP/IP stack?

The Internet Protocol suite—like many protocol suites—can be viewed as a set

of layers

Each layer solves a set of problems involving the transmission of data, and

provides a well-defined service to the upper layer protocols based on using

services from some lower layers

Upper layers are logically closer to the user and deal with more abstract data,

relying on lower layer protocols to translate data into forms that can

eventually be physically transmitted

It has also been referred to as the TCP/IP protocol suite, which is named after

two of the most important protocols in it: the Transmission Control Protocol

(TCP) and the Internet Protocol (IP), which were also the first two IP

networking protocols defined

Trang 7

1 Device Drivers Physical (hardware)

TCP, UDP

IP, ARP, ICMP

PPP,SLIP, Ethernet

User data

Physical Devices

AppHeader

TCP Segment

Application dataTCP

Header

Application dataTCP

Header

IPHeader

IP Datagram

14

Application data

420

20

46 to 1500 bytes

Transport Protocol Messages

Network-Specific Frames

User Data(Messages or Streams)

EthernetTrailer

TCPHeader

IPHeader

IP Datagrams

Layers in the Internet Protocol suite

EthernetHeader

User data

What is a TCP/IP stack?

Trang 8

Layered communication

Trang 9

TCP/IP Protocol Architecture

Protocol Family

Trang 10

The starting point

Implementing

TCP/IP

Understanding

TCP/IP

Trang 11

Block 2

Requirements

 Connectivity only Or

 Throughput?

Trang 12

CPU

Most embedded targets are slower consumers

when compared to laptop and desktop

computers.

Packets generated by a faster producer and

received by the target will consume most or all

NIC network buffers and some packets will be

dropped

Hardware features such as DMA and CPU speed

can improve this situation The latter is trivial,

the faster the target can receive and process the packets, the faster the network buffers can be

freed

Trang 13

Footprint

For connectivity, a TCP/IP stack or a subset of it

can be implemented with very few RAM

(approximately 32K)

For a few Megabits per second, a more complete

TCP/IP stack is required In this case, embedded system requirements dictate in the range of 96K

of RAM for a minimal sustained throughput

Resources need to be allocated to the protocol

stack so that it can perform its duties

Trang 14

Memory Usage Summary

of our setup

Other ROM / RAM Usage (cstartup, µC/CPU, CPU, µC/LCD, ) 7406 1120 1.63%

8 receive buffers

8 large transmit buffers

2 small transmit buffers

3 receive descriptors

8 transmit descriptors

Trang 16

Questions?

Trang 17

Block 3

LAN = Ethernet

Why Ethernet?

Because Ethernet is the ubiquitous LAN (Local Area Network)

Most of the world wide data initiates or terminates on an

Trang 19

Ethernet technology

Topology

1st Generation

Trang 20

Ethernet 802.3 Frame Structure

Trang 21

Unicast (point to point) 00-02-0C-4B-59-78 = unique station address

Traffic types

Trang 22

Broadcast (point to all-point) FF-FF-FF-FF-FF-FF = all stations group address

Traffic types

Trang 23

Multicast (point to a group) 01-80-C2-00-00-01 = spanning tree group address

Traffic types

Trang 24

Network buffers

A TCP-IP stack network buffer includes the Ethernet frame and

metadata to manage the buffer.

Network Buffer

Typically 1518 (1520 for alignment)

A TCP/IP stack places received packets in network buffers to be processed by the upper

protocol layers and also places data to send in network buffers for transmission Network

buffers are data structure defined in RAM

The data portion of the network buffer contains the application data and protocol headers

Trang 25

– The software that interfaces between the TCP/IP stack and

the Ethernet controller

 Could be complex depending on the Ethernet controller (1000-3000 lines)

– Has dedicated memory

– Uses main memory

– Ethernet packets need to be transferred to these network

buffers

– Either copied by the CPU or through a DMA controller

Trang 26

Ethernet Controller Interface

When a packet is received by the MAC, a

DMA transfer from the MAC’s internal buffer

is initiated by the MAC into main memory

This method generally provides for

shortened development time and excellent

performance.

Trang 27

Ethernet Controller Interface

CPU with an internal MAC

but with dedicated memory.

When a packet is received, the MAC initiates

a DMA transfer into dedicated memory

Generally, most configurations this type

allow for transmission from main memory

while reserving dedicated memory for either

receive or transmit operations Both the

MAC and the CPU can read and write from

dedicated memory and thus the stack can

process packets directly from dedicated

memory

Porting to this architecture is generally not

difficult and provides for excellent

performance However, performance may

be limited by the size of the dedicated

memory; especially in cases where transmit

and receive operations share the dedicated

memory space.

DMA

Trang 28

Ethernet Controller Interface

Ethernet Controller

Internal FIFO

& Memory DMA

CPU

TCP/IP

Main Memory

Cooperative DMA solution where both

the CPU and MAC take part in the

DMA operation.

This configuration is generally found on

external devices that are either connected

directly to the processor bus or connected via

the ISA or PCI standard This method

requires that the CPU contain a DMA

peripheral that can be configured to work

within the architectural limitations of the

external device This method is more difficult

to port to, but generally offers excellent

performance.

Trang 29

Ethernet Controller Interface

Data is moved to and from main memory and

the external device’s internal memory via bus

read and write cycles The amount of data

transferred in a given bus operation depends

on the width of the data bus This method

requires additional CPU intervention in order to

copy all of the data to and from the device

when necessary This method is generally

easy to port and offers average performance Parallel I/O (Non DMA)

Trang 30

CPU_REG32 Status CPU_REG32 Addr

CPU_REG32 Status CPU_REG32 Addr

CPU_REG32 Status CPU_REG32 Addr

.

DMA Descriptors Descriptor List DMA

Data

Register

Software Hardware

BufDescPtrStart

Int Ptr (BufDescPtrStart + i) % n

Step 4 With each new received frame, software increments BufDescPtrCur by 1 and wraps around the descriptor list as necessary; hardware applies the same logic to an internal descriptor pointer.

Step 1 Software allocates receive buffers.

Step 2 Software allocates a list of buffer descriptors and configures each address field to point to the start address of a receive buffer.

Step 3 Software initializes three pointers One to track the current descriptor which is expected to contain the next received frame, and two, to remember the

descriptor list boundaries Hardware is informed of the descriptor list starting address.

Step 5 When a received frame is processed, software obtains a pointer to a new data buffer and updates the current descriptor address field The previous buffer address is passed to the protocol stack for processing If

a buffer pointer cannot be obtained, the existing pointer remains in place and the frame is dropped.

DMA

Descriptors and Buffers

Trang 31

Zero Copy

A true zero copy architecture - negating the need for

performance reducing memory buffer moves

Zero copy networking enables the network adapter to transfer data directly to or from application memory, eliminating the need to copy data between application memory and the data buffers in the operating system

Trang 32

(2,048) 204.8

(4,883) 20.4

(48,828) 2.04

(488,281) 1024

(8,192) 819.2

(1,221) 81.9

(12,207) 8.19

(122,070) 1518

(12,144) 1,214

(823) 121.4

(8,234) 12.14

(82,345)

– Depends on many factors:

 Data is moved between the controller and the main memory using DMA?

 The CPU needs to be capable of processing all the data

 Can the CPU produce or consume the data at this rate?

 Amount of memory available for the TCP/IP stack

Trang 33

IEEE 1588

Timestamping in the Application Layer

PTP UDP IP MAC PHY

PTP UDP IP MAC PHY

T S

T S

Milliseconds introduced by router processing

Milliseconds

of delay variation introduced

by protocol stack

processing delays

Trang 34

IEEE 1588

Timestamping in the Ethernet Driver

PTP UDP IP MAC PHY

PTP UDP IP MAC PHY

T S

T S

Network jitter remains

Other techniques must be used to reduce this effect.

…8:40

Trang 35

IEEE 1588

IEEE 1588 PTP_TSYNC Engine

TCP/IP stack

IEEE 1588 PTP protocol

stack

Software Hardware

External

• The IEEE 1588 PTP protocol stack is shown operating at the Application layer

Trang 36

Embedded systems typical usage

WiFi Hardware

SPI Interface

Wifi Radio and Firmware

Handler

TxRx Handler

WiFi Driver

Application Task

WiFi Task

Trang 38

Block 4

ARP Operation

ARP allows us to associate a layer 3 address (like IP) with a

layer 2 address (for example Ethernet) of different lengths.

Trang 39

Station 172.16.10.5 sends a ping request (ICMP) to the station

172.16.10.8.

ARP Operation

172.16.10.5 pinging 172.16.10.8

Trang 40

The IP module asks the ARP module to supply it with the MAC address (Layer 2).

The ARP module consults its table The desired IP address is not in the table.

ARP Operation

172.16.10.5 pinging 172.16.10.8

Trang 41

The ARP module sends a packet «ARP request» to the Ethernet module who will send it to everyone («broadcast»).

ARP Operation

172.16.10.5 pinging 172.16.10.8

Trang 42

The Ethernet module of the station 172.16.10.8 receives the Ethernet frame and realizes that it is a «ARP request».

The request is sent to the ARP module.

ARP Operation

172.16.10.5 pinging 172.16.10.8

Trang 43

The ARP module acknowledges the request and replies back with an

answer («ARP reply») to the Ethernet module.

ARP Operation

172.16.10.5 pinging 172.16.10.8

Trang 44

The Ethernet module passes the reply to the ARP module.

The ARP module forwards the missing information to the IP module as well as keeping the information in the ARP cache.

ARP Operation

172.16.10.5 pinging 172.16.10.8

Trang 45

The IP module can now send the information to the station with the IP address of 172.16.10.8 and the Ethernet address of 12:4a:07:12:b9:c0.

ARP Operation

172.16.10.5 pinging 172.16.10.8

Trang 46

ARP Header

The ARP header is found at the beginning of each ARP packet.

The header contains fields of fixed length.

Each field has a specific role to play

Trang 47

ARP Header

Hardware Specifies the type of hardware address (1 specifies Ethernet)

Protocol Represents the type of protocol addressing used (IP = 0x0800)

HLen Length of the physical address in bytes, Ethernet = 6

PLen Length of the protocol address in bytes, IP = 4

Operation Four values are possible

Sender Hardware Sender physical address

The possible values for the Operation field are :

 1 : ARP request

 2 : ARP reply

 3 : RARP request

 4 : RARP reply

Trang 49

Renesas Demonstration Kit YRDKRX63N

Trang 50

Network set-up

Trang 51

Windows PC (software tools)

 Renesas Eclipse Embedded Studio (e 2 Studio)

 KPIT Cummins GNURX Tool Chain

 Command prompt (ping and other utilities)

 Wireshark, Network Protocol Analyzer

 TeraTerm Pro, Terminal emulation

 IPerf, benchmarking tool for measuring TCP and UDP

Trang 53

Micriµm µC/TCP-IP

uC/TCP-IP is a compact, reliable, high performance TCP/IP

protocol stack Built from the ground up with Micrium's

renowned quality, scalability and reliability,

µC/TCP-IP was designed specifically for the specific

requirements of embedded systems

Trang 54

Network Protocol Analyzer

Wireshark

Trang 55

IPerf (IP performance)

Benchmarking Tool for measuring TCP and UDP Performance

IPerf was developed by The National Laboratory for Applied

Network Research (NLANR) as a means to measure maximum TCP

and UDP bandwidth performance

IPerf is open source software written in C++ that runs on various

platforms including Linux, Unix and Windows.

The source code can be found on Sourceforge:

http://iperf.sourceforge.net/

Trang 56

Kperf Settings

On the PC side, Micriμm uses Kperf because of its ease of use

Download Kperf from the Micriμm site at:

www.micrium.com/page/downloads/uc-tcp-ip_files.

Trang 57

Kperf Bandwidth Graph

Trang 60

Questions?

Trang 61

Lab 1

ARP & Packet Capture using Ping

Trang 62

Lab set-up

Trang 63

Renesas e Studio : Opening Workspace

Find the Renesas e 2 Studio shortcut and run the application

Select the e 2 Studio workspace located at:

C:\Workspcae\9L06I_Micrium_TCPIP

Trang 64

Renesas e Studio : Toolchain integration

This project uses the GNURX compiler.

Click Cancel on this screen.

Trang 65

Renesas e Studio : Selecting Project

uC_OS_III_TCPIP_HTTPs_IPerf

Left click

to expand

Trang 66

Renesas e Studio : Iperf+HTTPs Project

µC/OS-III source code

µC/TCP-IP library headers

µC/IPerf source code

CPU, LIB, TCP-IP & HTTP Server binary libraries

Trang 67

Renesas e Studio : Configuring Application

Open app.c to edit the static IP configuration

Update the IP address, Subnet Mask and

Default Gateway according to your Locate the function

App_TCP_Init()

Trang 68

Renesas e Studio : Building project

Build Project Right click over the name of the project

Trang 69

Renesas e Studio : Downloading code to target

Click Download and Debug

Select

Binary

file

Trang 70

Renesas e Studio : Running code

Start running

to main() i.e initialize

Trang 71

Renesas e Studio : Running code

Start running from main()

Trang 72

Code running

Code is running when LED7 to LED12 are blinking sequentially

Trang 73

Configuring the PC

Static IP settings

Right Click

Trang 74

PC static IP settings

Then click OK to close all the screens

Trang 75

Find the Wireshark shortcut and run the application

1- Select the wired Ethernet interface to use 2- For the first capture, click on “Capture Options”

Trang 76

Configuration

Name Resolution

Trang 77

Configuration

Name Resolution:

Display complete

address and port

numbers (not aliases)

Trang 79

Configuration

We can also define

Capture Filters

Trang 80

Configuration

Or Display Filters

Trang 81

Protocol selection

Selected protocols for the

Trang 82

Let’s generate a few packets of traffic using

the PING DOS command to validate our lab

set-up and tools installation

Trang 83

Open a Command Prompt window

Find the Command Prompt shortcut and run the application

If the shortcut is not on your desktop, the next slides show you how to launch it

Trang 84

Command Prompt using the search box

Click Start button

Enter “cmd” and Enter

or Click OK Click Run

Trang 85

Command Prompt using the Start menu

1 Select the

accessories folder

2 Select Command

Prompt

Trang 86

Using PING to create network traffic

Trang 87

Wireshark

Packet Capture

Trang 88

Stop capture

Trang 89

PC ARP cache

List

Delete

Trang 90

Stopping execution

Stop Debugging

Trang 91

Analyzing the packet capture

Trang 93

IP Characteristics

IP does not offer :

 Connections or logical circuits

 Datagram acknowledgements

 Flow control

 Data error checking

 Retransmission of lost datagrams

Trang 94

IP Characteristics

Transports information in the form of packets.

Fragments and reassembles packets that are too big.

Finds the destination of the packets.

… to create one whole entity, therefore one unique homogenous

network.

Servers

Client stations

IP

Ngày đăng: 22/06/2015, 14:05

TỪ KHÓA LIÊN QUAN