Michaelmas 2009Building an Internet Router (P33)Handout 1 1 Building an Internet Router (P33)...
-
Upload
kole-colliver -
Category
Documents
-
view
217 -
download
0
Transcript of Michaelmas 2009Building an Internet Router (P33)Handout 1 1 Building an Internet Router (P33)...
Michaelmas 2009 Building an Internet Router (P33)Handout 1
1
Building an Internet Router (P33)
Handout 1: What’s a router?Class project and logistics
Dr Andrew W. [email protected]
Thank yousupporters:
Michaelmas 2009 Building an Internet Router (P33)Handout 1
2
Some logisticsWeb page: http://www.cl.cam.ac.uk/teaching/0910/P33/
TAs:David Miller (Hardware) [email protected] Stephen Kell (Software) [email protected]
Hot-spare TAs: Phil Watts (Hardware) philip.watts @cl.cam.ac.uk
Chris Smowton (Software) [email protected]
Grades: Mphil (ACS) – Pass / Fail - based on a mark out of 100All others (DTC) – Mark out of 100
3
Some more logistics
Class Mailing list: [email protected] think of this as a self-help mailing list for all of you
Staff Mailing list: [email protected]
Submission mail: [email protected]
Group aliases can appear if you require them.
4
What is Routing?
R3
A
B
C
R1
R2
R4 D
E
FR5
R5F
R3E
R3D
Next HopDestination
D
5
What is Routing?
R3
A
B
C
R1
R2
R4 D
E
FR5
R5F
R3E
R3D
Next HopDestination
D
16 3241
Data
Options (if any)
Destination Address
Source Address
Header ChecksumProtocolTTL
Fragment OffsetFlagsFragment ID
Total Packet LengthT.ServiceHLenVer
20
byte
s
6
What is Routing?
A
B
C
R1
R2
R3
R4 D
E
FR5
7
Points of Presence (POPs)
A
B
C
POP1
POP3POP2
POP4 D
E
F
POP5
POP6 POP7POP8
8
Where High Performance Routers are Used
R10 R11
R4
R13
R9
R5
R2R1 R6
R3 R7
R12
R16R15
R14
R8
(10 Gb/s)
(10 Gb/s)(10 Gb/s)
(10 Gb/s)
9
What a Router Looks LikeCisco CSR-1 Juniper T320
6ft
19”
2ft
Capacity: 92Tb/sPower: 4.7kW
3ft
2.5ft
19”
Capacity: 320Gb/sPower: 2.9kW
10
Basic Architectural Components
of an IP Router
Control Plane
Datapathper-packet processing
SwitchingForwarding
Table
Routing Table
Routing Protocols
Management& CLI
Softw
are
Hard
ware
11
Per-packet processing in an IP Router
1. Accept packet arriving on an incoming link.2. Lookup packet destination address in the
forwarding table, to identify outgoing port(s).
3. Manipulate packet header: e.g., decrement TTL, update header checksum.
4. Send packet to the outgoing port(s).5. Buffer packet in the queue.6. Transmit packet onto outgoing link.
12
Generic Router Architecture
LookupIP Address
UpdateHeader
Header ProcessingData Hdr Data Hdr
~1M prefixesOff-chip DRAM
AddressTable
AddressTable
IP Address Next Hop
QueuePacket
BufferMemoryBuffer
Memory~1M packetsOff-chip DRAM
13
Generic Router Architecture
LookupIP Address
UpdateHeader
Header Processing
AddressTable
AddressTable
LookupIP Address
UpdateHeader
Header Processing
AddressTable
AddressTable
LookupIP Address
UpdateHeader
Header Processing
AddressTable
AddressTable
Data Hdr
Data Hdr
Data Hdr
BufferManager
BufferMemory
BufferMemory
BufferManager
BufferMemory
BufferMemory
BufferManager
BufferMemory
BufferMemory
Data Hdr
Data Hdr
Data Hdr
14
The P33 Project:Build a 4-port x 1GE Router
SwitchingForwarding
Table
Routing Table
Routing Protocols
Management& CLI
Softw
are
Hard
ware
Software TeamDevelop s/w in Linuxon PC in lab
Hardware TeamDevelop h/w in Verilogon NetFPGA boardin lab
ExceptionProcessing
15
softwarehardware
SwitchingForwarding
Table
Routing Table
Routing Protocols
Management& CLI
ExceptionProcessing
InteroperabilityBuild basic router Routing Protocol(PWOSPF)
Integrate with H/W
Emulatedh/w in VNS
Routing Table
Routing Protocols
Management& CLI
ExceptionProcessing
Emulatedh/w in VNS
Routing Table
Routing Protocols
Management& CLI
ExceptionProcessing
Emulatedh/w in VNS
Routing Table
Routing Protocols
Management& CLI
ExceptionProcessing
Command Line Interface
1 2 3 4 5 6Wow us!
• Innovate and add!• Presentations• Judges
4-port non-learningswitch
4-port learningswitch
IPv4 routerforwarding path
Integrate with S/W Interoperability Wow us!
SwitchingForwarding
Table
Learning Environment Modular design
Testing
21/Oct 28/Nov 5/Nov 11/Nov 18/Nov 10/Jan
21/Oct 28/Nov 5/Nov 18/Nov11/Nov 10/Jan
FPGAFPGA
MemoryMemory
1GE1GE
1GE1GE
1GE1GE
1GE1GE
What is the NetFPGA?
PCI
CPUCPU MemoryMemory
NetFPGA Board
PC with NetFPGA
NetworkingSoftwarerunning on a standard PC
A hardware acceleratorbuilt with Field Programmable Gate Arraydriving Gigabit network links
FPGAFPGA
MemoryMemory
1GE1GE
1GE1GE
1GE1GE
1GE1GE
Running the Router Kit
User-space development, 4x1GE line-rate forwarding
PCI
CPUCPU MemoryMemory
PW-OSPFPW-OSPFuser
kernelRouting
Table
IPv4RouterIPv4
Router
1GE1GE
1GE1GE
1GE1GE
1GE1GE
FwdingTable
FwdingTable
PacketBufferPacketBuffer
ExceptionProcessingExceptionProcessing
Management (including CLI)Management (including CLI)
“Mirror”
18
Next steps
Explore the web page(http://www.cl.cam.ac.uk/teaching/0910/P33/)
Decide if you still want to take the class Build a team of 3 people: 2 s/w and 1 h/w Come to SW02 on Tuesday 10am…
We will meet with you every week during class time.
Using the nf-test machines
Each group is allocated an nf-test machine{nf-test1,nf-test2,nf-test3,...}.nf.cl.cam.ac.uk
These machines are headless (no KVM) and located in SW02 (alcove)
Login via ssh; set your own password and goWe suggest running “vncserver” and then using “vncviewer”;
as a useful way to leave jobs/desktop running and reconnect if you need to move location.
SW02 is a busy classroom – please respect othersIf you need to gain physical access to an nf-test
machine
Do it quietly! You maybe refused entry in the afternoons – don’t take it
personally.
nf-test machine rules
Abuse the machines – that’s the end of this module for you – zero tolerance policy.
only connect eth0 to the cisco (access) switch
these machines run a firewall for a reason if it doesn’t work for you, lets fix the rules
Play nicely with each other; your interoperability marks depend on it.
nf-test machine information
Warning: Files stored on nf-test machines are not backed up - and may be lost at any time.
You must make sure that you regularly copy your files into your REAL (computer laboratory) home directory as a back-up
Machines fail – they usually fail 24 hours before the big deadline!
Building an Internet Router (P33) Michaelmas 2009 22
Tree Structure
NF2
binbin
liblib
projectsprojects
bitfilesbitfiles
(scripts for running simulations and setting up the environment)(scripts for running simulations and setting up the environment)
(contains the bitfiles for all projects that have been synthesized)(contains the bitfiles for all projects that have been synthesized)
(stable common modules and common parts needed for simulation/synthesis/design)(stable common modules and common parts needed for simulation/synthesis/design)
(user projects, including reference designs)(user projects, including reference designs)
Building an Internet Router (P33) Michaelmas 2009 23
Tree Structure (2)
lib
CC
javajava
MakefilesMakefiles
Perl5Perl5
pythonpython
scriptsscriptsverilogverilog
(common software and code for reference designs)(common software and code for reference designs)
(contains software for the graphical user interface)(contains software for the graphical user interface)
(makefiles for simulation and synthesis)(makefiles for simulation and synthesis)
(common libraries to interact with reference designs and aid in simulation)(common libraries to interact with reference designs and aid in simulation)
(common libraries to aid in regression tests)(common libraries to aid in regression tests)
(scripts for common functions)(scripts for common functions)
(modules and files that can be reused for design)(modules and files that can be reused for design)
Building an Internet Router (P33) Michaelmas 2009 24
Tree Structure (3)
projects
docdoc
includeinclude
regressregress
srcsrc
swsw
synthsynthverifverif
(project specific documentation)(project specific documentation)
(contains file to include verilog modules from lib, and creates project specific register defines files)(contains file to include verilog modules from lib, and creates project specific register defines files)
(regression tests used to test generated bitfiles)(regression tests used to test generated bitfiles)
(contains non-library verilog code used for synthesis and simulation)(contains non-library verilog code used for synthesis and simulation)
(all software parts of the project)(all software parts of the project)
(contains user .xco files to generate cores and Makefile to implement the design)(contains user .xco files to generate cores and Makefile to implement the design)
(simulation tests)(simulation tests)
Building an Internet Router (P33) Michaelmas 2009 25
State Diagram to Verilog (1)
MACRxQMACRxQ
CPURxQCPURxQ
MACRxQMACRxQ
CPURxQCPURxQ
MACRxQMACRxQ
CPURxQCPURxQ
MACRxQMACRxQ
CPURxQCPURxQ
Input ArbiterInput Arbiter
Output Port LookupOutput Port Lookup
MACTxQMACTxQ
CPUTxQCPUTxQ
MACTxQMACTxQ
CPUTxQCPUTxQ
MACTxQMACTxQ
CPUTxQCPUTxQ
MACTxQMACTxQ
CPUTxQCPUTxQ
Output QueuesOutput Queues
Building an Internet Router (P33) Michaelmas 2009 26
Inter-module Communication
datadata
ctrlctrlwrwrrdyrdy
Building an Internet Router (P33) Michaelmas 2009 27
State Diagram to Verilog (2)
• Projects:– Each design represented by a project
Format: NF2/projects/<proj_name>
e.g., NF2/projects/bir_starter
– Consists of:
– What is Missing?• refer to the web page
“Implement four port hard-wired switch” is the start.
•Verilog source•Simulation tests•Hardware tests
•Verilog source•Simulation tests•Hardware tests
•Libraries•Optional software•Libraries•Optional software
Building an Internet Router (P33) Michaelmas 2009 28
State Diagram to Verilog (3)
• Projects (cont):– Pull in modules from NF2/lib/verilog
• Generic modules that are re-used in multiple projects
• Specify shared modules in project’s include/lib_modules.txt
– Local src modules override shared modules
– bir_starter:• Local in_arb_regs.v input_arbiter.v
output_port_lookup.v• Everything else: shared modules
Building an Internet Router (P33) Michaelmas 2009 29
Testing: Simulation (1)
• Simulation allows testing without requiring lengthy synthesis process
• NetFPGA provides Perl simulation infrastructure to:– Send/receive packets
• Physical ports and CPU– Read/write registers– Verify results
• Simulations run in ModelSim/VCS
Building an Internet Router (P33) Michaelmas 2009 30
Testing: Simulation (2)
• Simulations located in project/verif• Multiple simulations per project
– Test different features• Example:
– bir_starter/verif/test_fwd_sourcePort0• Test forwarding of packets from port 0 to port 1
Building an Internet Router (P33) Michaelmas 2009 31
Testing: Simulation (3)
• Example functions:– nf_PCI_read32(delay, batch, addr, expect)– nf_PCI_write32(delay, batch, addr, value)– nf_packet_in(port, length, delay, batch, pkt)– nf_expected_packet(port, length, pkt)– nf_dma_data_in(length, delay, port, pkt)– nf_expected_dma_data(port, length, pkt)– make_IP_pkt(length, da, sa, ttl, dst_ip, src_ip)
Building an Internet Router (P33) Michaelmas 2009 32
Running Simulations
• Use command nf2_run_test.pl– Optional parameters
• --major <major_name>• --minor <minor_name>• --gui (starts the default viewing environment)
test_fwd_sourcePort0
• Problems? check the environment variables reference your project
• NF2_DESIGN_DIR=/root/NF2/projects/<project>• PERL5LIB=/root/NF2/projects/<project>/lib/Perl5: /root/NF2/lib/Perl5:
majormajor minorminor
Building an Internet Router (P33) Michaelmas 2009 33
Running Simulations
• When running modelsim interactively:– Click "no" when simulator prompts to finish
– Changes to code can be recompiled without quitting ModelSim:
• bash# cd /tmp/$(whoami)/verif/<projname>; make model_sim• VSIM 5> restart -f; run -a
– Problems?do ensure $NF2_DESIGN_DIR is correct
Building an Internet Router (P33) Michaelmas 2009 34
Synthesis
• To synthesize your project– Run make in the synth directory
(/root/NF2/projects/bir_starter/synth)
Building an Internet Router (P33) Michaelmas 2009 35
Regression Tests
• Test hardware module
• Perl Infrastructure provided includes: – Read/Write registers– Read/Write tables– Send Packets– Check Counters
Building an Internet Router (P33) Michaelmas 2009 36
Example Regression Tests
• For a Router… – Send Packets from CPU– Longest Prefix Matching– Longest Prefix Matching Misses– Packets dropped when queues overflow– Receiving Packets with IP TTL <= 1– Receiving Packets with IP options or non IPv4– Packet Forwarding– Dropping packets with bad IP Checksum
Building an Internet Router (P33) Michaelmas 2009 37
Perl Libraries
• Specify the Interfaces– eth1, eth2, nf2c0 … nf2c3
• Start packet capture on Interfaces
• Create Packets– MAC header– IP header– PDU
• Read/Write Registers
• Read/Write Reference Router tables– Longest Prefix Match– ARP– Destination IP Filter
Building an Internet Router (P33) Michaelmas 2009 38
Regression Test Examples
• Reference Router– Packet Forwarding
• regress/test_packet_forwarding
– Longest Prefix Match• regress/test_lpm
– Send and Receive • regress/test_send_rec
Building an Internet Router (P33) Michaelmas 2009 39
Creating a Regression Test
• Useful functions:– nftest_regwrite(interface, addr, value)– nftest_regread(interface, addr)– nftest_send(interface, frame)– nftest_expect(interface, frame)
– $pkt = NF2::IP_pkt->new(len => $length, DA => $DA, SA => $SA, ttl => $TTL, dst_ip => $dst_ip, src_ip => $src_ip);
Building an Internet Router (P33) Michaelmas 2009 40
Creating a Regression Test (2)
• Your task:
1. Template files /root/NF2/projects/bir_starter/regress/test_fwd_sourcePort0/run.pl
2. Implement your Perl verif tests
Building an Internet Router (P33) Michaelmas 2009 41
Running Regression Test
• Run the commandnf2_regress_test.pl --project bir_starter