embedding tcp/ip working through … is a tcp/ip stack? the internet protocol suite—like many...

254
Renesas Electronics America Inc. © 2012 Renesas Electronics America Inc. All rights reserved. Embedding TCP/IP Working Through Implementation Challenges Micriμm

Upload: truongthu

Post on 05-Jul-2018

234 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Embedding TCP/IP Working Through … 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

Renesas Electronics America Inc.© 2012 Renesas Electronics America Inc. All rights reserved.

Embedding TCP/IPWorking Through Implementation Challenges

Micriµm

Page 2: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.2 Micriµm

Renesas Technology & Solution Portfolio

Page 3: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.3 Micriµm

Introduction : ObjectivesBlock 1 : What is a TCP/IP stack?Block 2 : Embedded system requirementsBlock 3 : LAN = EthernetBlock 4 : ARP OperationBlock 5 : Hardware/Software setupBlock 6 : IPv4 AddressingBlock 7 : IPv6 AddressingBlock 8 : Troubleshooting connectionBlock 9 : Transport protocols Block 10 : Network services and application

Agenda

Page 4: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.4 Micriµm

Objectives

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.

Page 5: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.5 MicriµmMicriµm

Block 1What is a TCP/IP stack?

Page 6: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.6 Micriµm

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.

Page 7: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.7 Micriµm

1. Device Drivers

Physical (hardware)

2. Network Access

3. Internet

5-6-7. Application

4. Transport

Telnet, FTP, TFTP, HTTP, BOOTP, DHCP, SNMP

Socket API

TCP, UDP

IP, ARP, ICMP

PPP,SLIP, Ethernet

User data

Physical Devices

AppHeader

TCP Segment

Application dataTCPHeader

Application dataTCPHeader

IPHeader

IP Datagram

14

Application data

4202046 to 1500 bytes

Ethernet Frame

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?

The TCP/IP reference model consists of four layers plus the physical layer.

Page 8: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.8 Micriµm

Layered communication

Page 9: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.9 Micriµm

TCP/IP Protocol ArchitectureProtocol Family

Page 10: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.10 Micriµm

The starting point

1. Device DriversPhysical (hardware)

2. Network Access

3. Internet

5-6-7. Application

4. Transport

Telnet, FTP, TFTP, HTTP, BOOTP, DHCP, SNMP

Socket API

TCP, UDP

IP, ARP, ICMP

PPP,SLIP, Ethernet

Physical Devices Ethernet

Applications and services

Implementing TCP/IP

Understanding TCP/IP

Page 11: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.11 MicriµmMicriµm

Block 2Requirements

Performance Connectivity onlyOr Throughput?

Page 12: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.12 Micriµm

PerformanceCPU

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.

Page 13: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.13 Micriµm

RequirementsFootprint

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.

Page 14: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.14 Micriµm

Memory Usage Summaryof our setup

Module ROM Bytes RAM Bytes RAM %

Estimated µC/LIB ROM / RAM Usage 5380 0 0.00%

Estimated TCP-IP ROM / RAM Usage 106779 41976 61.03%

Estimated RTOS ROM / RAM Usage 29114 9852 14.32%

Estimated Probe ROM / RAM Usage 6231 5684 8.26%

Estimated HTTPs ROM / RAM Usage 7121 8756 12.73%

Estimated µC/CPU ROM / RAM Usage 1104 58 0.08%

Estimated App + BSP Code ROM / RAM Usage 9905 1338 1.95%

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

Total Code 173040Total RAM Data 68784

8 receive buffers8 large transmit buffers2 small transmit buffers

3 receive descriptors 8 transmit descriptors

Page 15: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.15 Micriµm

RequirementsProtocols and services

Optional protocols:IGMPICMPTCP Congestion controlTCP keepaliveTCPIP fragmentation

Page 16: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.16 MicriµmMicriµm

Questions?

Page 17: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.17 MicriµmMicriµm

Block 3LAN = Ethernet

Why Ethernet?Because Ethernet is the ubiquitous LAN (Local Area Network)

Most of the world wide data initiates or terminates on an Ethernet port (>99%).

Embedded systems sometimes use serial links (SLIP, PPP or PPPoE)

Page 18: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.18 Micriµm

Ethernet technology

Regardless of the speed, the following aspects are always the same : Frame format Access method

SPEED STANDARD

10 MBPS IEEE 802.3

100 MBPS IEEE 802.3u

1000 MBPS IEEE 802.3z

10,000 MBPS IEEE 802.3ae

Supports various speed :

Page 19: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.19 Micriµm

Ethernet technology

Topology

1st Generation

Today

Page 20: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.20 Micriµm

Ethernet 802.3 Frame Structure802.3 frame format

PRE PreambleSFD Start Frame DelimiterDA Destination addressSA Source address

LEN LengthDATA ….PAD PaddingFCS Frame check sequence

Page 21: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.21 Micriµm

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

Traffic types

Page 22: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.22 Micriµm

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

Traffic types

Page 23: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.23 Micriµm

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

Traffic types

Page 24: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.24 Micriµm

Network buffers

A TCP-IP stack network buffer includes the Ethernet frame and metadata to manage the buffer.

Header Ethernet Frame

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.

Page 25: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.25 Micriµm

Drivers

Ethernet controllers require ‘drivers’– The software that interfaces between the TCP/IP stack and

the Ethernet controller Could be complex depending on the Ethernet controller

(1000-3000 lines) Two most popular Ethernet controller types

– Has dedicated memory– Uses main memory

TCP/IP uses main memory for ‘network buffer’– Ethernet packets need to be transferred to these network

buffers– Either copied by the CPU or through a DMA controller

Page 26: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.26 Micriµm

Ethernet Controller Interface

CPU

Ethernet Controller

TCP/IP

Main Memory

CPU with an internal Media Access Controller (MAC).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.

Page 27: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.27 Micriµm

Ethernet Controller Interface

CPU

Ethernet Controller

TCP/IP

Main Memory

Dedicated Memory

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

Page 28: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.28 Micriµm

Ethernet Controller Interface

Ethernet Controller

Internal FIFO & Memory

DMA

CPUTCP/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.

Page 29: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.29 Micriµm

Ethernet Controller Interface

Ethernet Controller

Internal FIFO & Memory

CPUTCP/IP

Main Memory

External device attached via the CPU’s external bus.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)

Page 30: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.30 Micriµm

CPU_REG32 StatusCPU_REG32 Addr

CPU_REG32 StatusCPU_REG32 Addr

CPU_REG32 StatusCPU_REG32 Addr

.

.

.

DMA Descriptors

DMA Descriptor List

BufDescPtrStart

BufDescPtrCur

BufDescPtrEnd

0x00 0x50 0xC20x25 0x60 0x02

.

.

.

DataBuffers

Circular DMA Descriptor List

DescriptorPointers

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.

DMADescriptors and Buffers

Page 31: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.31 Micriµm

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.

Page 32: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.32 Micriµm

Line Rateand Packet Processing

Bytes/packet(Bits/packet)

10 Mbpsµsec/packet(packets/sec)

100 Mbpsµsec/packet(packets/sec)

1000 Mbps

µsec/packet(packets/sec)

64(512)

51.2(19,531)

5.12(195,312)

0.512(1,953,125)

256(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)

Can the processor produce/consume data at line rate?– 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

Page 33: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.33 Micriµm

IEEE 1588Timestamping in the Application Layer

PTP

UDP

IP

MAC

PHY

PTP

UDP

IP

MAC

PHY

Master Clock Slave Clock

It is 8:40Ok, thanks.

8:40

TS

TS

TS Timestamp

It is 8:40PTP packet

Milliseconds of delay variation introduced by protocol stack processing delays

Hundreds of nanoseconds to microseconds of variation introduced by network equipment processing

Milliseconds introduced by router processing

Milliseconds of delay variation introduced by protocol stack processing delays

Jitter = Delay variation

Page 34: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.34 Micriµm

IEEE 1588Timestamping in the Ethernet Driver

PTP

UDP

IP

MAC

PHY

PTP

UDP

IP

MAC

PHY

Master Clock Slave Clock

It is …Ok, thanks.

8:40

TS

TS

TS TimestampIt is 8:40PTP packet

Hardware timestamp removes the effect of protocol stack jitter

Hardware timestamp removes the effect of protocol stack jitter

Network jitter remains. Other techniques must be used to reduce this effect.

…8:40

Page 35: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.35 Micriµm

IEEE 1588

PHY MII MAC

IEEE 1588PTP_TSYNC

Engine

TCP/IP stack

IEEE 1588 PTP protocol

stack

SoftwareHardwareExternal

• The IEEE 1588 PTP protocol stack is shown operating at the Application layer (IEEE 1588 calls it layer 4 mode). It can also operate at the MAC layer (layer 2).• The stack can also be implemented in software only, without the physical timestamp.

Page 36: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.36 Micriµm

WiFiEmbedded systems typical usage

WiFi Hardware

SPI Interface

Wifi Radio and Firmware

Target

TCP/UDP

IP

IF

TCP/IP

Sockets

TCP/IP Driver SPI Driver

Ext. Interrupt Driver

Handler

TxRxHandler

WiFi Driver

Application Task

WiFiTask

Page 37: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.37 Micriµm

WiFi

System Services

Interrupt and SPI Driver

WiFi Driver

Link Managem

ent TCP/IP Stack

User Applications

Page 38: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.38 MicriµmMicriµm

Block 4ARP Operation

ARP allows us to associate a layer 3 address (like IP) with a layer 2 address (for example Ethernet) of different lengths.

Page 39: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.39 Micriµm

The ICMP sends the command to the IP module.

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

ARP Operation172.16.10.5 pinging 172.16.10.8

Page 40: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.40 Micriµm

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 Operation172.16.10.5 pinging 172.16.10.8

Page 41: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.41 Micriµm

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

ARP Operation172.16.10.5 pinging 172.16.10.8

Page 42: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.42 Micriµm

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 Operation172.16.10.5 pinging 172.16.10.8

Page 43: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.43 Micriµm

The ARP module acknowledges the request and replies back with an answer («ARP reply») to the Ethernet module.

The response is sent in a Ethernet frame to the the station with the IP address172.16.10.5.

ARP Operation172.16.10.5 pinging 172.16.10.8

Page 44: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.44 Micriµm

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 Operation172.16.10.5 pinging 172.16.10.8

Page 45: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.45 Micriµm

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 Operation172.16.10.5 pinging 172.16.10.8

Page 46: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.46 Micriµm

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.

Page 47: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.47 Micriµm

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

Target Hardware Target hardware address (normally FF:FF:FF:FF:FF:FF)

Sender IP Sender IP address

Target IP Target IP address

The possible values for the Operation field are :

1 : ARP request 2 : ARP reply 3 : RARP request 4 : RARP reply

Page 48: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.48 MicriµmMicriµm

Block 5Setup

Renesas YRDKRX63N RS-232 terminal port J-Link on board

Directly connected Ethernet LAN Software tools

Page 49: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.49 Micriµm

Renesas Demonstration Kit YRDKRX63N

Page 50: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.50 Micriµm

Network set-up

Page 51: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.51 Micriµm

Windows PC (software tools)

Renesas Eclipse Embedded Studio (e2Studio)

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 performance

Page 52: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.52 Micriµm

Software Development

RenesasEclipse Embedded Studio e2 Studio http://www.renesas.com/e2studio Registration required

+KPIT CumminsGNURX Windows Tool Chain (ELF) http://www.kpitgnutools.com Registration required

Page 53: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.53 Micriµm

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'srenowned quality, scalability and reliability,

µC/TCP-IP was designed specifically for the specific requirements of embedded systems.

Page 54: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.54 Micriµm

Network Protocol AnalyzerWireshark

http://www.wireshark.org/

Page 55: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.55 Micriµm

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/

Page 56: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.56 Micriµm

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.

Page 57: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.57 Micriµm

Kperf Bandwidth Graph

Page 58: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.58 Micriµm

µC/IPerf

Micriμm ported IPerf source code to μC/TCP-IP and created a module in C called μC/IPerf.

It uses an RS-232 interface for Terminal I/O.

Page 59: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.59 Micriµm

µC/IPerf

Client modeiperf –c xxx.xxx.xxx.xxx

Server modeiperf -s

Page 60: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.60 MicriµmMicriµm

Questions?

Page 61: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.61 Micriµm

Lab 1ARP & Packet Capture using Ping

Page 62: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.62 Micriµm

Lab set-up

Page 63: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.63 Micriµm

Renesas e2 Studio : Opening Workspace

Find the Renesas e2 Studio shortcut and run the application

Select the e2 Studio workspace located at:C:\Workspcae\9L06I_Micrium_TCPIP

Page 64: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.64 Micriµm

Renesas e2 Studio : Toolchain integration

This project uses the GNURX compiler.Click Cancel on this screen.

Page 65: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.65 Micriµm

Renesas e2 Studio : Selecting ProjectuC_OS_III_TCPIP_HTTPs_IPerf

Left clickto expand

Page 66: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.66 Micriµm

Renesas e2 Studio : Iperf+HTTPs Project

Application code for this example.

Board Support Package

RX63Nhardware initialization code

µC/CPU specific for the RX63N

µC/OS-IIIport code

µC/OS-III source code

µC/TCP-IP library headers

µC/IPerfsource code

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

Page 67: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.67 Micriµm

Renesas e2 Studio : Configuring Application

Open app.c toedit the static IP configuration

Update the IP address, Subnet Mask and Default Gatewayaccording to yournetwork setup

Locate the functionApp_TCP_Init()

Page 68: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.68 Micriµm

Renesas e2 Studio : Building project

Build Project

Right click over the name of the project

Page 69: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.69 Micriµm

Renesas e2 Studio : Downloading code to target

ClickDownload and Debug

SelectBinaryfile

Page 70: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.70 Micriµm

Renesas e2 Studio : Running code

Start running to main()i.e. initialize

Page 71: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.71 Micriµm

Renesas e2 Studio : Running code

Start running from main()

Page 72: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.72 Micriµm

Code running

Code is running when LED7 to LED12 are blinking sequentially

Page 73: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.73 Micriµm

Configuring the PCStatic IP settings

Right Click

Page 74: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.74 Micriµm

PC static IP settings

Then click OK to close all the screens

Page 75: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.75 Micriµm

Wireshark

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”

Page 76: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.76 Micriµm

WiresharkConfiguration

Name Resolution

Page 77: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.77 Micriµm

WiresharkConfiguration

Name Resolution:

Display complete address and port numbers (not aliases)

Page 78: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.78 Micriµm

WiresharkCapture

78

Packet List

Packet Details

Packet Bytes

Display filtersCapture filters

Page 79: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.79 Micriµm

WiresharkConfiguration

We can also define Capture Filters

Page 80: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.80 Micriµm

WiresharkConfiguration

Or Display Filters

Page 81: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.81 Micriµm

WiresharkProtocol selection

Selected protocols for the exercises:

ARP – IP – ICMP – TCP – UDP

Page 82: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.82 Micriµm

Traffic

Let’s generate a few packets of traffic using the PING DOS command to validate our lab set-up and tools installation

Page 83: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.83 Micriµm

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

Page 84: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.84 Micriµm

Command Prompt using the search box

Click Start buttonEnter “cmd” and Enter or Click OK

Click Run

Page 85: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.85 Micriµm

Command Prompt using the Start menu

1. Select the accessories folder

2. Select Command Prompt

Page 86: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.86 Micriµm

Using PING to create network traffic

Page 87: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.87 Micriµm

Wireshark Packet Capture

Page 88: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.88 Micriµm

WiresharkStop capture

Page 89: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.89 Micriµm

PC ARP cache

List

Delete

Page 90: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.90 Micriµm

Stopping execution

Stop Debugging

Page 91: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.91 Micriµm

Analyzing the packet capture

ARP Ethernet

PING IP ICMP

– Type– Sequence number– Payload

Page 92: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.92 MicriµmMicriµm

Block 6IPv4 Addressing

IP address Subnets Public versus private

Page 93: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.93 Micriµm

IP Characteristics

IP does not offer :

Connections or logical circuits Datagram acknowledgements Flow control Data error checking Retransmission of lost datagrams

Page 94: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.94 Micriµm

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

Page 95: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.95 Micriµm

IP version 4 Header Description

Page 96: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.96 Micriµm

Viewing the IP Configuration

Windows ipconfigLinux ifconfig

Page 97: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.97 Micriµm

IP Address Definition

141.138.88.161

141.138.163.5

141.138.40.11141.138.2.1

141.138.70.11

Byte #

Page 98: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.98 Micriµm

Ethernet

Unicast (point to point)

IP address types

Page 99: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.99 Micriµm

Ethernet

Multicast (point to multipoint)

IP address types

99

Page 100: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.100 Micriµm

Ethernet

Broadcast (point to all points)

IP address types

100

Page 101: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.101 Micriµm

IP Address Classes

Net ID (#bytes)

Host ID (#bytes)

Class A 1 3

Class B 2 2

Class C 3 1

Page 102: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.102 Micriµm

•• 0.0.0.0 -The network the station is connected to- Also the default route

•• The network numbers–– N.0.0.0 The network N of the class A network –– N.N.0.0 The network N.N of the class B network–– N.N.N.0 The network N.N.N of the class C network••

The broadcast addresses –– N.255.255.255 « broadcast » on network N–– N.N.255.255–– N.N.N.255–– 255.255.255.255••

127.x.x.x «Loopback address »

« broadcast » on network N.N« broadcast » on network N.N.N« broadcast » limited to this network

IP Reserved Addresses

Page 103: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.103 Micriµm

IP Reserved Private Addresses

Private addresses for internal usage:

Class A : 10.0.0.0 Class B : 172.16.0.0 to 172.31.0.0 Class C : 192.168.0.0 to 192.168.255.0

Page 104: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.104 Micriµm

Network Mask configuration

Number of Net ID bits

Number of Host ID bits

Network Mask

Class A 1 3 255.0.0.0

Class B 2 2 255.255.0.0

Class C 3 1 255.255.255.0

Page 105: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.105 Micriµm

Network Mask usage

Page 106: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.106 Micriµm

Subnetworking

Subnetworking consists of breaking up a block of addresses into multiple blocks of smaller size. Example :

• with a subnet mask of 255.255.255.0, • a class B network is divided up in 256 blocks,• each containing 256 addresses.

Page 107: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.107 Micriµm

Subnetworking

Page 108: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.108 Micriµm

IP version 4 Address Architecture

IP version 4 was designed with an addressing structure by classes– The addressing bits are subdivided between the hosts and the networks.

IP version 4 addressing is non hierarchical. It does not allow to representmany subnet addresses by only one higher level address

– A hierarchical addressing scheme works like the telephone network numbering plan(country code , area code , etc.)

Page 109: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.109 Micriµm

IP Address Definition

Network NetworkAddress

Host Address

Default Gateway (Router

Address)

A 10.0.0.0 10.0.0.310.0.0.4

10.0.0.1

B 15.0.0.0 NA 15.0.0.115.0.0.2

C 17.0.0.0 17.0.0.317.0.0.4

17.0.0.1

Page 110: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.110 Micriµm

Routing Information

For the configuration of an IP stack to be complete, we need the following values:

An IP address A network mask (or subnet mask) And a default gateway

Page 111: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.111 Micriµm

IP Packets Routing

The function of the routing process is to select a route among one or several possible routes, along which the data will travel between the source and the destination, moving from hop to hop.

Page 112: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.112 Micriµm

IP HeaderIDENTIFICATION

Page 113: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.113 Micriµm

Viewing the routing information

Route Print

Page 114: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.114 Micriµm

Gateway Setup

Page 115: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.115 Micriµm

SubnetworkingDestination address resolution

Using the Gateway set-up, where will a packet go, if sent by the Host to a Server on the Internet?

Host IP address : 10. 10. 1.128Host Subnet mask : 255.255.255. 0Default Gateway address : 10. 10. 1. 1Destination address : 169.142. 6. 32

Destination address : 169.142. 6. 32Host Subnet mask : 255.255.255. 0Network : 169.142. 6. 0

Host address : 10. 10. 1.128Host Subnet mask : 255.255.255. 0Host network : 10. 10. 1. 0

Is the destination address in my network?NO

Where do I send it to? My Default Gateway!

IP packet header

Source address 10. 10. 1.128

Destination address 169.142. 6. 32

Is my Default Gateway on my network? YES

What is my Default Gateway MAC address? Let’s ARP if it is not already in the ARP cache!

1

2

5

6

3

4

Page 116: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.116 Micriµm

Network Address Translation

Page 117: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.117 Micriµm

Port Address Translation

Page 118: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.118 MicriµmMicriµm

Questions?

Page 119: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.119 MicriµmMicriµm

Block 7Why IP version 6?

Shortage of public IPv4 addresses Routing tables size Simplified configuration Increased security QoS and real-time services Mobility mechanisms Multimedia and multicast

Page 120: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.120 Micriµm

IP version 6 Header Description

Simplified header format :–Fix 40 bytes header length.–Reduce packet processing cost in routers.

Page 121: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.121 Micriµm

IPv6 address scope

Addresses are assigned to interfaces No change from IPv4 Model Interface ‘expected’ to have multiple addresses

Addresses have scope Link Local Site Local Global Global Site-local Link-local

Hierarchical Routing and improved addressing :– 128 bits addresses instead of 32 bits. (~3,4 * 1038)– 340,282,366,920,938,463,463,374,607,431,768,211,456

totally! – 1030 addresses par individual on the planet!

Page 122: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.122 Micriµm

Auto-configurationStatefull or Stateless

Router

HostStateless Router solicitation message

Router Advertisement message

HostDHCP ServerIPv6

StatefullDHCP servers Multicast Group

Unicast

No manual configuration, the router specify the address prefix anddefault gateway, but no DNS server.

The host will contact a DHCP server or similar server. The server assigns anaddress from the pre-configured list.

Page 123: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.123 Micriµm

IPv6 address structure

FP Format Prefix (Address types)SLA ID Site-Level Aggregation IdentifierINTERFACE ID Interface Identifier

The RFC 2374 describe two other hierarchical fields: TLA and NLA. IETF decided to remove the TLA and NLA fields because they are to subject to provider specific politics.

Interface IDGlobal Routing Prefix64 bits45 bits

FP3

SLA ID16 bits

« Network » « host »« Subnet »

128 bits/16 octets

Page 124: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.124 Micriµm

Address prefix

Prefix = Network portion + Subnet. Identify the number of bits, starting from left, which represents the

network and subnet parts. The prefix representation is identical to the one used in IP version 4

with CIDR.

In a URL, the address is found between square brackets:– http://[1080::8: 800:200C:417A]:8080/index.html– The browsers are modified– The use of names (FQDN: Fully Qualified Domain Names)

is preferable.

12AB : 0000 : 0000 : CD30 : 0000 : 0000 : 0000 : 0000 / 64

16 bits 16 bits 16 bits16 bits 16 bits 16 bits 16 bits 16 bits Prefix length

Network host Subnet

Prefix

Page 125: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.125 Micriµm

Hierarchical routing

Tier 1 : Top-Level Aggregator (provider)Intermediate Provider : Next-Level Aggregator (provider)Site : Site-Level Aggregator (user)

Page 126: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.126 Micriµm

IP address types

1) Unicast (point to point)

A B C D E

3) Broadcast (point to multipoint)

A B C D E

2) Multicast (point to multipoint)

A B C D E

X

Page 127: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.127 Micriµm

IP address types – RFC 3513

The type of an IPv6 address is identified by the high-order bits of the address, as follows:

Address type Binary prefix IPv6 notation

Unspecified 00...0 (128 bits) ::/128

Loopback 00...1 (128 bits) ::1/128

Multicast 11111111 FF00::/8

Link-local unicast 1111111010 FE80::/10

Site-local unicast 1111111011 FEC0::/10

Global unicast (everything else)Future specifications may redefine one or more sub-ranges of the global unicast space for other purposes, but unless and until that happens, implementations must treat all addresses that do not start with any of the above-listed prefixes as global unicast addresses.

Page 128: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.128 Micriµm

Neighbor Discovery (ND) Protocol

RFC 2461 Replace IP version 4 ARP, plus new functionalities Use ICMPv6 Used to: Find the neighbors link-local address Find routers on the local network Maintain neighbor accessibility Allow routers to send network address and related info to hosts Used by the auto-configuration process All ND messages have a Hop Limit of 255 Messages have a link-local scope

Page 129: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.129 Micriµm

Duplicate Address Detection

– The host initiate the address resolution process by sending to the Multicast group a request to return their layer 2 address.

– The Neighbor Solicitation Messages are Multicast:

target Multicast address FF02 : :1 :FF17 :FCCD And MAC address 33-33-FF-17-FC-CD

– If no neighbor answers, the address is unique.

Neighbor solicitation

Group MulticastAdrress

FF02 : :1 :FFXX :XXXX

FE80 : :0290 : 27FF : FE17 : FCCD

Target Host

Page 130: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.130 Micriµm

MTU discovery process

EthernetMTU = 1500

FDDIMTU = 4500

FDDIMTU = 4500

FDDIMTU = 4500

MTU discovery message

ICMPDatagram too big

With IP version 6, routers don’t fragment packets. When fragmentation is required, it is performed by the source host. Nodes transmit packets as large as the local network can support. If MTU is too big for some links on the path, a ICMP message « Datagram Too Big »

is returned to the source. The source adjust the MTU and fragment the packet. The minimum MTU is 1280.

Page 131: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.131 Micriµm

Minimum address configurationWindows 7

Ethernet adapter Local Area Connection:

Connection-specific DNS Suffix . : DLinkDescription . . . . . . . . . . . : Broadcom NetLink (TM) Gigabit EthernetPhysical Address. . . . . . . . . : D4-BE-D9-9A-AA-FADHCP Enabled. . . . . . . . . . . : YesAutoconfiguration Enabled . . . . : YesIPv6 Address. . . . . . . . . . . : aaaa:bbbb:cccc:dddd:6c6e:b685:4fa:1b8(Preferred) Temporary IPv6 Address. . . . . . : aaaa:bbbb:cccc:dddd:a56c:dd91:e685:873(Preferred) Link-local IPv6 Address . . . . . : fe80::6c6e:b685:4fa:1b8%11(Preferred) IPv4 Address. . . . . . . . . . . : 192.168.5.247(Preferred) Subnet Mask . . . . . . . . . . . : 255.255.255.0Lease Obtained. . . . . . . . . . : May-01-12 4:24:04 PMLease Expires . . . . . . . . . . : May-03-12 4:24:04 AMDefault Gateway . . . . . . . . . : fe80::218:e7ff:fed8:6bdb%11

fe80::4858:bfb:12a1:6289%11192.168.5.1

DHCP Server . . . . . . . . . . . : 192.168.5.1DHCPv6 IAID . . . . . . . . . . . : 248823513DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-17-04-2A-C6-D4-BE-D9-9A-AA-FADNS Servers . . . . . . . . . . . : 192.168.5.1NetBIOS over Tcpip. . . . . . . . : Enabled

Page 132: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.132 Micriµm

Minimum address configurationWindows 7

Tunnel adapter isatap.DLink:

Media State . . . . . . . . . . . : Media disconnectedConnection-specific DNS Suffix . : DLinkDescription . . . . . . . . . . . : Microsoft ISATAP AdapterPhysical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0DHCP Enabled. . . . . . . . . . . : NoAutoconfiguration Enabled . . . . : Yes

Tunnel adapter Local Area Connection* 11:

Media State . . . . . . . . . . . : Media disconnectedConnection-specific DNS Suffix . : Description . . . . . . . . . . . : Microsoft 6to4 AdapterPhysical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0DHCP Enabled. . . . . . . . . . . : NoAutoconfiguration Enabled . . . . : Yes

Tunnel adapter Teredo Tunneling Pseudo-Interface:

Connection-specific DNS Suffix . : Description . . . . . . . . . . . : Teredo Tunneling Pseudo-InterfacePhysical Address. . . . . . . . . : 00-00-00-00-00-00-00-E0DHCP Enabled. . . . . . . . . . . : NoAutoconfiguration Enabled . . . . : YesIPv6 Address. . . . . . . . . . . : 2001:0:4137:9e76:14e0:3748:b5c5:fc6b(Preferred) Link-local IPv6 Address . . . . . : fe80::14e0:3748:b5c5:fc6b%14(Preferred) Default Gateway . . . . . . . . . : NetBIOS over Tcpip. . . . . . . . : Disabled

Page 133: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.133 Micriµm

What are the risks?

Capital expenditure

Human resources (retraining)

Security

Unproven technologies, protocols, implementations

Instability

Protocol limitations

Performance limitations

Page 134: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.134 Micriµm

Migrating to IPv6

1. Upgrade your applications to be independent of IPv6 or IPv4.

a) Applications must be changed to use new Sockets Application programming interfaces (APIs) so that name resolution, socket creation, and other functions are independent of whether IPv4 or IPv6 is being used.

b) Update the DNS infrastructure to support IPv6 address and PTR records.

c) The DNS infrastructure might need to be upgraded to support the new AAAA records and PTR records in the IP6.ARPA reverse domain (optional).

Page 135: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.135 Micriµm

Migrating to IPv6

2. Upgrade hosts to IPv6/IPv4 nodes.

3. Hosts must be upgraded to use a dual IP layer or dual IP stack. DNS resolver support must also be added to process DNS query results that contain both IPv4 and IPv6 addresses.

4. Upgrade routing infrastructure for native IPv6 routing.

5. Routers must be upgraded to support native IPv6 routing and IPv6 routing protocols.

6. Convert IPv6/IPv4 nodes to IPv6-only nodes.

Page 136: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.136 Micriµm

Migrating to IPv6

IPv6/IPv4 nodes can be upgraded to be IPv6-only nodes.

This should be a long-term goal because it will take years for all current IPv4-only network devices to be upgraded to IPv6-only. For those IPv4-only nodes that cannot be upgraded to IPv6/IPv4 or IPv6-only, employ translation gateways as appropriate so that IPv4-only nodes can communicate with IPv6-only nodes.

Page 137: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.137 MicriµmMicriµm

Block 8 Troubleshooting

Using the ICMP tools Ping Traceroute

Page 138: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.138 Micriµm

ICMP protocol

Since the IP protocol does not guarantee datagram delivery, this responsibility is left to higher layers.

The IP protocol does, however, provide a means of sending alerts and diagnostic messages using the ICMP protocol.

Such errors typically occur in intermediary routers and systems to which these datagrams are sent.

Page 139: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.139 Micriµm

ICMP protocol

There are two types of ICMP messages :– error messages– request/response messages

IP packet

ICMP message

Page 140: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.140 Micriµm

ICMP protocol

Message structure

The IP PROTOCOL field is equal to 1 if ICMP is used. The TYPE field is the first byte of the ICMP message. This field’s value

determines the contents of the rest of the data field. The CODE field depends directly on the TYPE field. The CHECKSUM field is the 16-bit one‘s complement of the one's

complement sum of the ICMP message.

Page 141: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.141 Micriµm

ICMP protocol

15 ICMP

message types

ICMP Message type #

Function

0 Echo reply

3 Destination unreachable

4 Source quench

5 Redirect

8 Echo request

9 Router advertisement

10 Router solicitation

11 Time exceed

12 Parameter problem

13 Timestamp request

14 Timestamp reply

15 Information request

16 Information reply

17 Address mask request

18 Address mask reply

Page 142: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.142 Micriµm

ICMP protocol

Error message structure :

An ICMP ERROR message always returns the following elements from the original datagram : the IP header (20 bytes) the IP options (0-40 bytes) the first (8) bytes of the data field (8 bytes)

The first eight bytes of the data field include port numbers in the case of upper layer TCP and UDP protocols. These ports indicate the applications to which the datagram belongs.

Page 143: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.143 Micriµm

ICMP protocol

Error message structure

8 bytes

Page 144: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.144 Micriµm

ICMP protocol

Example: Echo request and echo reply messages

TYPE8= Echo Request0= Echo Reply

IdentifierArbitrary number for linking a request with a reply

Sequential numberCounter set to 0 and incremented after reply received

Page 145: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.145 Micriµm

ICMP protocol - PING

Echo Request (type 8) message

Page 146: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.146 Micriµm

Echo Reply (type 0) message

ICMP protocol - PING

Page 147: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.147 Micriµm

TTL (Time Exceed) (type 11) message used by “Traceroute”

ICMP protocol - TRACEROUTE

Page 148: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.148 Micriµm

ICMP protocol - TRACEROUTE

Page 149: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.149 Micriµm

ICMP protocol - TRACEROUTE

Page 150: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.150 Micriµm

ICMP protocol - TRACEROUTE

Page 151: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.151 Micriµm

ICMP protocol - TRACEROUTE

Page 152: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.152 Micriµm

ICMP protocol - TRACEROUTE

Page 153: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.153 MicriµmMicriµm

Questions?

Page 154: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.154 MicriµmMicriµm

Block 9Transport Protocols

Explain the operation of the transport layer protocols : UDP and TCP by

Looking at the transport mechanisms used by UDP and TCP. See the difference between UDP and TCP. Identify the header fields for both UDP and TCP.

Page 155: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.155 Micriµm

Client – Server Model

Page 156: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.156 Micriµm

UDP Characteristics

UDP is a communication protocol at Layer 4 of the OSI model.

It provides limited services when information is exchanged between two stations on the network.

UDP is used together with IP.

Page 157: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.157 Micriµm

UDP Characteristics

UDP does not provide :

Connections or logical circuits. Acknowledgements of datagram reception. Flow control. Retransmission of lost datagrams.

It is a connectionless service.

Page 158: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.158 Micriµm

UDP Header

UDP header fields

Page 159: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.159 Micriµm

Ethernet driver configuration

net_dev_cfg.cconst NET_DEV_CFG_ETHER NetDev_Cfg_RX_Ether_0 = {

NET_IF_MEM_TYPE_MAIN, /* Desired receive buffer memory pool type : *//* NET_IF_MEM_TYPE_MAIN buffers allocated from main memory *//* NET_IF_MEM_TYPE_DEDICATED buffers allocated from (device's) dedicated memory */

1520u, /* Desired size of device's large receive buffers (in octets) */10u, /* Desired number of device's large receive buffers]. */16u, /* Desired alignment of device's receive buffers (in octets) */0u, /* Desired offset from base receive index, if needed (in octets) */

NET_IF_MEM_TYPE_MAIN, /* Desired transmit buffer memory pool type : *//* NET_IF_MEM_TYPE_MAIN buffers allocated from main memory *//* NET_IF_MEM_TYPE_DEDICATED buffers allocated from (device's) dedicated memory */

1612u, /* Desired size of device's large transmit buffers (in octets) */10u, /* Desired number of device's large transmit buffers */256u, /* Desired size of device's small transmit buffers (in octets) */5u, /* Desired number of device's small transmit buffers */16u, /* Desired alignment of device's transmit buffers (in octets) */0u, /* Desired offset from base transmit index, if needed (in octets) */

0x00000000u, /* Base address of dedicated memory, if available. */0u, /* Size of dedicated memory, if available (in octets). */

NET_DEV_CFG_FLAG_NONE, /* Desired option flags, if any */

3u, /* Desired number of device's receive descriptors. */10u, /* Desired number of device's transmit descriptors. */

0x000C0000u, /* Base address of device's hardware/registers. */

0u, /* Size of device's data bus (in bits), if available. */

"00:30:55:08:80:00", /* Desired device hardware address; may be NULL address or string ... *//* ... if device hardware address configured or set at run-time. */

Page 160: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.160 Micriµm

JPerf

Find the JPerf icon on your desktop and run it

Page 161: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.161 Micriµm

JPerf

J-Perf creates a DOS window.It should be minimized.

J-Perf settings window.This is the main window we will use

Page 162: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.162 Micriµm

TeraTerm

Find the TeraTerm icon on your desktop and run it

You may have to determine and/or modified which COM port the USB-to-Serial adaptor is installed on, select the Serial interface and its port

Page 163: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.163 Micriµm

TeraTerm

Page 164: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.164 Micriµm

TeraTerm

Cycle the target board power or send empty lines (carriage return) from the PC to the target to trigger a response from the target

White background versus black background is a Setup->Window menu settingsChoose “Reverse”

Page 165: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.165 Micriµm

UDP Test 1

Target PC

Server Client

Page 166: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.166 Micriµm

UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors

Target PC

> iperf –s –u –f m

Page 167: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.167 Micriµm

Target PC

UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors

Page 168: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.168 Micriµm

UDP Test 2

Target PC

ServerClient

Page 169: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.169 Micriµm

Target PC> iperf –c 10.10.2.100 –u –f m

UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors

Page 170: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.170 Micriµm

Target PC

UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors

Page 171: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.171 Micriµm

Target PC

UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors

Page 172: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.172 Micriµm

UDP Test 3

Target PC

Server Client

Page 173: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.173 Micriµm

Target PC

> iperf –s –u –f m

Maximum UDP receive performance

Page 174: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.174 Micriµm

Target PC

Maximum UDP receive performance

Page 175: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.175 Micriµm

Target PC

Maximum UDP receive performance

Page 176: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.176 Micriµm

Performance with Wireshark

Wireshark interfaces between the Network Interface Card and the Windows TCP/IP stack

Depending on your laptop, running Wireshark in parallel with IPerf may influence the laptop performance

Redo the UDP tests with Wireshark and validate the performance results obtained without and with Wireshark

Page 177: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.177 Micriµm

UDP receive performance with Wireshark

Target PC

> iperf –s –u –f m

Page 178: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.178 Micriµm

UDP receive performance with Wireshark

Do we get the same performance?

Page 179: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.179 Micriµm

TCP Characteristics

TCP is a communication protocol at layer 4 of the OSI model.

It provides full services when information is being exchanged between two stations on the network.

TCP is used together with IP.

Page 180: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.180 Micriµm

TCP Characteristics

TCP provides : Logical connections or circuits. Acknowledgment of datagrams. Flow control. Data error checking. Retransmission of lost datagrams. Data delivery in the correct order.

It is a connection-oriented protocol.

Page 181: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.181 Micriµm

1

2

3

Client Server

TCP connection phases

Connection establishment

SYN

SYNACK

ACK

Page 182: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.182 Micriµm

TCP connection phases

Information transfer

1

Client Server

ACK

PUSH

PUSH

ACK

2

1

2

Page 183: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.183 Micriµm

TCP connection phases

Disconnection

1

Client Server

ACK

FIN

FIN

ACK

2

1

2

Page 184: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.184 Micriµm

Connection status verification

Windows command: netstat

Page 185: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.185 Micriµm

TCP Header

TCP header fields

Page 186: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.186 Micriµm

TCP Header

The socket : IP address + port number.

Page 187: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.187 Micriµm

TCP Header

CODE (6 bits)

Page 188: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.188 Micriµm

TCP Header

SEQUENCE NUMBER (32 bits)

Page 189: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.189 Micriµm

TCP Header

ACKNOWLEDGEMENT NUMBER (32 bits)

189

Page 190: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.190 Micriµm

TCP Header

WINDOW (16 bits)

Page 191: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.191 Micriµm

TCP Header

An example of WINDOW use :

Page 192: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.192 Micriµm

TCP Header

Another example of WINDOW use :

Page 193: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.193 Micriµm

Bandwidth * Delay Product (BDP)

BDP (bytes) = total_available_bandwidth (KBytes/sec) x round_trip_time (ms)

It is recommended to make Rx TCP Window Size (or BDP) a multiple of the Maximum Segment Size (MSS), typically a multiple of 1460.

Page 194: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.194 Micriµm

Timers That Contribute to Data Transmission with TCP

Timers are spans of time that are used to manage the sending and retransmission of segments.

RTT (Round trip time)♦ The RTT is the time that passes between the sending of a TCP segment (SYN or

PSH) and the receipt of its acknowledgment (ACK).♦ The RTT is recalculated over the duration of the connection and varies according

to the congestion of the network.

Page 195: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.195 Micriµm

Timers That Contribute to Data Transmission with TCP

RTT

Page 196: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.196 Micriµm

Timers That Contribute to Data Transmission with TCP

RTO (Retransmission Time Out)

RTT

Time

Page 197: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.197 Micriµm

Timers That Contribute to Data Transmission with TCP

Example of RTO usage :

µC/TC-IP uses a fix initial RTO.

Page 198: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.198 Micriµm

Timers That Contribute to Data Transmission with TCP

Persist Timer

It is the waiting time before a transmission to a station when the transmission window is 0.

All TCP segments with the exception of acknowledgments (« ACK ») receive a segment acknowledging receipt.

ACK segments may be lost (just like any other TCP segment). If Station A does not receive an ACK with a transmission window > 0, it will transmit a single byte to Station B after the persist timer has elapsed.

This segment is called a « window probe ». The persist timer is always set at between 5 and 60 seconds.

Page 199: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.199 Micriµm

Timers That Contribute to Data Transmission with TCP

Example of Persist timer usage :

Page 200: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.200 Micriµm

Timers That Contribute to Data Transmission with TCP

KEEPALIVE

It is the maximum period of time between two activities on a TCP connection.

Many set-ups have the maximum period of inactivity set at two hours. The timer is restarted every time an activity occurs on the connection.

Keepalive

Page 201: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.201 Micriµm

Timers That Contribute to Data Transmission with TCP

2MSL

2MSL is the maximum « keep alive » of a TCP segment on the network.

This « keep alive » is defined in the « TTL » field in the IP header.

2MSL

Page 202: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.202 Micriµm

TCP3-way handshakeCapture and analyze a TCP connection

Page 203: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.203 Micriµm

TCP Test 1

Target PC

Server Client

Page 204: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.204 Micriµm

TCPReception : 10 buffers, 3 descriptorsTransmission : 10 large buffers, 10 descriptors

5 small buffers

Target PC> iperf –s –f m

Page 205: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.205 Micriµm

Target PC

TCPReception : 10 buffers, 3 descriptorsTransmission : 10 large buffers, 10 descriptors

5 small buffers

Page 206: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.206 Micriµm

TCP3-way handshake

Page 207: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.207 Micriµm

TCP MSS optimization

Is 31.5 Mpbs the maximum TCP performance in client mode we can achieve?

The TCP Maximum Segment Size (MSS) is 1460 bytes

The IPerf default buffer size is 8K bytes

What will happen if we make the buffer an exact multiplier of the MSS?

Page 208: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.208 Micriµm

TCP Test 2

Target PC

Server Client

Page 209: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.209 Micriµm

> iperf –s –f m

Target PC

TCPReception : 10 buffers, 3 descriptorsTransmission : 10 large buffers, 10 descriptors

5 small buffers Buffer = 7300

Page 210: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.210 Micriµm

TCPReception : 10 buffers, 3 descriptorsTransmission : 10 large buffers, 10 descriptors

5 small buffers Buffer = 7300

Target PC

Page 211: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.211 Micriµm

TCP Test 3

Target PC

ServerClient

Page 212: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.212 Micriµm

Target PC> iperf –c 10.10.2.100 –f m

TCPReception : 10 buffers, 3 descriptorsTransmission : 10 large buffers, 10 descriptors

5 small buffers

Page 213: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.213 Micriµm

Target PC

TCPReception : 10 buffers, 3 descriptorsTransmission : 10 large buffers, 10 descriptors

5 small buffers

Page 214: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.214 Micriµm

TCPWinsize > Number of net_bufsConfiguring TCP Window sizes

Page 215: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.215 Micriµm

TCP Window size – Source code projectWindow size in relation to buffers

/* Configure TCP connections' window sizes ... *//* ... in integer number of octets (see Note #2) : */

#define NET_TCP_CFG_RX_WIN_SIZE_OCTET (10u * 1460u) /* Configure TCP connection receive window size. */#define NET_TCP_CFG_TX_WIN_SIZE_OCTET (10u * 1460u) /* Configure TCP connection transmit window size. */

net_cfg.h

The TCP window size should follow the number of buffers available.In our configuration, we have 3 Receive descriptors for 10 Receive buffers.This test sets the TCP Receive Window Size at 10 Receive buffers.

Page 216: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.216 Micriµm

TCP Demo by the instructor

Target PC

Server Client

Page 217: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.217 Micriµm

Target PC> iperf –s –f m

TCP Window sizeWindow size in relation to buffers

Page 218: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.218 Micriµm

Wireshark capture

218

Retransmission occurring because the transmitter is overflowing the Receive buffers, degrading the

performance

Page 219: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.219 Micriµm

Bandwidth-Delay Product (BDP)

BDP (bytes) = total_available_bandwidth (KBytes/sec) * round_trip_time (ms)

Example 1Bandwidth = 5 Megabits per secondRTT = 300 milliseconds (public internet)

BDP = 187500 bytes

It is a good practice to define the TCP window size in multiple of the TCP maximum segment size (MSS) which is normally 1460 bytes.

In this case, 187500 bytes is the equivalent of 129 buffers.

Page 220: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.220 Micriµm

Bandwidth-Delay Product (BDP)

BDP (bytes) = total_available_bandwidth (KBytes/sec) * round_trip_time (ms)

Example 2Bandwidth = 5 Megabits per secondRTT = 3 milliseconds (private intranet)

BDP = 1875 bytes

In this case, 1875 bytes is the equivalent of 2 buffers(with a MSS of 1460 bytes).

Page 221: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.221 Micriµm

TCPMultiple sockets

Bandwidth is shared between all active TCP connections

The BDP (i.e. number of buffers) are shared between connections. The performance of each connection will linearly decrease as the number of connection increases

Perform a system performance assessment

Page 222: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.222 Micriµm

Removing options and optimizing the stack

File Parameter Valuecpu_cfg.h

CPU_CFG_INT_DIS_MEAS_EN DEF_DISABLED

CPU_CFG_LEAD_ZEROS_ASM_PRESENT DEF_ENABLED

os_cfg.h

OS_CFG_APP_HOOKS_EN DEF_DISABLED

OS_CFG_ARG_CHK_EN DEF_DISABLED

OS_CFG_CALLED_FROM_ISR_CHK_EN DEF_DISABLED

OS_CFG_DBG_EN DEF_DISABLED

OS_CFG_OBJ_TYPE_CHK_EN DEF_DISABLED

OS_CFG_SCHED_LOCK_TIME_MEAS_EN DEF_DISABLED

File Parameter Valuenet_cfg.h

NET_CFG_OPTIMIZE NET_OPTIMIZE_SPD

NET_CFG_OPTIMIZE_ASM_EN DEF_ENABLED

NET_DBG_CFG_INFO_EN DEF_DISABLED

NET_DBG_CFG_STATUS_EN DEF_DISABLED

NET_DBG_CFG_MEM_CLR_EN DEF_DISABLED

NET_DBG_CFG_TEST_EN DEF_DISABLED

NET_ERR_CFG_ARG_CHK_EXT_EN DEF_DISABLED

NET_ERR_CFG_ARG_CHK_DBG_EN DEF_DISABLED

NET_CTR_CFG_STAT_EN DEF_DISABLED

NET_CTR_CFG_ERR_EN DEF_DISABLED

NET_TCP_CFG_RX_WIN_SIZE_OCTET 3 * 1459

NET_TCP_CFG_TX_WIN_SIZE_OCTET 10 * 1460

The activities in this session used all these optimizations

Page 223: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.223 Micriµm

HTTP Server

Start Wireshark Open the web browser of your choice Enter the following address: http://10.10.2.65

Use the potentiometer on the board to change the

value

Click to toggle LED15 Click to toggle LED4

Page 224: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.224 Micriµm

HTTP ServerWireshark captureUsing Internet Explorer

Embedded Target IP Address:10.10.2.65

PC IP Address:10.10.2.100

Page 225: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.225 MicriµmMicriµm

Questions?

Page 226: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.226 MicriµmMicriµm

Block 10Applications and services

Distinguish the various network services and applications

Page 227: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.227 Micriµm

Services

DHCP&

DNS

Page 228: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.228 Micriµm

DHCP Service

Since all IP network equipment require unique addresses, the DHCP (Dynamic Host Configuration Protocol) protocol relieves a burden on network administrator management.

DHCP supports two types of addresses :StaticDynamic

DHCP replaces BOOTP (Bootstrap Protocol).

Page 229: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.229 Micriµm

DHCP Service

DHCP usage example

150.100.10.8 150.100.10.10DHCP server

1

?.?.?.?

1 2Eth. s: A0.B2.C1.D3.F4.E5Eth. d: FF.FF.FF.FF.FF.FFadresse IP = ?DHCP request

Eth. s: A0.B2.C1.E6.D4.A7Eth. d: A0.B2.C1.D3.F4.E5adresse IP = 150.100.10.5DHCP reply

Page 230: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.230 Micriµm

DHCP Service

Resulting configuration

Page 231: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.231 Micriµm

DHCP Client implementation

Page 232: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.232 Micriµm

Dynamic configuration of link-local addresses

RFC 3927 :

Microsoft refers to this as Automatic Private IP Addressing (APIPA)or

AutoNet in other environments.

IPv4 uses the special block 169.254.0.0/16while IPv6 hosts use the prefix fe80::/10

Page 233: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.233 Micriµm

Zeroconf

Zeroconf – is a protocol that solves the following issues: Assigning a network address to a device using link-local address autoconfiguration Detect the presence of neighbour computers by their hostname using Multicast

DNS (Apple mDNS) or Link-local Multicast Name Resolution (Microsoft LLMNR) Detect services, such as printer using Apple's protocol: mDNS and DNS-SD (DNS

Service Discovery) Avahi – is a Zeroconf implementation for Linux and BSDs. Bonjour – also known as Rendezvous, is a proprietary zeroconf implementation from

Apple Inc. Zeroconf is built on three core technologies:

Assignment of numeric network addresses for networked devices () Automatic resolution and distribution of computer hostnames (multicast DNS) Automatic location of network services, such as printing devices through DNS service

discovery.

Page 234: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.234 Micriµm

DNS Service

The « Domain Name System » is used to establish an association between a system name and its IP address.

It is a protocol with two parts to it : Client : Resolver Server : Name server

Page 235: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.235 Micriµm

DNS Service

The structure of DNS is very similar to the file structures that we find in our existing systems.

It is possible to have up to 127 levels (but this is not recommended…).

Page 236: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.236 Micriµm

DNS Service

DNS structureROOT

The DNS database is depicted as an inverted tree, with the root at the top.

Page 237: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.237 Micriµm

DNS Service

Each element/node of the tree has a label that identifies it in relation to its parent.

The label may consist of up to 63 characters.

The root uses a reserved label, i.e. « nil character » or « ».

The levels are separated from each other by periods « . »

The label of each child belonging to a given parent must be unique.

Page 238: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.238 Micriµm

DNS Service

Syntax of Domain Names

WWW.MYCOMPANY.COMDomain NameService Name

Page 239: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.239 Micriµm

DNS Service

An embedded system normally implements a DNS resolver.

The DNS server is a network service.

Page 240: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.240 Micriµm

DNS Service

Resolver

DNS

199.138.88.161

www.mycompany.com ?

www.mycompany,com is199.138.88.161

www.mycompany.com

Internet

Page 241: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.241 Micriµm

DNS Service

Resolution mechanism

Name

Server

Root Server

.com Server

mycompany.com Server

User (resolver)

Request

Answer

www.mycompany.com

Referred to .com

www.mycompany.com

Referred to mycompany.com

www.mycompany.com

Return the requested address199.138.88.161

Root

.gov .com .net

.mycompany

www

Page 242: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.242 Micriµm

Telnet Application

Telnet is a standard application now offered by most TCP/IP implementations on the market.

It is a widely used application aimed at establishing a connection between your computer and a remote system so you can run the remote system as if it were local.

Most telecommunications equipment on the market today, like routers and switches, support the Telnet protocol.

Page 243: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.243 Micriµm

Telnet Application

A virtual session lets the client run applications on the server in terminal mode

> ls.. .. .. .cshrc> cd ..

Page 244: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.244 Micriµm

SMTP Application

SMTP (Simple Mail Transfer Protocol) is one of the protocols used to transfer email messages from computer to computer using TCP/IP.

Messages take the form of emails with headers, destination addresses and messages.

About half of all TCP connections are used by SMTP!

Page 245: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.245 Micriµm

SMTP Application

Envelope

Message Headers

Multipart/alternativeAlternative PartText/plain

Alternative PartText/html

Attachment

From : Alan Fraser from ok.eduDate : 11/09/21Subject: A message

Attachment

MAIL FROM: [email protected] TO : [email protected]

Hello Roger,This is a message. See you soon.Alan

Page 246: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.246 Micriµm

SMTP Application

SMTP address syntax :

User@DomainUser

– A unique user on the Domain

Domain– The domain name of the network.

Page 247: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.247 Micriµm

FTP Application

FTP is the standard Internet file transfer protocol.

FTP is one of the three most common « Net » protocols (tens of millions of email, www and FTP users).

It is a layer 7 protocol using the TCP transport service.

Page 248: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.248 Micriµm

FTP Application

Page 249: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.249 Micriµm

FTP Application

FTP (File Transfer Protocol) is used to transfer files from one machine to another.

The anonymous user is a generic user. This lets a client connect to a server without having an account with a given server. A minimum security can be implemented by using the user client’s email address as the password.

Ex.:Userid : anonymousPassword: [email protected]

Page 250: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.250 Micriµm

HTTP Application

HTTP (Hypertext Transfer Protocol) is a protocol that is used to exchange files (text, video, graphics and other multimedia files) over the World Wide Web – WWW.

This protocol uses TCP/IP as the vehicle for sending and receiving data.

The protocol works in client/server mode. The client portion is embedded in the applications on the workstations.

It includes many other tools used on the Internet : News, FTP, Telnet, Email, etc.

Page 251: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.251 Micriµm

HTTP Application

Page 252: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.252 MicriµmMicriµm

Questions?

Page 253: Embedding TCP/IP Working Through … 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

© 2012 Renesas Electronics America Inc. All rights reserved.253 Micriµm

Summary

A TCP/IP stack is a layered protocol stack Performances attained on Personal Computers may not be

the right expectations for an embedded system based on an MCU

Ethernet is the ubiquitous Local Area Network, with WiFibeing an extension of it

A network protocol analyzer like Wireshark is the best tool to troubleshoot problems and to communicate issues

IPerf is a great tool to stress your Ethernet/WiFi driver and TCP/IP stack

IPv4 and IPv6 will coexist for a long time UDP can be overrun. TCP can produce bad results when not

configured properly DHCP and DNS are network services. FTP, HTTP, Telnet

SMTP, POP3 are applications

Page 254: Embedding TCP/IP Working Through … 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

Renesas Electronics America Inc.© 2012 Renesas Electronics America Inc. All rights reserved.

Micriµm