Renesas Electronics America Inc.© 2012 Renesas Electronics America Inc. All rights reserved.
Embedding TCP/IPWorking Through Implementation Challenges
Micriµm
© 2012 Renesas Electronics America Inc. All rights reserved.2 Micriµm
Renesas Technology & Solution Portfolio
© 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
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.5 MicriµmMicriµm
Block 1What is a TCP/IP stack?
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.8 Micriµm
Layered communication
© 2012 Renesas Electronics America Inc. All rights reserved.9 Micriµm
TCP/IP Protocol ArchitectureProtocol Family
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.11 MicriµmMicriµm
Block 2Requirements
Performance Connectivity onlyOr Throughput?
© 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.
© 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.
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.15 Micriµm
RequirementsProtocols and services
Optional protocols:IGMPICMPTCP Congestion controlTCP keepaliveTCPIP fragmentation
© 2012 Renesas Electronics America Inc. All rights reserved.16 MicriµmMicriµm
Questions?
© 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)
© 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 :
© 2012 Renesas Electronics America Inc. All rights reserved.19 Micriµm
Ethernet technology
Topology
1st Generation
Today
© 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
© 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
© 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
© 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
© 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.
© 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
© 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.
© 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
© 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.
© 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)
© 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
© 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.
© 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
© 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
© 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
© 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.
© 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
© 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
© 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.
© 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
© 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
© 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
© 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
© 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
© 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
© 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
© 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.
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.49 Micriµm
Renesas Demonstration Kit YRDKRX63N
© 2012 Renesas Electronics America Inc. All rights reserved.50 Micriµm
Network set-up
© 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
© 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
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.54 Micriµm
Network Protocol AnalyzerWireshark
http://www.wireshark.org/
© 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/
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.57 Micriµm
Kperf Bandwidth Graph
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.59 Micriµm
µC/IPerf
Client modeiperf –c xxx.xxx.xxx.xxx
Server modeiperf -s
© 2012 Renesas Electronics America Inc. All rights reserved.60 MicriµmMicriµm
Questions?
© 2012 Renesas Electronics America Inc. All rights reserved.61 Micriµm
Lab 1ARP & Packet Capture using Ping
© 2012 Renesas Electronics America Inc. All rights reserved.62 Micriµm
Lab set-up
© 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
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.65 Micriµm
Renesas e2 Studio : Selecting ProjectuC_OS_III_TCPIP_HTTPs_IPerf
Left clickto expand
© 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
© 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()
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.69 Micriµm
Renesas e2 Studio : Downloading code to target
ClickDownload and Debug
SelectBinaryfile
© 2012 Renesas Electronics America Inc. All rights reserved.70 Micriµm
Renesas e2 Studio : Running code
Start running to main()i.e. initialize
© 2012 Renesas Electronics America Inc. All rights reserved.71 Micriµm
Renesas e2 Studio : Running code
Start running from main()
© 2012 Renesas Electronics America Inc. All rights reserved.72 Micriµm
Code running
Code is running when LED7 to LED12 are blinking sequentially
© 2012 Renesas Electronics America Inc. All rights reserved.73 Micriµm
Configuring the PCStatic IP settings
Right Click
© 2012 Renesas Electronics America Inc. All rights reserved.74 Micriµm
PC static IP settings
Then click OK to close all the screens
© 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”
© 2012 Renesas Electronics America Inc. All rights reserved.76 Micriµm
WiresharkConfiguration
Name Resolution
© 2012 Renesas Electronics America Inc. All rights reserved.77 Micriµm
WiresharkConfiguration
Name Resolution:
Display complete address and port numbers (not aliases)
© 2012 Renesas Electronics America Inc. All rights reserved.78 Micriµm
WiresharkCapture
78
Packet List
Packet Details
Packet Bytes
Display filtersCapture filters
© 2012 Renesas Electronics America Inc. All rights reserved.79 Micriµm
WiresharkConfiguration
We can also define Capture Filters
© 2012 Renesas Electronics America Inc. All rights reserved.80 Micriµm
WiresharkConfiguration
Or Display Filters
© 2012 Renesas Electronics America Inc. All rights reserved.81 Micriµm
WiresharkProtocol selection
Selected protocols for the exercises:
ARP – IP – ICMP – TCP – UDP
© 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
© 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
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.86 Micriµm
Using PING to create network traffic
© 2012 Renesas Electronics America Inc. All rights reserved.87 Micriµm
Wireshark Packet Capture
© 2012 Renesas Electronics America Inc. All rights reserved.88 Micriµm
WiresharkStop capture
© 2012 Renesas Electronics America Inc. All rights reserved.89 Micriµm
PC ARP cache
List
Delete
© 2012 Renesas Electronics America Inc. All rights reserved.90 Micriµm
Stopping execution
Stop Debugging
© 2012 Renesas Electronics America Inc. All rights reserved.91 Micriµm
Analyzing the packet capture
ARP Ethernet
PING IP ICMP
– Type– Sequence number– Payload
© 2012 Renesas Electronics America Inc. All rights reserved.92 MicriµmMicriµm
Block 6IPv4 Addressing
IP address Subnets Public versus private
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.95 Micriµm
IP version 4 Header Description
© 2012 Renesas Electronics America Inc. All rights reserved.96 Micriµm
Viewing the IP Configuration
Windows ipconfigLinux ifconfig
© 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 #
© 2012 Renesas Electronics America Inc. All rights reserved.98 Micriµm
Ethernet
Unicast (point to point)
IP address types
© 2012 Renesas Electronics America Inc. All rights reserved.99 Micriµm
Ethernet
Multicast (point to multipoint)
IP address types
99
© 2012 Renesas Electronics America Inc. All rights reserved.100 Micriµm
Ethernet
Broadcast (point to all points)
IP address types
100
© 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
© 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
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.105 Micriµm
Network Mask usage
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.107 Micriµm
Subnetworking
© 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.)
© 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
© 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
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.112 Micriµm
IP HeaderIDENTIFICATION
© 2012 Renesas Electronics America Inc. All rights reserved.113 Micriµm
Viewing the routing information
Route Print
© 2012 Renesas Electronics America Inc. All rights reserved.114 Micriµm
Gateway Setup
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.116 Micriµm
Network Address Translation
© 2012 Renesas Electronics America Inc. All rights reserved.117 Micriµm
Port Address Translation
© 2012 Renesas Electronics America Inc. All rights reserved.118 MicriµmMicriµm
Questions?
© 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
© 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.
© 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!
© 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.
© 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
© 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
© 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)
© 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
© 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.
© 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
© 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
© 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.
© 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
© 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
© 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
© 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).
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.137 MicriµmMicriµm
Block 8 Troubleshooting
Using the ICMP tools Ping Traceroute
© 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.
© 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
© 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.
© 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
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.143 Micriµm
ICMP protocol
Error message structure
8 bytes
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.145 Micriµm
ICMP protocol - PING
Echo Request (type 8) message
© 2012 Renesas Electronics America Inc. All rights reserved.146 Micriµm
Echo Reply (type 0) message
ICMP protocol - PING
© 2012 Renesas Electronics America Inc. All rights reserved.147 Micriµm
TTL (Time Exceed) (type 11) message used by “Traceroute”
ICMP protocol - TRACEROUTE
© 2012 Renesas Electronics America Inc. All rights reserved.148 Micriµm
ICMP protocol - TRACEROUTE
© 2012 Renesas Electronics America Inc. All rights reserved.149 Micriµm
ICMP protocol - TRACEROUTE
© 2012 Renesas Electronics America Inc. All rights reserved.150 Micriµm
ICMP protocol - TRACEROUTE
© 2012 Renesas Electronics America Inc. All rights reserved.151 Micriµm
ICMP protocol - TRACEROUTE
© 2012 Renesas Electronics America Inc. All rights reserved.152 Micriµm
ICMP protocol - TRACEROUTE
© 2012 Renesas Electronics America Inc. All rights reserved.153 MicriµmMicriµm
Questions?
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.155 Micriµm
Client – Server Model
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.158 Micriµm
UDP Header
UDP header fields
© 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. */
© 2012 Renesas Electronics America Inc. All rights reserved.160 Micriµm
JPerf
Find the JPerf icon on your desktop and run it
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.163 Micriµm
TeraTerm
© 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”
© 2012 Renesas Electronics America Inc. All rights reserved.165 Micriµm
UDP Test 1
Target PC
Server Client
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.167 Micriµm
Target PC
UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors
© 2012 Renesas Electronics America Inc. All rights reserved.168 Micriµm
UDP Test 2
Target PC
ServerClient
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.170 Micriµm
Target PC
UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors
© 2012 Renesas Electronics America Inc. All rights reserved.171 Micriµm
Target PC
UDPReception : 10 buffers, 3 descriptorsTransmission : 10 buffers, 10 descriptors
© 2012 Renesas Electronics America Inc. All rights reserved.172 Micriµm
UDP Test 3
Target PC
Server Client
© 2012 Renesas Electronics America Inc. All rights reserved.173 Micriµm
Target PC
> iperf –s –u –f m
Maximum UDP receive performance
© 2012 Renesas Electronics America Inc. All rights reserved.174 Micriµm
Target PC
Maximum UDP receive performance
© 2012 Renesas Electronics America Inc. All rights reserved.175 Micriµm
Target PC
Maximum UDP receive performance
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.177 Micriµm
UDP receive performance with Wireshark
Target PC
> iperf –s –u –f m
© 2012 Renesas Electronics America Inc. All rights reserved.178 Micriµm
UDP receive performance with Wireshark
Do we get the same performance?
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.181 Micriµm
1
2
3
Client Server
TCP connection phases
Connection establishment
SYN
SYNACK
ACK
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.184 Micriµm
Connection status verification
Windows command: netstat
© 2012 Renesas Electronics America Inc. All rights reserved.185 Micriµm
TCP Header
TCP header fields
© 2012 Renesas Electronics America Inc. All rights reserved.186 Micriµm
TCP Header
The socket : IP address + port number.
© 2012 Renesas Electronics America Inc. All rights reserved.187 Micriµm
TCP Header
CODE (6 bits)
© 2012 Renesas Electronics America Inc. All rights reserved.188 Micriµm
TCP Header
SEQUENCE NUMBER (32 bits)
© 2012 Renesas Electronics America Inc. All rights reserved.189 Micriµm
TCP Header
ACKNOWLEDGEMENT NUMBER (32 bits)
189
© 2012 Renesas Electronics America Inc. All rights reserved.190 Micriµm
TCP Header
WINDOW (16 bits)
© 2012 Renesas Electronics America Inc. All rights reserved.191 Micriµm
TCP Header
An example of WINDOW use :
© 2012 Renesas Electronics America Inc. All rights reserved.192 Micriµm
TCP Header
Another example of WINDOW use :
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.195 Micriµm
Timers That Contribute to Data Transmission with TCP
RTT
© 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
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.199 Micriµm
Timers That Contribute to Data Transmission with TCP
Example of Persist timer usage :
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.202 Micriµm
TCP3-way handshakeCapture and analyze a TCP connection
© 2012 Renesas Electronics America Inc. All rights reserved.203 Micriµm
TCP Test 1
Target PC
Server Client
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.206 Micriµm
TCP3-way handshake
© 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?
© 2012 Renesas Electronics America Inc. All rights reserved.208 Micriµm
TCP Test 2
Target PC
Server Client
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.211 Micriµm
TCP Test 3
Target PC
ServerClient
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.214 Micriµm
TCPWinsize > Number of net_bufsConfiguring TCP Window sizes
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.216 Micriµm
TCP Demo by the instructor
Target PC
Server Client
© 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
© 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
© 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.
© 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).
© 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
© 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
© 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
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.225 MicriµmMicriµm
Questions?
© 2012 Renesas Electronics America Inc. All rights reserved.226 MicriµmMicriµm
Block 10Applications and services
Distinguish the various network services and applications
© 2012 Renesas Electronics America Inc. All rights reserved.227 Micriµm
Services
DHCP&
DNS
© 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).
© 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
© 2012 Renesas Electronics America Inc. All rights reserved.230 Micriµm
DHCP Service
Resulting configuration
© 2012 Renesas Electronics America Inc. All rights reserved.231 Micriµm
DHCP Client implementation
© 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
© 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.
© 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
© 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…).
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.238 Micriµm
DNS Service
Syntax of Domain Names
WWW.MYCOMPANY.COMDomain NameService Name
© 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.
© 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
© 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
© 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.
© 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 ..
© 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!
© 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
© 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.
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.248 Micriµm
FTP Application
© 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]
© 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.
© 2012 Renesas Electronics America Inc. All rights reserved.251 Micriµm
HTTP Application
© 2012 Renesas Electronics America Inc. All rights reserved.252 MicriµmMicriµm
Questions?
© 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
Renesas Electronics America Inc.© 2012 Renesas Electronics America Inc. All rights reserved.
Micriµm