dpdk & layer 4 packet processing

51
DPDK & Layer 4 Packet Processing TLDK – Transport Layer Development Kit M Jay Presentation March 1 2017

Upload: michelle-holley

Post on 12-Apr-2017

101 views

Category:

Software


2 download

TRANSCRIPT

Page 1: DPDK & Layer 4 Packet Processing

DPDK & Layer 4 Packet Processing TLDK – Transport Layer Development Kit

M Jay Presentation March 1 2017

Page 2: DPDK & Layer 4 Packet Processing

TRANSFORMING NETWORKING & STORAGE 2

Technology Disclaimer:

Intel technologies’ features and benefits depend on system configuration and may require enabled hardware, software or service activation. Performance varies depending on system configuration. No computer system can be absolutely secure. Check with your system manufacturer or retailer or learn more at [intel.com].

Performance Disclaimers (include only the relevant ones):

Cost reduction scenarios described are intended as examples of how a given Intel- based product, in the specified circumstances and configurations, may affect future costs and provide cost savings. Circumstances will vary. Intel does not guarantee any costs or cost reduction.

Results have been estimated or simulated using internal Intel analysis or architecture simulation or modeling, and provided to you for informational purposes. Any differences in your system hardware, software or configuration may affect your actual performance.

General Disclaimer:

© Copyright 2017 Intel Corporation. All rights reserved. Intel, the Intel logo, Intel Inside, the Intel Inside logo, Intel. Experience What’s Inside are trademarks of Intel. Corporation in the U.S. and/or other countries. *Other names and brands may be claimed as the property of others.

Legal Disclaimer

Page 3: DPDK & Layer 4 Packet Processing

What are the problems with tradi1onal TCP/UDP stacks?

Page 4: DPDK & Layer 4 Packet Processing

One size “Kernel Stack” does not Fit All App needs

“onesizedoesnotfitall”SingleKernelStack

App3needssomething

else

App1needsHigh

Throughput

App2needsLow

Latency

Page 5: DPDK & Layer 4 Packet Processing

What if you can have mul1ple “user level” stacks?

App1needsHigh

Throughput

App2needsLow

Latency

AppNneeds

somethingelse

“ContextA–a.k.aStackA–tunedforApp1

groupneeds”

App1needsHigh

ThroughputApp2needs

LowLatency

“ContextB–a.k.aStackB–tunedforApp2groupneeds

“ContextC–a.k.aStackC–tunedforApp2groupneeds

Page 6: DPDK & Layer 4 Packet Processing

ConfusedTravelers Tradi?onalTCP/UDPStack

InefficientColdCache

CacheUnfriendlyskbuff OneKernel

Stack“doesnotfitall”appneeds

PacketI/Oinones&twos?

Manymorepainpoints

What are the problems with tradi1onal TCP/UDP stacks?

Page 7: DPDK & Layer 4 Packet Processing

ConfusedTravelers Tradi?onalTCP/UDPStack

InefficientColdCache

CacheUnfriendlyskbuff OneKernel

Stack“doesnotfitall”appneeds

PacketI/Oinones&twos?

Manymorepainpoints

Op?mizedTLDKLayer4-basedonDPDK

UserLevelTLDK–no

constraintofonestack

WarmICache&DCache–Pullpacketsonlywhenreadytoprocess

CacheFriendlymbuf,

DynamicRing

BulkTransfer

https://en.wikipedia.org/wiki/Travelling_salesman_problem

Page 8: DPDK & Layer 4 Packet Processing

TLDK – Any Sample Applica1ons?

Page 9: DPDK & Layer 4 Packet Processing

You know L2fwd, L3fwd

• Whataboutudpfwd?

Page 10: DPDK & Layer 4 Packet Processing

The Eternal Loop of /tldk/examples/udpfwd/main.c

Page 11: DPDK & Layer 4 Packet Processing

Eternal Loop of /tldk/examples/udpfwd/main.c

Page 12: DPDK & Layer 4 Packet Processing

What Are The Main APIs ?

Page 13: DPDK & Layer 4 Packet Processing

3 Key Modules 1) event.o

2) Udp_ctl.o 3) Udp_rxtx.o

Page 14: DPDK & Layer 4 Packet Processing

The Main APIs

Page 15: DPDK & Layer 4 Packet Processing

Front End Core + Back End Core Pulling UDP Stack

FrontEndCoreConfigfile

BackEndCoreConfigfile

tle_udp_dev

ServerProcess

ClientProcess

ReqResponse

TLE_UDP_STREAM

tle_udp_ctx

UDPLocalPort UDPRemotePort

RX TX

Layer4

Layer3

Layer2

“Thesockets”“Your”stacks

Page 16: DPDK & Layer 4 Packet Processing

What does FE config file configure?

FrontEndCoreConfigfile

lcore=3, op=fwd, laddr=0.0.0.0, lport=11211, raddr=0.0.0.0, rport=0, fwladdr=::, fwlport=0, fwraddr=2001:4860:b002::56, fwrport=11211

Layer4

1)Read[Server]2)Write[Client]3)Forward[Gateway]

Page 17: DPDK & Layer 4 Packet Processing

FE config record format: ------------------------ lcore=<uint>,op=<"rx|tx|echo|fwd">,\ laddr=<ip>,lport=<uint16>,raddr=<ip>,rport=<uint16>,\ [txlen=<uint>,fwladdr=<ip>,fwlport=<uint16>,fwraddr=<ip>,fwrport=<uint16>,\ belcore=<uint>] lcore - EAL lcore to manage that stream(s) in the FE. op - operation to perform on that stream:

"rx" - do receive only on that stream. "tx" - do send only on that stream. "echo" - mimic recvfrom(..., &addr);sendto(..., &addr); on that stream. "fwd" - forward packets between streams.

laddr - local address for the stream to open. lport - local port for the stream to open. raddr - remote address for the stream to open. rport - remote port for the stream to open. txlen - data length to send with each packet ("tx" mode only). fwladdr - local address for the forwarding stream(s) to open

("fwd mode only). fwlport - local port for the forwarding stream(s) to open

("fwd mode only). fwraddr - remote address for the forwarding stream(s) to open

("fwd mode only). fwrport - remote port for the forwarding stream(s) to open

("fwd mode only). belcore - EAL lcore to manage that stream(s) in the BE.

Page 18: DPDK & Layer 4 Packet Processing

What does BE config file configure?

BackEndCoreConfigfile

# # udpfwd BE config file example # port=0, masklen=16, addr=192.168.0.0, mac=01:de:ad:be:ef:01 port=0, addr=2001:4860:b002::, masklen=64, mac=01:de:ad:be:ef:01

Layer3

Layer2

Page 19: DPDK & Layer 4 Packet Processing

In addi1on, can I do command line config. as well?

Page 20: DPDK & Layer 4 Packet Processing

Yes ! Command line Op1ons configuring

As an example: udpfwd --lcores='3,6,8' -w 01:00.0 -- \ --promisc --rbufs 0x1000 --sbufs 0x1000 --streams 0x100 \ --fecfg ./fe.cfg --becfg ./be.cfg \ port=0, lcore=6, lcore=8, rx_offload=0xf, tx_offload=0,\ ipv4=192.168.1.233, ipv6=2001:4860:b002::28 Will create TLDK UDP context on lcore=6 and lcore=8 (BE lcore) to manage DPDK port 0. Will assign IPv4 address 192.168.1.233 and IPv6 address 2001:4860:b002::28 to that port. The following supported by DPDK RX HW offloads: DEV_RX_OFFLOAD_VLAN_STRIP, DEV_RX_OFFLOAD_IPV4_CKSUM, DEV_RX_OFFLOAD_UDP_CKSUM, DEV_RX_OFFLOAD_ TCP_CKSUM will be enabled on that port. No HW TX offloads will be enabled.

Page 21: DPDK & Layer 4 Packet Processing

Have you run udpfwd in echo mode?

• Doyouhaveoutput–wecanlookat?

Page 22: DPDK & Layer 4 Packet Processing

Wireshark Output of the file created by udpfwd – echo mode

Page 23: DPDK & Layer 4 Packet Processing

tle_udp_dev

What is tle_udp_dev? What it contains?

Page 24: DPDK & Layer 4 Packet Processing

TX

RXRXOffloadFlags

TXOffloadFlags

Context

ProducerHead

ProducerTail

ConsumerHead

ConsumerTail

tle_udp_dport tle_udp_dport

tle_udp_dev

Page 25: DPDK & Layer 4 Packet Processing

What is TLE_UDP_STREAM?

ServerProcess

ClientProcess

ReqResponse

HostnamePort#

TLE_UDP_STREAM

TLE_UDP_STREAM

Page 26: DPDK & Layer 4 Packet Processing

ReqResponse

LinkedListofUDP_Streams

Context

RX

DNS–53DHCP–67…

TX

What is TLE_UDP_STREAM?

Page 27: DPDK & Layer 4 Packet Processing

Req

Response

Req

Response

…….

…….

TLE_UDP_STREAMS

TLE_UDP_STREAMS

TLE_UDP_DEVICE TLE_

UDP_DEVICE

SpinLocksForUDP_STREAMS

SpinLocksForUDP_DEVICES

Context

ContextParameter

Context

What is TLE_UDP_CONTEXT?

Page 28: DPDK & Layer 4 Packet Processing

OneThreadDrivingMulepleContextsAllowedAsIs

…….

MulepleThreadsDrivingSingleContextNOTAllowedAsIs.YouneedtoprovideExplicitsynchronizaeon

Developer’s Responsibility – Scope

Page 29: DPDK & Layer 4 Packet Processing

Callback Model for RECEIVE Callback Model for TRANSMIT

Page 30: DPDK & Layer 4 Packet Processing

Event Model for RX Event Model for TX

Page 31: DPDK & Layer 4 Packet Processing

Can I use Callback for RX & Event no1fica1on for TX?

• Viceversa?

Page 32: DPDK & Layer 4 Packet Processing

Back Up

Page 33: DPDK & Layer 4 Packet Processing

Event/Callback & RX/TX - Combina1ons No?fica?onChoice

EventNo?fySetforSend

CallbackSetforSend

NoNo?fica?onSetforSend

EventNo?fysetforRcv

Forbothreceive&Send,yougetLEVELTRIGGEREDnoeficaeon

YougetLEVELTRIGGEREDForrecv&EDGETRIGGEREDnoeficaeonforSend

OnlyReceivegetsnoefied–LEVELTRIGGERED.NoNoeficaeonforSend

CallbacksetforRcv

YougetEDGETRIGGEREDForrecv&LEVELTRIGGEREDnoeficaeonforSend

Forbothreceive&Send,yougetEDGETRIGGEREDnoeficaeon

OnlyReceivegetsnoefied–EDGETRIGGERED.NoNoeficaeonforSend

NoNo?fica?onsetforRcv

OnlySendgetsnoefied–LEVELTRIGGERED.NoNoeficaeonforRecv

OnlySendgetsnoefied–EDGETRIGGERED.NoNoeficaeonforRecv

NoNoeficaeonforbothsend&Receive

Page 34: DPDK & Layer 4 Packet Processing

Key gdb commands

ptypex DataStructureTypeofstuctx

b<funceonname> Setbreakpoint

clear<funceonname> Clearbreakpoint@funceon

infolocals

gdb--arg./<funceon><args> Debugging

run

conenue

Page 35: DPDK & Layer 4 Packet Processing

Key virsh & ssh commands

sudovirshdomifaddr<HostName>

Sudovirshlist--all

[email protected]....

ipradddefaultvia192.168…devens8 AperrebootofVMs,toresolveanyconnecevityissue

Page 36: DPDK & Layer 4 Packet Processing

Key git & Misc commands

gitlog Returns40bitIDs

gitcheckout<40bitID>

sed-i's/\r$//'filename Windowscontrolcharactersissue

Page 37: DPDK & Layer 4 Packet Processing

Key Objdump commands

Objdump--syms<file.o> Toreadthesymbols

Objdump–S<file.o> Disassemblymixedwithsource+Assembly Objdump–S<file.o>

Objdump–h<file.o> Togetdetailsaboutfile Txt,data,bss,stack

Objdump-x<file.o> Forallheadersindetail

Page 38: DPDK & Layer 4 Packet Processing

Install puTTY • ClicktheURL•  hwp://the.earth.li/~sgtatham/puwy/0.60/x86/• DoubleClickpuwy-0.60-installer.exeopeon•  YouhavedownloadedonyourDownloadfolder• RightClickandRunAsAdministrator•  YouhaveinstalledPuTTY!  NextStepisToConfigurePuTTY

Page 39: DPDK & Layer 4 Packet Processing

PuTTY Config: " Session Screen 1 / 2 1) Host name 2) Port 22 3) Connec1on Type SSH

1stselectthis

Page 40: DPDK & Layer 4 Packet Processing

Keep Alive – 30 sec; Enable TCP Keepalives

40

Page 41: DPDK & Layer 4 Packet Processing

If you are outside

41

Page 42: DPDK & Layer 4 Packet Processing

PuTTY Config: Connec1on -- > Proxy Screen 2 / 2 1)  ProxyType:None2) Proxyhostname:Leaveitblank3) DoDNSnamelookupatproxyend:Auto

!  NextStepisToSaveTheConfigura?on

Page 43: DPDK & Layer 4 Packet Processing

1) Name The Configura1on. 2) Save It

!  Click“Session”onthetopledcorner.

!  Itwilltakeyoutothe1stscreen-shownhere.

!  InSavedSessonsBox,Enteraname,e.g.,dpdktrainingcluster

!  PressSaveBueon.

!  Fromnowonwards,youcanloadthesavedsessionwhenstar?ngPuTTY

Page 44: DPDK & Layer 4 Packet Processing

Gejng To The HostVM-<m> through Cluster Jump Server

Page 45: DPDK & Layer 4 Packet Processing

Start PuTTY

•  FindPuTTYthatyoujustinstalled•  Clickonicon“puwy.exe”.YouwillgetthePuTTYConfigScreen•  SelecttheSavedSession,shownheree.g.,dpdktrainingcluster.•  PressLoadBuwon.PressOpenBuwon.•  Youwillgetsshsessionshownin3rdscreenaskingusername

•  Username:student<m><m>isgiventoyou.Forexampleitmaybestudent19orstudent25oranyotherstudent<m>.

•  Askforyourspecific<m>anduseonlythat.Thiswillavoidoverlappingwithotherteams’<m>.

•  Passwordissameasusername.Forexample,ifyourusernameisstudent19,thenpasswordisstudent19

•  Repeattheabovestepssothatyouhavemanyconneceonstothejumpserver

Page 46: DPDK & Layer 4 Packet Processing

How to login and Connect to HostVM-<m>

•  Loginasstudent<m>passwordstudent<m>•  ThenextstepistoconnecttoHostVM-<m>assignedtoyou.

•  Incasenotgiven,Askforyourown<m>

•  Note:Weareusing1:1–samestudentnameandsameHostVM-name

•  Typeinthefollowingcommand

• sshHostVM-<m>•  Username:passwordPassword:password•  sudosu–•  cd/home/user/dpdk_hands_on• Vicommands.txt

Page 47: DPDK & Layer 4 Packet Processing

Open 2 Windows

ssh HostVM-<M>

Password is password

sudo su –

cd /

47

ssh HostVM-<M>

Password is password

sudo su -

cd /

vi Cpy_PasteFromMe.txt

B) NEXT, in the 2nd Window, enter these commands A) FIRST, In the 1st Window, enter these commands

1)  Only Highlight from the vi in this Window This is your “Highlight to Copy From Window” Don’t Click. i.e., Don’t Select. Only Highlight

./00_installTools.sh

1

2

3 Right Click in this Window to Paste

Page 48: DPDK & Layer 4 Packet Processing

Cpy_Paste From Me.txt #Cpy_PasteFromMe.txt

sudo su -

cd /

./00_ReserveHugePage.sh

source 01_SetEnvironmentVariables.sh

cd $RTE_SDK

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

**** Please be patient

*** The following commands will take time to start

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

make config T=$RTE_TARGET

make

make install T=$RTE_TARGET

cd $GTEST_DIR

cmake CMakeLists.txt

make

cd $TLDK_ROOT

make clean

make all O=$RTE_TARGET

48

# *********** TEST 1 **************************************

# Shall we take a look at key data structures?

# For that let us use gdb and run Dynamic Ring Buffer Tests

# *********************************************************

# *********************************************************

gdb --arg ./x86_64-native-linuxapp-gcc/app/test_dring

# Set BreakPoints

b drb_dump

b tle_dring_dump

run

#Examine dynamic ring

ptype dr

# Examine dynamic buffer

ptype db

continue

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

Page 49: DPDK & Layer 4 Packet Processing

STOP! OBSERVE the tle_dring structure

WHAT DO YOU SEE?

Producer / Consumer pointers with Head and Tail Pointers.

WHAT VALUE YOU SEE for Head and Tail Pointers?

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

continue

continue

****

STOP: Now what value you see for head and tail pointers

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

continue

# type continue till you see [Inferior 1 (process <> exited normally]

quit

# ********** TEST 2 ****************************************

# Now run the same dring test without gdb

# *********************************************************

./x86_64-native-linuxapp-gcc/app/test_dring

49

#********************************************************** #************TEST 3 ************************************ # Shall we run the Layer 4 UDP Application? Echo mode? #******************************************************* cd $TLDK_ROOT ./02_run_UDP_Echo_Test.sh # Check that all packet in output pcap file contain valid udp checksum:

Page 50: DPDK & Layer 4 Packet Processing

How do you “repair” the build problem with gtest?

Page 51: DPDK & Layer 4 Packet Processing

How To Repair Build error? •  unsetGMOCK_DIR•  unsetGTEST_DIR

•  cd$TLDK_ROOT•  cdmakeclean•  MakeallO=$RTE_TARGET

•  cdgoogletest_feb2017•  cmakeCMakeLists.txt•  Make

•  exportGTEST_DIR=/googletest_feb2017/googletest•  exportGMOCK_DIR=/googletest_feb2017/googlemock

•  cd$TLDK_ROOT•  makeclean•  makeallO=$RTE_TARGET