server library access on fpga - xlynsxlyns.com/server library fpga final report.pdf · server...

34
Server Library access on FPGA Design Report Server Library access on FPGA A new user friendly FPGA Library access page forged for ease of use of the FPGA man-machine interface based on the Web that connects the FPGA accessing its online Database controlling the Memory contents TROENDLE PETER-PAUL [email protected] This part of work defined by the Co-op Course CIS-140 was also submitted today to Juergen Pintaske (ExMark), he was in the teams that brought the 1802 RCA that competed with the first 6802 Motorolla DSPs Note: the Code structure was defined in last the Autum 2014 previous Report and the Data processing in the Spring 2014 first Report both for the Highline Community College US 10 MARCH 2014 Adviser: RAVINDER KANG COMPUTING SCIENCE HIGHLINE COMMUNITY COLLEGE DES MOINES WA page 1 of 34

Upload: voquynh

Post on 09-Apr-2018

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Server Library access on FPGA

A new user friendly FPGA Library access page forged for ease of use of the FPGA man-machine interface

based on the Web that connects the FPGA accessing its online Databasecontrolling the Memory contents

TROENDLE [email protected]

This part of work defined by the Co-op Course CIS-140 was also submitted today to Juergen Pintaske (ExMark),

he was in the teams that brought the 1802 RCAthat competed with the first 6802 Motorolla DSPs

Note: the Code structure was defined in last the Autum 2014 previous Report

and the Data processing in the Spring 2014 first Report both for the Highline Community College

US

10 MARCH 2014

Adviser: RAVINDER KANG

COMPUTING SCIENCEHIGHLINE COMMUNITY COLLEGE

DES MOINES WA

page 1 of 34

Page 2: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Table of ContentsMarketing Aim....................................................................................................................................... 4Objectives.............................................................................................................................................5Introduction........................................................................................................................................... 7Features................................................................................................................................................ 8

Products Required.............................................................................................................................9Hardware....................................................................................................................................... 9Tools Required (free)......................................................................................................................9Design Status.................................................................................................................................9

Background....................................................................................................................................... 9Why This Project?..........................................................................................................................9Reference Material.........................................................................................................................9References.....................................................................................................................................9

Acknowledgments...............................................................................................................................10Project Summary.................................................................................................................................10

Server Database using MySQL.......................................................................................................10Web PHP binds the Database for HTML.........................................................................................10FPGA TCP triggers the PHP for HTML............................................................................................10

Detailed Design...................................................................................................................................11Server side.......................................................................................................................................... 12

HTML............................................................................................................................................... 12HTML Listing................................................................................................................................12

PHP to read the database...............................................................................................................15PHP to read the graph.....................................................................................................................18PHP to WRITE into the database....................................................................................................21MySQL............................................................................................................................................ 26

FPGA side........................................................................................................................................... 27DNS................................................................................................................................................. 27ARP................................................................................................................................................. 28

TCP..................................................................................................................................................... 28TCP definition..................................................................................................................................29Packet tranferred.............................................................................................................................31TCP connection...............................................................................................................................32TCP 3 way handshake.....................................................................................................................32Checksum........................................................................................................................................33

Architecture......................................................................................................................................... 34Muxcodes program for the TCP.......................................................................................................34

Conclusion.......................................................................................................................................... 34

page 2 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 3: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Illustration IndexIllustration 1......................................................................................................................................... 12Illustration 2......................................................................................................................................... 18Illustration 3......................................................................................................................................... 21Illustration 4......................................................................................................................................... 25Illustration 5......................................................................................................................................... 26Illustration 6......................................................................................................................................... 27Illustration 7......................................................................................................................................... 31Illustration 8......................................................................................................................................... 32Illustration 9......................................................................................................................................... 33

page 3 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 4: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Marketing Aim

The first question why Server Library access for the FPGA?

1. Re-usability is guaranteed once someone tested a programm others need not create it again2. The issue with the different software versions can be resolved if all use a central repository for

download of the up to date version3. Instead of manually using programming cables and other communication means to access the

FPGA the Ethernet can be used that is the State of the Art in speed and performance and well tested

4. The Data can be lost in hasardous environements and if the FPGA is downloading or uploading to the server it renders the data safe (this is the cloud idea)

The next question how is it done? See present report

The next question what do we not need any more to do?1. The Man-Machine Interface is no longer required because one can use the Ethernet that

allows the use of a web page that one can access from the key board and screen. Hence the Drivers for Data entry, Key board man machine interface, HDMI VGA graphics, PCI Express, Rocket IO etc.. are also obsolete

2. The separate programming cables and other connectors, PMC, HDMI, VGA, LVDS, UART, USB, PCI etc.. are also obsolete the database is accessed directly

3. The Data monitoring tools are also obsolete the monitoring is done by graph that catpures in real time the signals in the RAM like an internal oscillscolpe. Hence the Digital Trace Oscilloscopes, Logic Analyzers, Simulation tools or even Chipscope also

The last question who needs it?1. People that want to work in a clean lab : no hundrets of different cables and protocolls of

connecting each using diffefrent frequencies amplitudes and signal shapes, basically creating EMC noise

2. Speed of implementation, each feature that needs to be “added” for functionality is costing timeand the set up is often with delays that people do not want

3. The Industry and Laboratories need to have simple equipments because less parameters mean less errors and help them focus more on their task

4. The FPGA is really needed because it can measure with 2.5-8nS lags while the common Processing and DSP units are 1-7uS lag so it is a factor of 1000. Additionally one can have theFPGA having several functions anf filters in real time and parallel the others cant

5. People seeking for computing with no lag for traffic management, gaming, accurate trading etc.

page 4 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 5: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Objectives

The global objectives that seem to be urgently required that mostly came across, where:

ACHIEVING SMALLER COSTS :

*Considering that the connectors often cost the same price then the microchips….The data entry and processing can be linked to web data or other data sources without the need or cost of having to have the connectors* and medium for tranferring the CD, DVD, USB, SD card, ext drive, etc..The Debugging, Monitoring and Testing does not need the usual bulky expensive measurement equipments because the real time events can be captured within and shown on the web page graph.The Man Machine needs not be extra one can use the own laptop or what is already present for the web accessWhat is the biggest cost are the many several BILLIONS that went into the Firmware developpment due to the re-usability issue of the FPGA: unlike Software that are re-usable and can auto -update on the run whitout the whole sustem needed re-engineering. The challenge here is to remove the synthesis requirement and allow for the re-configuration on the run where the FPGA accesses the code from the Server online Libraries allowing for modifications to be done partially without affecting the wholeA change of color tone? That would no longer mean a redesign and re synthesis and several Engineers working several weeks.. That making it obvious why Industry still pays for the slower and much laggyer solutions but that any skilled person can program in a few hours only and sometimes really less

ACHIEVING LESS POWER CONSUMPTION:

The FPGA can be much smaller size and consume far less than if it had the memory and all programms and data libraries. It can be used in common by several users in the same time.Because the computing is faster the amount of requests handled by one machine is significantly higher hence there is less need for whole datacenters rooms one single machine can do the same as 1000 machines that are 1000 times slower?

page 5 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 6: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

SECURITY:

The central database is kept in Server provider that belongs to the big ones and have the best tools against intrusions, nevertheless there is the additional benefit that all database data can be stored in several backups and if some entries are questionable not only all user identoification details will be apparent but also the data is purely passive in the database so if it causes harm on the FGPA locationthey so not even need to “pull the plug” that instance will simply revert to previous version and flaf the current. And that means in effect simply that the backup will be requested to provide the previous version and it will be added to the current database like a new CLUSTER, while the one that was flagged will be reviewed and the error entry fixed or the whole deleted. The CLUSTER model means that any additional codes that gets flagged due to errors are then taken back in the “workshop” allowing for the operational units to always be the state of the art and fully functionnal

Why do all need to debug the same error or 'virus” and fix it again and again when it is enough that it is done just once and that bis it ACHIEVING FASTEST RUN TIME:

The FPGA is able to have several hundret Ios in parallel that are totally orthogonal and with response times of 1-2nS is there more to say?

ROBUST DESIGN ENTRY

One Chip for the PHYOne RJ45 ConnectorOne PowersupplyOne FPGA

OK that is our supermachine :)

no need for all the wires and connectors etc.. :)

page 6 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 7: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Introduction

There are some very exiting prospects for FPGA's to take up with speed with respect to the DSP's or Processors that use Software. Previously was shown simple methods to get PARALLEL DSP cores onthe FPGA, that use Systolic Arrays N x N of 1 Bit ALUs bitslice. The core automatically binds the math formulas into the scalable data path using bit slice.

This design is just an example of what is now achieved, many more will crush the barrier wide open now the opening is becoming apparent and I am sure many amazing designs are to come even those that never used the FPGA will start to feel more at home!

The aim is to show everyone how any Processing requirement can be done in a programmable way using the FPGA without needing the re-synthesis. This report documents how it is done:

The idea is to have the FPGAs connected to a server and they are run by the data/code that the user enters in the server database suing a web page HTML form. The FPGA executes the code that is defined as a Shapes (German = Gestalt) on data that is also defined as a Shapes that is simply a listing. A Sine Wave Shapes could be defined in 256 points per ex. or also any other data and the code listings will also be defined that way.

Once it starts to run and it gets to life the monitoring can also be defining any location and timneset or triggers and the result visible on the online graph en effect allowing for monitoring as if there was an internal oscilloscope.

The idea of the Server Library is to facilitate the programming of the FPGA (no extra cable) and monitoring (no extra Simulation envirinment or Oscilloscope or Logic Analyzer) and also usage (no FPGA is needed onecan use the one on the server). The Programming is also mainly based on simpleDatapath definitions using the muxcodes (no Instruction NISC is defined in the previous report).

All this makes the solution easier to use whereas using the FPGA with no hassle

Lot's of fun.

page 7 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 8: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Features

After synthesis to have up to several blocks within the FPGA that would offer the flexibility of RE-CONFIGURING the custom units used and for having also several instances run together in a RE-PROGRAMMABLE manner so one FPGA could be used for several different tasks in run time with no re-synthesis required, because the re-synthesis synthesis introduces hazards in the design due to it's non- deterministic implementation.

The FPGA will have the Systolic Array ready and the Memory with a default program that will simply get the HTTP and fetch the program defined

We use the switches of the NEXYS4 they define the Bootstrap Shape that needs to be fetched

Following functions would need to be defined in a flexible manner and be re-defined during RUNTIME within ONE CLOCK CYCLE:

- N samples sorting in 1 clock- N samples searched in 1 clock- N-th root algorithm demo- N x M algebra or logic in 1 clock- avalanche Math (e.g. TCP Checksum)

The Systolic Arrays would be merged in one big unit and the Memory clusters filled with Shapes thatwill have the data/code stream in the structure and if there is overflow the system will simply requirean extra clock.

This means that for a good size of FPGA “cloud” all instructions and programs should be able toresolve simultanaously in one clock cycle

ALL THE ABOVE USE JUST 1 developpment board(per ex. 110-290$)with the FPGA (per ex. 110$) on it an PHY chip (per ex. 1.21 $)(these are the values I paid and I am writing them as such here)

Now how we done it?

page 8 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 9: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Products Required

Hardware

The Nexys4 board is a complete, ready-to-use digital circuit development platform based on the latestArtix-7™ Field Programmable Gate Array (FPGA) from Xilinx. With its large, high-capacity FPGA (Xilinx part number XC7A100T-1CSG324C).

Tools Required (free)

Wireshark Version 1.12.4 (v1.12.4-0-gb4861da from master-1.12) (alternative to Wireshark: Message Analyser V 1,2 Build 4.0.7285.0) Colapackets http://www.colasoft.com/packet_builder/

Design Status100 % Design description is done with this document for the Server Library for FPGA in particular:

1. Definition of the Database2. Definition of the Active Web page (PHP)3. TCP connection to the FPGA

Background

Why This Project?

The DSP and software solution offer more flexible solutions than the common FPGA hardware and designing boards, even if they are much faster they are STUCK because the synthesis cannot be changed that easily. Here the though was to get the advantages of state of the art electronics and BRIDGE THE GAP between it's hardware attributes and what the DSP, Software people are able to do.

Reference Material

For the finished and tested NISC ALU unit see Documentation following the public Link: http://www.digilentdesigncontest.com/uploads/2/2/7/9/22797146/excel_on_fpga.zip

For the description of the Muxcodes control unit :http://www.xlyns.com/Muxcodes-Programing.html

References Efficient PC-FPGA Communication over Gigabit Ethernet:

http://ieeexplore.ieee.org/xpl/articleDetails.jsp?arnumber=5577968

page 9 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 10: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

About the PHP codehttp://php.net/

About HTML and SQL:http://www.w3schools.com/

Acknowledgments

For to get the Server done here those that helped me the most:

- Nick Beaumont that introduced the PHP and MySQL solutions within HTML basically helping to migrate the initila www.xlyns.com page that was a Google Site creation (no php or sql) to the eNom servers.

- Great support at eNom many thanks!

- Nikos Alachiotis from the Carnegie Mellon University

And all the great people here spending a lot of time and giving so many invaluable advices, without you all I would not be able to achieve and I am so grateful!!

Project Summary

Server Database using MySQL

The Table is enterd on the server side using their interface and SQL

Web PHP binds the Database for HTML

The Read Write operations and Graph outputs using the HTML for the user data entry and monitorand the Database to Read and Writes the needed Data

The FPGA can read the sinewave graph from the database and show it on a webpageOr it can be processed and the result wave also looked at thae same way

FPGA TCP triggers the PHP for HTML

Access to the FPGA using the HTML GET/POST Datagram placed AdHoc after the PC MAC/IP connection

page 10 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 11: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Detailed Design

uses protocols (FPGA side):

RFC

793 - TCP Transmission Control Protocol791 - IP Internet Protocol826 - ARP An Ethernet Address Resolution Protocol1071 -Checksum Computing the Internet checksum

Uses scripting (Server side):

APACHE DirectoryIndex xlyns.htmlthis line saved as text with .htaccess extension

PHP Binding the MySQL to collect or output the Data:instruction_processor.phpGRAPH.phpfview_instruction.php

MySQL Definition of the DatabaseHTML Creation of the Webpage:

FPGA-feeder.html

The next sections detail more on these and that is the base of the design, how the design is done

page 11 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 12: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Server side

HTML

Here the Form and it is hosted by eNom with the domain

HTML Listing

The first line defines the binding PHP file that will be used to WRITE to the database:form action="/instruction_processor.php" Further on the READ is done with 2 methods, the graphical and table form:form action="/GRAPH.php?shape=GRAPH"form action="/view_instruction.php?shape=FORTH"

after the question mark ? The default values is given the user can change the variable (it corresponds to the “Shape” field): here an example:

page 12 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 1

Page 13: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

http://www.xlyns.com/view_instruction.php?shape=MESSAGE

Here the user can select another Shape name, as example Shape = message2then he can call the page and just needs to write in the browser address field ?shape=message2

Here from www.xlyns.com/FPGA-feeder.html (right click and select view source):

<form action="/instruction_processor.php" autocomplete="off" id="id_0___" method="post" target="_blank"> <table border="1"> <tbody><tr> <td width="400">&nbsp;</td> <td width="400">

Shape <br> <input autocomplete="off" class="bodytext" id="id_1___" maxlength="16" name="shapes" size="16" type="text" value=""> </td>

<td width="400"> Alias <br> <input autocomplete="off" class="bodytext" id="id_2___" maxlength="16" name="alias" size="16" type="text" value=""> </td></tr>

<tr> <td width="400">direct</td> <td width="400"> dst muxcode<br> <input autocomplete="off" class="bodytext" id="id_3___" maxlength="4" name="full_namea1" size="4" type="text" value="101"> </td> <td width="400"> alucode<br> <input autocomplete="off" class="bodytext" id="id_4___" maxlength="4" name="full_namea2" size="4" type="text" value="102"> </td> <td width="400"> src muxcode<br> <input autocomplete="off" class="bodytext" id="id_5___" maxlength="4" name="full_namea3" size="4" type="text" value="104"> </td> </tr> <tr> <td width="400">immediate</td> <td width="400"> dst muxcode<br> <input autocomplete="off" class="bodytext" id="id_6___" maxlength="4" name="full_nameb1" size="4" type="text" value=""> </td> <td width="400"> MM<br> <input autocomplete="off" class="bodytext" id="id_7___" maxlength="4" name="full_nameb2" size="4" type="text" value=""> </td> <td width="400"> MM<br> <input autocomplete="off" class="bodytext" id="id_8___" maxlength="4" name="full_nameb3" size="4" type="text" value=""> </td> </tr> <tr> <td width="400">relative</td> <td width="400"> @NN<br> <input autocomplete="off" class="bodytext" id="id_9___" maxlength="4" name="full_namec1" size="4" type="text" value=""> </td> <td width="400"> alucodes<br> <input autocomplete="off" class="bodytext" id="id_10___" maxlength="4" name="full_namec2" size="4" type="text" value=""> </td> <td width="400"> src @NN<br> <input autocomplete="off" class="bodytext" id="id_11___" maxlength="4" name="full_namec3" size="4" type="text" value=""> </td>

page 13 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 14: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

</tr> <tr> <td width="400">jump</td> <td width="400"> @NN<br> <input autocomplete="off" class="bodytext" id="id_12___" maxlength="4" name="full_named1" size="4" type="text" value=""> </td> <td width="400"> MM<br> <input autocomplete="off" class="bodytext" id="id_13___" maxlength="4" name="full_named2" size="4" type="text" value=""> </td> <td width="400"> MM<br> <input autocomplete="off" class="bodytext" id="id_14___" maxlength="4" name="full_named3" size="4" type="text" value=""> </td> </tr> <tr> <td width="400">branch jump</td> <td width="400"> Qcode<br> <input autocomplete="off" class="bodytext" id="id_15___" maxlength="4" name="full_namee1" size="4" type="text" value=""> </td> <td width="400"> ALU<br> <input autocomplete="off" class="bodytext" id="id_16___" maxlength="4" name="full_namee2" size="4" type="text" value=""> </td> <td width="800"> QQ<br> <input autocomplete="off" class="bodytext" id="id_17___" maxlength="8" name="full_namee3" size="8" type="text" value=""> </td> </tr>

<tr> <td width="400">loop jump</td> <td width="800"> final value<br> <input autocomplete="off" class="bodytext" id="id_18___" maxlength="8" name="full_namef1" size="8" type="text" value=""> </td> <td width="800"> current value<br> <input autocomplete="off" class="bodytext" id="id_19___" maxlength="8" name="full_namef2" size="8" type="text" value=""> </td> </tr> <tr> <td align="center" colspan="4"> <input autocomplete="off" type="submit" value="Submit"> </td> </tr>

</tbody></table>

</form> <form action="/view_instruction.php?shape=FORTH" autocomplete="off" id="id_20___" method="post" target="_blank">

<table> <tbody border="1"> <td align="center" colspan="3"> <input autocomplete="off" type="submit" value="Receive"> </td> </tbody></table> </form> <form action="/GRAPH.php?shape=GRAPH" autocomplete="off" id="id_21___" method="post" target="_blank"> <table border="3" bordercolor="#6A5ACD"> <tbody> <tr> <td align=center colspan=4 width="1200"> Scale </td> </tr> <tr>

page 14 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 15: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

<td align=center colspan=4 width="1200"> <select id="scale" name="scale" size="1" name="scale"> <option>8</option> <option>16</option> <option>32</option> <option>64</option> <option>128</option> <option>256</option> <option>1024</option> <option>2048</option> <option>4096</option> <option>65535</option> </select> </td> </tr>

<td align="center" colspan="4"> <input autocomplete="off" type="submit" value="Graph"> </td> </tbody> </table> </form>

PHP to read the database

view_instruction.php

<? $shape = $_GET["shape"];

$sql_cmd = "SELECT shapes, alias, full_namea1,full_namea2,full_namea3,full_nameb1,full_nameb2,full_nameb3,"; $sql_cmd .= "full_namec1,full_namec2,full_namec3,full_named1,full_named2,full_named3,"; $sql_cmd .= "full_namee1,full_namee2,full_namee3,full_namef1,full_namef2,ip_address,date_address FROM fpga_settings"; $sql_cmd .= " WHERE shapes='" . $shape . "' ORDER BY fpga_key";

$server="xxxxxxxx.com";//database location $dbusername="xxxxxxxx"; //database username $dbpassword="xxxxxxx"; //database password $dbdatabase="xxxxxxxxxxx"; //database name

$conn = @mysql_connect ($server, $dbusername, $dbpassword) or die('Counld not connect to Mysql Server:' . mysql_error());

mysql_select_db ($dbdatabase) or die('Could not connect to the database:' . mysql_error());

$result = mysql_query($sql_cmd); if (!$result) { die('Invalid query: ' . mysql_error());}

echo "<html>";echo "<head><title>FPGA data for one shape</title></head>";echo "<body>"; while ($row = mysql_fetch_array( $result , MYSQL_NUM) ) { $shapes = $row[0]; $alias = $row[1]; $full_namea1 = $row[2]; $full_namea2 = $row[3]; $full_namea3 = $row[4]; $full_nameb1 = $row[5]; $full_nameb2 = $row[6];

page 15 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 16: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

$full_nameb3 = $row[7]; $full_namec1 = $row[8]; $full_namec2 = $row[9]; $full_namec3 = $row[10]; $full_named1 = $row[11]; $full_named2 = $row[12]; $full_named3 = $row[13]; $full_namee1 = $row[14]; $full_namee2 = $row[15]; $full_namee3 = $row[16]; $full_namef1 = $row[17]; $full_namef2 = $row[18]; $ip_address = $row[19]; $date_address = $row[20];

echo "<table border=1 width=800px>"; echo "<tr>"; echo "<td width=800>"; echo $ip_address; echo "</td>"; echo "</tr>"; echo "</table>";

echo "<table width=800px>"; echo "<tr>"; echo "<td width=100>"; echo "<b>A1</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namea1; echo "</td>"; echo "<td width=100>"; echo "<b>A2</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namea2; echo "</td>"; echo "<td width=100>"; echo "<b>A3</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namea3; echo "</td>"; echo "</tr>";

echo "<tr>"; echo "<td width=100>"; echo "<b>B1</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_nameb1; echo "</td>"; echo "<td width=100>"; echo "<b>B2</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_nameb2; echo "</td>"; echo "<td width=100>"; echo "<b>B3</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_nameb3; echo "</td>"; echo "</tr>";

echo "<tr>"; echo "<td width=100>"; echo "<b>C1</b>:"; echo "</td>";

page 16 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 17: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

echo "<td width=100>"; echo $full_namec1; echo "</td>"; echo "<td width=100>"; echo "<b>C2</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namec2; echo "</td>"; echo "<td width=100>"; echo "<b>C3</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namec3; echo "</td>"; echo "</tr>";

echo "<tr>"; echo "<td width=100>"; echo "<b>D1</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_named1; echo "</td>"; echo "<td width=100>"; echo "<b>D2</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_named2; echo "</td>"; echo "<td width=100>"; echo "<b>D3</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_named3; echo "</td>"; echo "</tr>";

echo "<tr>"; echo "<td width=100>"; echo "<b>E1</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namee1; echo "</td>"; echo "<td width=100>"; echo "<b>E2</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namee2; echo "</td>"; echo "<td width=100>"; echo "<b>E3</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namee3; echo "</td>"; echo "</tr>";

echo "<tr>"; echo "<td width=100>"; echo "<b>F1</b>:"; echo "</td>"; echo "<td width=100>"; echo $full_namef1; echo "</td>"; echo "<td width=100>"; echo "<b>F2</b>:"; echo "</td>"; echo "<td width=100>";

page 17 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 18: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

echo $full_namef2; echo "</td>"; echo "<td width=100>"; echo "&nbsp;"; echo "</td>"; echo "<td width=100>"; echo "&nbsp;"; echo "</td>"; echo "</tr>"; //echo "<td>TEST". $result ."</td></tr>"; echo "</table>"; }

echo "</body>"; echo "</html>";?>

This is what we get:

PHP to read the graph

GRAPH.php

<?php require_once 'phplot.php'; // here we include the PHPlot code $plot = new PHPlot(800,800);

//$ip_address = $_GET["ip_addr"]; $shape = $_GET["shape"]; $sql_cmd = "SELECT shapes,alias, full_namea1,full_namea2,full_namea3,full_nameb1,full_nameb2,full_nameb3,"; $sql_cmd .= "full_namec1,full_namec2,full_namec3,full_named1,full_named2,full_named3,"; $sql_cmd .= "full_namee1,full_namee2,full_namee3,full_namef1,full_namef2,ip_address,date_address FROM fpga_settings"; //$sql_cmd .= " WHERE ip_address='" . $ip_address . "'"; $sql_cmd .= " WHERE shapes='" . $shape . "' ORDER BY fpga_key";

$server="xxxxxxxx";//database location $dbusername="xxxxxxxxxx"; //database username $dbpassword="xxxxxxxxx"; //database password

page 18 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 2

Page 19: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

$dbdatabase="xxxxxxxxxx"; //database name

$conn = @mysql_connect ($server, $dbusername, $dbpassword) or die('Could not connect to Mysql Server on localhost because :' . mysql_error());

mysql_select_db ($dbdatabase) or die('Could not connect to the database:' . mysql_error());

$result = mysql_query($sql_cmd); if (!$result) { die('Invalid query: ' . mysql_error());}

$example_data = array(); $counter = 0;

while ($row = mysql_fetch_array( $result , MYSQL_NUM) ) { $shapes = $row[0]; $alias = $row[1]; $full_namea1 = $row[2]; $full_namea2 = $row[3]; $full_namea3 = $row[4]; $full_nameb1 = $row[5]; $full_nameb2 = $row[6]; $full_nameb3 = $row[7]; $full_namec1 = $row[8]; $full_namec2 = $row[9]; $full_namec3 = $row[10]; $full_named1 = $row[11]; $full_named2 = $row[12]; $full_named3 = $row[13]; $full_namee1 = $row[14]; $full_namee2 = $row[15]; $full_namee3 = $row[16]; $full_namef1 = $row[17]; $full_namef2 = $row[18]; $ip_address = $row[19]; $date_address = $row[20];

$normalised = $full_nameb2 .$full_nameb3; $normaliseds = $normalised / 5000000;

$example_data[] = array( $counter , $normaliseds); $counter++; }

/*hexdec or hex2bin*//*$example_data = array( array('-9',$full_namea1), array('-8', hexdec($full_namea2)/2 ), array('-7',$full_namea3), array('-6',$full_nameb1), array('-5',$full_nameb2), array('-4',$full_nameb3), array('-3',$full_namec1), array('-2',$full_namec2), array('-1',$full_namec3), array('0',$full_named1), array('1',$full_named2), array('2',$full_named3), array('3',$full_namee1), array('4',$full_namee2), array('5',$full_namee3), array('6',$full_namef1), array('7',$full_namef2), array('8',""), array('9',""), array('10',""));*/

/**/$plot->SetDataValues($example_data);

page 19 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 20: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

//Turn off X axis ticks and labels because they get in the way://$plot->SetXTickLabelPos('plotdown');//$plot->SetYTickLabelPos('none');$plot->SetXTickPos('none'); // positions the X tick marks : none = no tick marks

$plot->SetDrawDashedGrid(0);$plot->SetDrawXAxis(0); // odd behaviour when set to 1 on 2015.02.19 1638 - drew horiz line vertically at rightmost element value$plot->SetDrawYAxis(0); // does not hide the Y axis line - odd$plot->SetDrawXGrid(1); // vertical lines$plot->SetDrawYGrid(1); // horiz lines//$plot->SetNumXTicks(count($example_data));$plot->SetNumXTicks(20);$plot->SetNumYTicks(20);// below, Bottom makes a change , Right and Left do not//$plot->SetSkipBottomTick(1);//$plot->SetSkipRightTick(1);//$plot->SetSkipLeftTick(1);

$plot->SetXAxisPosition(0); // this sets X -10 in the bottom-left corner ; if 10 then the X tick labels are at the top of the plot ; 0 = Y 0//$plot->SetYAxisPosition(0); // does not change the displayed plot when -4 or 10 or 0//$plot->SetXDataLabelPos("plotin");

$plot->SetYDataLabelPos("plotin"); // put the values of the point above the point shapes ( 'dots' as set below )

$plot->SetImageBorderType("raised");$plot->SetImageBorderWidth(3);//$plot->SetMarginsPixels(7,7,7,7); // when used hides X and Y axis labels

// precisionX(0) and Y(0) work fine for numbers stored in varchars in the database, but not for hex values//$plot->SetPrecisionX(0);//$plot->SetPrecisionY(0); // causes axis values to be duplicated - odd

$plot->SetLightGridColor("blue");$plot->SetLineWidths(1);

$plot->SetPointShapes('dot');$plot->SetPointSizes(7);

$plot->SetXTickPos("plotdown"); // adds a little length to the vertical lines, adds whitespace above the X axis labels$plot->SetYTickPos("plotleft"); // does little in this plot ; was none changd to plotleft//$plot->SetYTickLabelPos("yaxis"); // this puts the label too close to the label$plot->SetXTickLabelPos("xaxis"); // this moves the X labels to the Y 0

//$plot->SetYTickAnchor(-10); // moves the Y axis labels upward, not helpful.

//$plot->TuneXAutoRange(-10,"R",1);$plot->SetPlotAreaWorld(-20,-20,20,20);

$plot->setTitleColor("blue");$plot->SetXTitle("Plot filled with database values, custom layout/format functions");

//Draw it$plot->DrawGraph();/**/?>

This is what we get:

page 20 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 21: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

PHP to WRITE into the database

page 21 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 3

Page 22: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

The first line defines the binding HTML POST command that will access the Database using the MySQL statements:

$sql_cmd = "INSERT INTO fpga_settings( etc..

instruction_processor.php

<? if (isset($_POST)) { $shapes = 0; $alias = 0; $full_namea1 = 0; $full_namea2 = 0; $full_namea3 = 0; $full_nameb1 = 0; $full_nameb2 = 0; $full_nameb3 = 0; $full_namec1 = 0; $full_namec2 = 0; $full_namec3 = 0; $full_named1 = 0; $full_named2 = 0; $full_named3 = 0; $full_namee1 = 0; $full_namee2 = 0; $full_namee3 = 0; $full_namef1 = 0; $full_namef2 = 0;

while ( list( $key, $val ) = each( $_POST ) ) {

if ($key == "shapes") { $shapes = $val; } if ($key == "alias") { $alias = $val; } if ($key == "full_namea1") { $full_namea1 = $val; } if ($key == "full_namea2") { $full_namea2 = $val; } if ($key == "full_namea3") { $full_namea3 = $val; }

if ($key == "full_nameb1") { $full_nameb1 = $val; } if ($key == "full_nameb2") { $full_nameb2 = $val; } if ($key == "full_nameb3") { $full_nameb3 = $val; }

if ($key == "full_namec1") { $full_namec1 = $val; } if ($key == "full_namec2") { $full_namec2 = $val;

page 22 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 23: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

} if ($key == "full_namec3") { $full_namec3 = $val; }

if ($key == "full_named1") { $full_named1 = $val; } if ($key == "full_named2") { $full_named2 = $val; } if ($key == "full_named3") { $full_named3 = $val; }

if ($key == "full_namee1") { $full_namee1 = $val; } if ($key == "full_namee2") { $full_namee2 = $val; } if ($key == "full_namee3") { $full_namee3 = $val; }

if ($key == "full_namef1") { $full_namef1 = $val; } if ($key == "full_namef2") { $full_namef2 = $val; } }

//$ip_address = $_SERVER['REMOTE_ADDR']; $ip_address = getenv("REMOTE_ADDR");

$sql_cmd = "INSERT INTO fpga_settings (shapes,alias,"; $sql_cmd .= "full_namea1,full_namea2,full_namea3,"; $sql_cmd .= "full_nameb1,full_nameb2,full_nameb3,"; $sql_cmd .= "full_namec1,full_namec2,full_namec3,"; $sql_cmd .= "full_named1,full_named2,full_named3,"; $sql_cmd .= "full_namee1,full_namee2,full_namee3,"; $sql_cmd .= "full_namef1,full_namef2,ip_address)";

$sql_cmd .= " VALUES ('" . $shapes . "',"; $sql_cmd .= "'" . $alias . "',"; $sql_cmd .= "'" . $full_namea1 . "',"; $sql_cmd .= "'" . $full_namea2 . "',"; $sql_cmd .= "'" . $full_namea3 . "',"; $sql_cmd .= "'" . $full_nameb1 . "',"; $sql_cmd .= "'" . $full_nameb2 . "',"; $sql_cmd .= "'" . $full_nameb3 . "',"; $sql_cmd .= "'" . $full_namec1 . "',"; $sql_cmd .= "'" . $full_namec2 . "',"; $sql_cmd .= "'" . $full_namec3 . "',"; $sql_cmd .= "'" . $full_named1 . "',"; $sql_cmd .= "'" . $full_named2 . "',"; $sql_cmd .= "'" . $full_named3 . "',"; $sql_cmd .= "'" . $full_namee1 . "',"; $sql_cmd .= "'" . $full_namee2 . "',"; $sql_cmd .= "'" . $full_namee3 . "',"; $sql_cmd .= "'" . $full_namef1 . "',"; $sql_cmd .= "'" . $full_namef2 . "',"; $sql_cmd .= "'" . $ip_address . "');";

$server="xxxxxxx";//database location $dbusername="xxxxxxxx"; //database username $dbpassword="xxxxxxxx"; //database password $dbdatabase="xxxxxxxx"; //database name

$conn = @mysql_connect ($server, $dbusername, $dbpassword) or die('Counld not connect to Mysql Server:' . mysql_error());

page 23 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 24: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

mysql_select_db ($dbdatabase) or die('Could not connect to the database:' . mysql_error());

$result = mysql_query($sql_cmd); if (!$result) { die('Invalid query: ' . mysql_error());} }

echo "<html>";echo "<body>";

echo "<table border=1>"; echo "<tr><td align=center colspan=2>Your shape entry is: " . $shapes . "</td><td>" . $alias . "</td></tr>";

echo "<tr><td colspan=3>direct</td></tr>";

echo "<tr>"; echo "<td>dux muxtcode is " . $full_namea1 . "</td>"; echo "<td>alucode is " . $full_namea2 . "</td>"; echo "<td>src muxcode is " . $full_namea3 . "</td> </tr>";

echo "<tr><td colspan=3>intermediate</td></tr>"; echo "<td>dux muxtcode is " . $full_nameb1 . "</td>"; echo "<td>MM is " . $full_nameb2 . "</td>"; echo "<td>MM is " . $full_nameb3 . "</td></tr>";

echo "<tr><td colspan=3>relative</td></tr>"; echo "<td>@NN is " . $full_namec1 . "</td>"; echo "<td>alucodes is " . $full_namec2 . "</td>"; echo "<td>src @NN is " . $full_namec3 . "</td></tr>";

echo "<tr><td colspan=3>jump</td></tr>"; echo "<td>@NN is " . $full_named1 . "</td>"; echo "<td>MM is " . $full_named2 . "</td>"; echo "<td>MM is " . $full_named3 . "</td></tr>";

echo "<tr><td colspan=3>branch jump</td></tr>"; echo "<td>Qcode is " . $full_namee1 . "</td>"; echo "<td>ALU is " . $full_namee2 . "</td>"; echo "<td>QQ is " . $full_namee3 . "</td></tr>";

echo "<tr><td colspan=3>loop jump</td></tr>"; echo "<td>&nbsp;</td>"; echo "<td>final value is " . $full_namef1 . "</td>"; echo "<td>current value is " . $full_namef2 . "</td></tr>";

// echo "<td>TEST" . $sql_cmd . "</td></tr>"; // $ipaddress = $_SERVER['REMOTE_ADDR']; echo "<tr><td>IP " . $ip_address . "</td></tr>";

echo "</table>";

echo "</body>";echo "</html>";

?>

The second half of the PHP is defining the HTML that results when the Submit button was pressed and the Database interaction completed, that page pops up showing the values send to the DB:

page 24 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 25: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

The MySQL Database is defined or modified using a Form that they provide or one can also write it in SQL for the Database Table (see next section)

page 25 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 4

Page 26: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

MySQL

page 26 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 5

Page 27: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

FPGA side

The communication will be established with a protocol that means that one is sending Forms that are similar to “Administrative Forms”: there are fields and they must be filled

To have the FPGA do it we need to see the standard communication (see further on a screenshot of the wireshark) and there only need to add the information that is needed:

DNS

The IP of the server are going to be pointing to the domain one wants to reach the source IP (cmd window >ipconfig gives the Ipv4 Address) 192.168.1.xthe destination IP (cmd window >nslookup www.xlyns.com) 98.124.252.143

When the packet is created and send to 192.168.1.1 Here what is captured:

https://www.youtube.com/watch?v=saF2W_LMZSw&t=159

shows that the destination can be chosen to be 192.168.1.1 for wire internet

page 27 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 6

Page 28: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

ARP

The destination IP is given the MAC of the Router that holds the gate to the internet(cmd window >arp -a ) 192.168.1.1 xx xx xx xx xx xx

The source IP is given the MAC of the PC(cmd window >getmac) xx xx xx xx xx xx

TCP

Now we unplug the PC and use the values and replace the port number with 80 (general purpose)That allows us to plug the FPGA and directly use the TCP packets and for the lower layers just reuse the same ones only changing the source and destination MAC IP values that we collected (see above)

For this reason we will only focus on the TCP protocoll and in the next section we see that it only involves:

- calculation of the checksum and in some case incrementing the sequence or acknowledgment- sequencing through a synchronisation process to connect called the 3 way handshake (see below)

First the header and how the RFC 793 shows it: 0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Source Port | Destination Port | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Sequence Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Acknowledgment Number | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Data | |U|A|P|R|S|F| | | Offset| Reserved |R|C|S|S|Y|I| Window | | | |G|K|H|T|N|N| | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Checksum | Urgent Pointer | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Options | Padding | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ TCP Header Format Note that one tick mark represents one bit position. Figure 3. RFC: 793

page 28 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 29: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

TCP definition

Sequence Number: 32 bits

The sequence number of the first data octet in this segment (except

when SYN is present). If SYN is present the sequence number is the

initial sequence number (ISN) and the first data octet is ISN+1.

Acknowledgment Number: 32 bits

If the ACK control bit is set this field contains the value of the

next sequence number the sender of the segment is expecting to

receive. Once a connection is established this is always sent.

Data Offset: 4 bits

The number of 32 bit words in the TCP Header. This indicates where

the data begins. The TCP header (even one including options) is an

integral number of 32 bits long.

Reserved: 6 bits

Reserved for future use. Must be zero.

Control Bits: 6 bits (from left to right):

URG: Urgent Pointer field significant

ACK: Acknowledgment field significant

PSH: Push Function

RST: Reset the connection

SYN: Synchronize sequence numbers

FIN: No more data from sender

page 29 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 30: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Window: 16 bits

The number of data octets beginning with the one indicated in the

acknowledgment field which the sender of this segment is willing to

accept.

Checksum: 16 bits

The checksum field is the 16 bit one's complement of the one's

complement sum of all 16 bit words in the header and text. If a

segment contains an odd number of header and text octets to be

checksummed, the last octet is padded on the right with zeros to

form a 16 bit word for checksum purposes. The pad is not

transmitted as part of the segment. While computing the checksum,

the checksum field itself is replaced with zeros.

The checksum also covers a 96 bit pseudo header conceptually

prefixed to the TCP header. This pseudo header contains the Source

Address, the Destination Address, the Protocol, and TCP length.

This gives the TCP protection against misrouted segments. This

information is carried in the Internet Protocol and is transferred

across the TCP/Network interface in the arguments or results of

calls by the TCP on the IP.

+--------+--------+--------+--------+

| Source Address |

+--------+--------+--------+--------+

| Destination Address |

+--------+--------+--------+--------+

| zero | PTCL | TCP Length |

+--------+--------+--------+--------+

The TCP Length is the TCP header length plus the data length in

octets (this is not an explicitly transmitted quantity, but is

computed), and it does not count the 12 octets of the pseudo

header.

page 30 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 31: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

In next section we use wireshark to show how it is done :

The values that differ from connection to connection (any place anywhere) are only the ones one hasto give attention: the MAC and IP values and we see that they correspond in this example to what weobtained (described above) using the cmd window.

Packet tranferred

This is the capture of the packet send the 3/9/2015 4pm in real followed by a phone call to the Provider support eNom and they confirmed that it caused no disruptionthe only thing it caused was 3 seconds after the server acknowledged the packet (that was send with no error) and did not get any reply, then send a second time the acknowledgement assuming the prior was lost. Which was not the case we just did not reply. So after the 2nd attemt to acknowledge it then carried on with the other tasks hence we created no disruption

page 31 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 7

Page 32: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

TCP connection

The SYN Packet send the 3/9/2015 4pm and the server replyed to this packet (that was green and flagged correct) with a SYN, ACK and because we did not reply it repeated it 3 seconds later and Wireshark noticed this and the entry was colored to show that there was an error. To avoid errors the connection sequence needs to befollowed and here how the F=RFC describe it:

TCP 3 way handshake

1) A --> B SYN my sequence number is X

2) A <-- B ACK your sequence number is X

3) A <-- B SYN my sequence number is Y

4) A --> B ACK your sequence number is Y

Because steps 2 and 3 can be combined in a single message this is called the three way handshake. TCP

Connection State Diagram

Illustration 8

http://www.isoc.org/inet95/proceedings/PAPER/042/html/paper.html

page 32 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Page 33: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

TCP A TCP B

1. CLOSED LISTEN

2. SYN-SENT --> <SEQ=100><CTL=SYN> --> SYN-RECEIVED

3. ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK> <-- SYN-RECEIVED

4. ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK> --> ESTABLISHED

5. ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED

Basic 3-Way Handshake for Connection Synchronization

Checksum

Here a guide going through the calculations https://vimeo.com/17585944

In effect the values yield the same checksum as the packet. This calculation and the incrementing ofthe sequence and acknowledgment numbers are the only computation needed.

page 33 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public

Illustration 9

Page 34: Server Library access on FPGA - xlynsxlyns.com/SERVER LIBRARY FPGA Final Report.pdf · Server Library access on FPGA ... TCP 3 way handshake ... The Data can be lost in hasardous

Server Library access on FPGA

Design Report

Architecture

The FPGA that the user will program using the PC is going to run on its own then and the cable of thePC internet connection suffice once plugged into the FPGA to have it instantly configured and good togo!

The PC has the connection data that are visible on the Webpage and it uses the commands onewould usually type in the cmd window anfd here it is automated in PHP using the exec() function thatopens the cmd and does the functions in the backrounbd just showing the required data that the userwill have to enter by manual means (such as the local IP if different to the usual default or the PCMAC it removes the risk of creating a MAC that is already in use)

The Packets are in the Memory hard coded and the variable values get imprinted so when it plays itthen simply consists of a Memory access and then further some calculations and the Checksum.

All in all the data can be accessed from the Database

Muxcodes program for the TCP

1/ ChecksumThe Memory will need to be accessed selectively to extract the packetsThe Packets will be edited with the values entered by the userSubsequently the 16 bit Checksum elements will be selectively read out and addedIt will take the carry out that is over the 16 bits size and it will be added backFFFF – the result will be the complement and it is the Checksum 2/ Sequence Acknowledge increment

These tasks will be coded in Muxcodes and allow the FPGA to be connected

that simple~

Conclusion

The Database was accessed by the FPGA using the descibed methods involving just unplugging the Internet cable from the PC and into the NEXY4 board

I hope this can help everyone that wants to be able to program!

page 34 of 34

All parties agrees that the work done within the Coursework is published and given freely to the public