30
Smart Wireless Router Design Review TA: Eric Clark ECE 445 Group 2 September 10th, 2015 By: Chris Reinke, Devasia Manuel

Smart Wireless Router

  • Upload
    others

  • View
    13

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Smart Wireless Router

Smart Wireless Router

Design Review

TA: Eric Clark ECE 445 Group 2

September 10th, 2015

By: Chris Reinke, Devasia Manuel

Page 2: Smart Wireless Router

Table of Contents 1.0 Introduction………………………………………………………….……………. …….... 3 1.1 Statement of Purpose…...………………...……………………………………… …….... 3 1.2 Objectives…..……………………………….……………………………………... …….... 3

1.2.1 Goals…………..………………….…………………………….……….. …….... 3 1.2.2 Benefits…………………….…………………………………………….. …….... 3 1.2.3 Functions and Features……….….…………………..……….……….. …….... 3

1.2.3.1 Smart Home Experience………………………...….………. ……... 3 1.2.3.2 Client side services…………….…………………..………... …….... 3

2.0 Design………………………………………………...………..………………….. …….... 4 2.1 Hardware…………………………………………………………………………… …….... 4

2.1.1 Block Diagram……………………………………..……………………. …….... 4 2.1.2 Block Descriptions………………………………………...……………. …….... 4

2.1.2.1 Antennas………………………………………….…………... …….... 4 2.1.2.2 Raspberry Pi…………………………………………….……. …….... 4 2.1.2.3 Zigbee Circuit…………………………………………………………. 5 2.1.2.4 Power Supply…………………………………………………………. 7 2.1.2.5 Touchscreen………………………………………………….. …….... 7

2.2 Software…………………………………………………………………………………….. 7 2.2.1 Software Components………….……………………………………… ……. 7 2.2.2 Adblock………………………………………………………………………….... 8 2.2.3 Page caching…………………………………………………………………….. 9 2.2.4 User Interface……………………………………………………………………. 10 2.2.5 Zigbee Control Software……………………………………………….……….. 11

2.2.5.1 State Transitions…………………………………………….………... 12 3.0 Requirements and Verification………………………………………………….……... 13 3.1 Hardware.…………………………………………………………………………..……….. 13 3.2 Software…………………………………………………………………………………….. 15

3.2.1 Basic Connectivity…………………………………………………….……….... 15 3.2.2 Adblock………………………………………………………………………….... 16 3.2.3 Page caching…………………………………………………………………..... 17 3.2.4 User Interface………………………………………………………………..…... 17 3.2.5 Zigbee Control Software…………………………………………………..……. 18

4.0 Tolerance Analysis………………………………………………………………............. 19 4.1 Zigbee Circuit……………………………………………………………………..………... 19 4.2 Raspberry Pi………………………………...…………………………………………….... 19 4.3 Adblock…………………………………...…………………………………………………. 19 5.0 Safety Analysis……………………………………………………………………………. 20 6.0 Simulations and Verification………...…………………………………………………. 20 6.1 Simulating Network Requests…………...……………………………………………….. 20 6.2 Simulating Hardware………………………………………………………………………. 22 6.3 Calculations……………………………….………………………………………………... 23

1

Page 3: Smart Wireless Router

6.3.1 Calculating Average Latency Increase with Adblock………………………... 23 6.3.2 Calculations for Antenna Matching………………………...………………….. 23

7.0 Cost and Schedule…………………………………………………………………......... 25 7.1 Cost Analysis……………………………………………………………………………….. 25

7.1.1 Labor……………………………………………………………………….……... 25 7.1.2 Parts………………………………………………………………………………. 25 7.1.3 Grand Total………………………………………………………………………. 26

7.2 Schedule…………………………………………………………………………………….. 26 8.0 Ethical Issues……………………………………………………………………………... 28 9.0 Reference.………………………………………………………………………………….. 30

2

Page 4: Smart Wireless Router

1.0 Introduction 1.1 Statement of Purpose The wireless router is a staple of the home environment. Unfortunately, this piece of hardware is antiquated and hasn’t changed in 5 years. With the advent of IoT and other client­side internet services (such as Adblockers, etc), it makes sense for wireless routers to get smarter and for them to manage larger aspects of our lives. Our project involves building a smart home router that does two things:

enable a "smart home" experience through Zigbee devices provide useful services to connected devices

Zigbee is the gold standard for home automation and is supported by many commercially available sensors. By interfacing Zigbee sensors with our wireless router, we could allow users to turn on a light. Our router will also run useful client side services such as page­caching and Adblocking, which is incredibly useful for mobile devices that don’t support it natively.

1.2 Objectives 1.2.1 Goals

Provide a smart home experience through the Zigbee protocol. Provide useful client side services to connected devices.

1.2.2 Benefits

Improve the mobile experience by providing page­caching and adblocking services to connected devices

Allow the user to interact and control various Zigbee devices directly from the router 1.2.3 Functions and Features

1.2.2.1 Smart Home Experience Perform actions on Zigbee connected devices such as turning on/off lights. Interact and collect data from widely available sensors, such as Nest

Thermometers, August Smart Locks, etc. Touch screen for easy access to user interface.

1.2.2.2 Client side services HTML page­caching for mobile browsers. Ad Blocking for mobile browsers.

2.0 Design

3

Page 5: Smart Wireless Router

2.1 Hardware 2.1.1 Block Diagram As shown in Figure 1, the electrical components of this project consist of three main parts: user interface, control system and power unit.

2.1.2 Block Descriptions 2.1.2.1 Antennas Inputs/Outputs:

Zigbee Circuit PCB Antenna

The antennas broadcast via Zigbee and Wifi signals by connecting to various areas. The wifi is broadcasted through an antenna dongle attached to the Raspberry Pi by usb. The antenna that is attached to the Zigbee chip is integrated into the PCB and will 69 Ω which will need to be matched to 50 Ω. Figure 2 shows the antenna matching circuit. 2.1.2.2 Raspberry Pi Inputs:

MOSO to MOSO GPIO02 to IRQ GPIO1 to CLKM 5V Micro usb to usb adaptor

4

Page 6: Smart Wireless Router

Output: MOSI to MOSI CE0_N to /SEL SCLK to SCLK GPIO3 to SLP_TR GPIO4 to /RST 3.3V pin to VDD

The Raspberry Pi serves as the central brain of the project. It runs software that provides Ad Blocking and page­caching capabilities to connected devices. It also acts as the control unit for the Zigbee circuit. The Raspberry Pi will be powered by an external power adapter and provide power to the touch screen via usb and the Zigbee will be powered via the 3.3v pin and wifi adapter via usb. The Raspberry Pi also gives data to these devices using SPI for zigbee and HDMI for the screen. See Figure 3 for pin location on Raspberry Pi 2. 2.1.2.3 Zigbee Circuit Inputs:

SCLK to SCLK /SEL to CE0_N MOSI to MOSI SLP_TR to GPIO3 /RST to GPIO4 VDD to 3.3V pin

Output: MOSO to MOSO IRQ to GPIO2 CLKM to GPIO1

The Zigbee circuit will allow the Raspberry Pi to have Zigbee capabilities, which enables it to interface with Zigbee devices. The Zigbee circuit will connect to the Raspberry Pi through SPI. The Zigbee circuit will get its power off of the 3.3v pin on the Raspberry Pi. Figure 2 shows the Zigbee circuit.

5

Page 7: Smart Wireless Router

Figure 2: Zigbee Circuit

Figure 3: Pin for Raspberry Pi

6

Page 8: Smart Wireless Router

2.1.2.4 Power Supply The power block houses a usb adaptor that will step down the power from 120V AC to 5V DC at 1.5 Amps maximum. This will be attached via microusb to the Raspberry Pi. 2.1.2.59 Touchscreen Inputs:

HDMI from Raspberry Pi 5V power from USB port

Outputs: Image on touch screen

The touchscreen will be responsible for displaying the user interface. Users will be able to click on the user interface to enable/disable services running on the router. More information on the user interface will be presented in the software section. 2.2 Software 2.2.1 Software Components

Name Description Source Contingency Source

Adblock See 2.2.2 Written entirely from scratch in Java. Will be perform much faster than MITMProxy.

Use MITMProxy (licensed under GPL) which abstracts out many of the complexities with handling raw HTTP requests/responses. Adblocking logic will still be written from scratch.

Page­caching See 2.2.3 Written entirely from scratch in Java. Will be perform much faster than MITMProxy.

Implement a hashtable inside MITMProxy (licensed under GPL) which abstracts out many of the complexities with raw HTTP requests/responses. Page­caching and all page eviction logic will still be written from scratch.

User Interface

See 2.2.4 Written entirely from scratch in Python

Not required

Zigbee See 2.2.5 Written entirely from scratch in Java with the Pi4J library to handle interactions with GPIO pins.

Use a Zigbee shield for Arduino coupled with open source libraries from Adafruit.

7

Page 9: Smart Wireless Router

2.2.2 Adblock Adblocking is implemented in Java code that runs on the Raspberry Pi. The code consists of a multi­threaded HTTP proxy that listens on port 80 and intercepts requests to the web. Upon intercepting the request, the software uses a hash­table stored in memory to try and match the requested domain to a list of known ad­serving domains. If the requested domain is well­known for serving ads and the request points to a file type well­known for ad content (ie: images, Flash, gifs, etc), then the software rewrites the request to point to localhost, and the request is fulfilled by a local HTTP server that returns a blank, 1x1 image file for the ad content. If the content is not an image file, the proxy will return a ‘400 Bad Request’.

Figure 4: Adblock implementation

8

Page 10: Smart Wireless Router

Figure 5: Adblock Flowchart

2.2.3 Page­caching The router will implement page­caching to speed up web page load times. Within the HTTP proxy, software will keep track of web page requests and cache HTTP responses locally in memory. If the proxy ever receives an identical request, it will look for a cache hit rather than fetching the web page from the Internet. The cache will use a LRU (least recently used) algorithm to eject elements if total size exceeds 250MB. It will also use Cache­Control headers and ETag headers present in the HTTP response to periodically eject or revalidate the response if the content becomes too old.

9

Page 11: Smart Wireless Router

Figure 6: Page Cache Flowchart

2.2.4 User Interface The user interface will be presented on a 5 inch touch­screen attached to the Raspberry Pi’s HDMI port. Compared to SPI, HDMI is more ideal as it abstracts out most of the complex logic associated with sending command signals to the screen to enable it to perform useful tasks. The screen will be powered by the Raspberry Pi’s 5V USB port. The user interface will allow the user to enable/disable certain services running on the router. It will have three primary toggle buttons for Adblock, Page­caching and Zigbee. Pressing the toggle button once will enable the associated service. Pressing it again will disable the service.

10

Page 12: Smart Wireless Router

NOTE: Adblock and Zigbee logos are under the Wikimedia Commons license and is available for re­use without modification

Figure 6: HDMI Screen 2.2.5 Zigbee Control Software The Zigbee control software will be responsible for managing control signals between the AT86RF233 and the Raspberry Pi. For Zigbee capabilities, we will use the AT86RF233 chip from Atmel. The AT86RF233 will be interfaced to the Raspberry Pi through an SPI interface, which uses 4 pins (/SEL, MOSO, MISO and SCLK) between the AT86RF233 circuit and Raspberry Pi. A description of each pin is provided below:

Name Purpose

/SEL SPI select signal, active low enables data transmission mode

MOSI SPI data (RPi output and AT86RF233 input) signal

MISO SPI data (RPi input and AT86RF233 output) signal

SCLK SPI clock signal

Control signals are sent to the AT86RF233 by writing bytes directly to registers stored on the AT86RF233. A register access is a two­byte read/write operation initiated by /SEL = L. The first transferred byte on MOSI is the command byte including an identifier bit, a read/write select bit, and a 6­bit register address. The second byte represents the content that should be written to the register. For read operations, the second byte is not necessary, instead the contents of the register is returned on the MISO pin.

11

Page 13: Smart Wireless Router

2.2.5.1 State Transitions The purpose of the control software is to transition the AT86RF233 through the correct states to receive and send messages from and to Zigbee devices. All the states for the AT86RF233 are listed below, fortunately, we will only need to use a small subset of them located in figure 7. The general algorithm we will take to communicate with Zigbee devices is detailed below:

1) Upon start­up, the AT86RF233 will be in state P_ON 2) Enable R_ON to force the AT86RF233 to transition to the listening state (RX_ON) 3) In RX_ON, the AT86RF233 listens for incoming frames, after detecting a valid

synchronization header (SHR), the AT86RF233 automatically enters the BUSY_RX state. The completion of the frame reception is indicated by an interrupt IRQ_3 (TRX_END) and the radio transceiver reenters the state RX_ON.

4) After receiving a TRX_END interrupt, the RPi will force the AT86RF233 to enter transmit mode by sending a TRX_START command through SPI to register bits TRX_CMD (register 0x02, TRX_STATE). .

5) The RPi will write a byte acknowledgement to the frame buffer which will be sent back to the transmitting device. It will also wrap action information in the acknowledgement. For a simple Zigbee enabled LED, we will use bit[7] of the acknowledgement to turn off/on the LED.

6) Force the chip to transition back to RX_ON by sending a R_ON.

Figure 7: Zigbee State Diagram

3.0 Requirements and Verification

12

Page 14: Smart Wireless Router

3.1 Hardware

Requirements Verification Points

Power Supply: 1. Receiving power from

usb adaptor

Power Supply: 1. Ensure power is outputted from micro usb

adaptor of +5V a. Connect multimeter ground to ground

pin b. Connect multimeter positive to

positive pin c. Read voltage should be 5V nominal,

minimum of 4.95V and maximum of 5.05V

6

Zigbee: 1. Matching circuit

Matches PCB Antenna

2. Must be able to send signals and receive signals

3. Must keep timing of the circuit

Zigbee: 1. Ensure Matching Circuit has impedances of

50 Ω a. Connect Network Analyzer to sma

adaptor on PCB b. Read Impedance should be 50 ohms

nominal, minimum of 49 ohms and maximum of 51 ohms.

2. Ensure power is outputted from RFP/RFN of

+.9V a. Connect multimeter ground to ground

pin b. Connect multimeter positive to RFP c. Read voltage should be up to .9V

when chip is sending BUSY_TX d. Read voltage should be 20mV

nominal, minimum 19 mV and maximum 21mV when chip is sending receive states

e. Read voltage should be 0 mV nominal, minimum ­1mV and maximum 1mV when chip is doing nothing

f. Move multimeter positive to RFN g. Iterate c­e

3. Ensure power is outputted from

XTAL1/XTAL2 of +.9V a. Connect multimeter ground to ground

pin

11 7 5

13

Page 15: Smart Wireless Router

4. Must Stabilize

bandgap for analog and digital domain

5. Must have power to the circuit

b. Connect multimeter positive to XTAL1

c. Read voltage should be .9V nominal, minimum .85V and maximum .95V

d. Move multimeter positive to XTAL2 e. Read voltage should be .9V nominal,

minimum .85V and maximum .95V

4. Ensure power is outputted from DVDD/AVDD of +1.8V

a. Connect multimeter ground to ground pin

b. Connect multimeter positive to DVDD c. Read voltage should be 1.8V

nominal, minimum 1.75V and maximum 1.85V

d. move multimeter positive to AVDD e. Read voltage should be 1.8V

nominal, minimum 1.75V and maximum 1.85V in all states except SLEEP, DEEP_SLEEP, RESET, TRX_OFF, and P_ON.

f. Read voltage should be 0 mV nominal, minimum ­1mV and maximum 1mV when SLEEP, DEEP_SLEEP, RESET, TRX_OFF, and P_ON

5. Ensure power is inputted to DEVDD/EVDD

of +3.3V a. Connect multimeter ground to ground

pin b. Connect multimeter positive to

DEVDD c. Read voltage should be 3.3V

nominal, minimum of 1.8V and maximum of 3.6V

4 6

Raspberry Pi: 1. Signals from /SEL,

MOSI, MISO, and SCLK must be sent and received by Zigbee Circuit

Raspberry Pi: 1. Ensure power from SPI pins must be 0 mV

or 3.3V a. Connect oscilloscope ground to

ground pin b. Connect oscilloscope positive to

/SEL c. Read voltage should 3.3V nominal,

minimum 3.25V and maximum 3.35V

9

14

Page 16: Smart Wireless Router

or 0 mV nominal, minimum ­1mV and maximum 1mV

d. Iterate through b­c but instead of oscilloscope positive connected to /SEL put it on MOSI and repeat for both MISO, SCLK

TouchScreen: 1. Must be turned on

and have power and respond to touches

Touchscreen: 1. Ensure power on and functioning

a. Attach to usb and hdmi b. Click power button c. Touch display make does not have a

noticeable lag

4

Antennas: 1. Must receive a

2.45Ghz signal

Antennas: 1. Check antenna is receiving 2.45 Ghz

frequencies a. Connect network analyzer to antenna b. See that there is a huge dip in the

graph at 2.45Ghz nominal, minimum 2.40Ghz and maximum 2.50Ghz

9

Total 61

3.2 Software 3.2.1 Basic Connectivity

Requirements Verification Points

Must broadcast valid Wifi SSID

a. Open the list of detected SSIDs on a mobile device.

b. SSID broadcasted by router (“free_adblock_wifi”) must be present on list.

3

Must allow incoming connections to Wifi SSID

a. Open the list of list of detected SSIDs on a mobile device.

b. Press connect on “free_adblock_wifi” and enter correct password.

c. Router must allow device to connect to network.

3

Must allow connected devices to access the

a. Open the list of list of detected SSIDs on a mobile device.

3

15

Page 17: Smart Wireless Router

Internet b. Press connect on “free_adblock_wifi” and enter correct password.

c. Afterwards, open https://www.google.com in a browser.

d. Browser should begin to load the webpage.

Must handle SSL websites without errors on client’s web browser.

a. Open the list of list of detected SSIDs on a mobile device.

b. Press connect on “free_adblock_wifi” and enter password.

c. Afterwards, open any HTTPS URL in mobile browser.

d. Browser should not throw a security exception and should begin loading the page.

3

3.2.2 Adblock

Requirements Verification Points

Must block request and return empty response when user is within app and tries to send a request to an ad domain.

a. Connect to router b. First, ensure that adblocking is disabled

on the router by toggling the user interface.

c. Open an app known for serving ads (eg: PingTools), ensure that ad is displayed.

d. Then, enable adblocking on the router by toggling the user interface.

e. Reconnect to the router and re­open the same app.

f. Ensure that ad is not displayed.

3

Must block request and return empty response when user is within a website and tries to send a request to an ad domain.

a. Connect to router b. Ensure that adblocking is disabled on

the router by toggling the user interface. c. Open a website known for serving ads

(eg: fortune.com, cnn.com), ensure that ad is displayed.

d. Enable adblocking on the router by toggling the user interface.

e. Reconnect to the router and re­open the same website.

f. Ensure that ad is not displayed.

3

16

Page 18: Smart Wireless Router

3.2.3 Page Caching

Requirements Verification Points

When multiple devices try to access a cached response, Date header across all responses should match since clients are requesting the same version of the cached response.

a. Obtain two devices. b. Connect both to the router. c. On device #1, send a request to any

image hosted on the Internet. d. Wait 1 minute for Date header to change. e. On device #2, send another request to

the same image. f. Using a network debugger such as

TCPDump, verify that date header of request on second device is same as Date header of request on first device.

g. This ensures that we are receiving an older, cached copy of the response on the second device.

3

3.2.4 User Interface

Requirements Verification Points

Pressing the ‘Enable’ button under Adblock on the user interface must enable Adblocking.

a. First, toggle the Adblock button to “On” using the Raspberry Pi’s touchscreen.

b. After, connect to the network using a mobile device and open an app such as PingTools which is known for serving ads. Advertisements should not load.

3

Pressing the ‘Disable’ button under Adblock on the user interface must disable Adblocking.

a. First, toggle the Adblock button to “Off” using the Raspberry Pi’s touchscreen.

b. After, connect to the network using a mobile device and open an app such as PingTools which is known for serving ads.

c. Advertisements should load.

3

Pressing the ‘Enable’ button under Page­caching on the user interface must disable page­caching.

a. First, toggle the Page­caching button to the “On” position. After, connect a mobile device to the router and open www.craiglist.com in a browser.

b. On the router, switch back to the terminal using the user interface and verify that size of page­cache is increasing as more requests are sent out by mobile device. This information will be available in the

3

17

Page 19: Smart Wireless Router

terminal session running the proxy.

Pressing the ‘Disable’ button under Page­caching on the user interface must disable page­caching.

a. First, toggle the Page­caching button to the “Off” position. After, connect a mobile device to the router and open www.craiglist.com in a browser.

b. On the router, switch back to the terminal using the user interface and verify that size of page­cache is increasing as more requests are sent out by mobile device. This information will be available in the Terminal session running the proxy.

3

3.2.5 Zigbee Control Software

Requirements Verification Points

Must broadcast frames to Zigbee device

a. Place Zigbee test device (ideally an LED connected to a Zigbee enabled Arduino) within 2 meters of router.

b. Go to user interface on router and toggle the status of the Zigbee device.

c. If final toggle state was ‘On’, LED on Zigbee Arduino should have lit up. If final state was ‘Off’, LED on Zigbee enabled Arduino should have gone off. NOTE: this test adequately tests both broadcasting and receiving of frames since both are needed to perform actions on a Zigbee device.

3

Must receive frames from Zigbee device

a. Place Zigbee test device (ideally an LED connected to a Zigbee enabled Arduino) within 2 meters of router.

b. Go to user interface on router and toggle the status of the Zigbee device. If final toggle state was ‘On’, LED on Zigbee Arduino should have lit up. If final state was ‘Off’, LED on Zigbee enabled Arduino should have gone off. NOTE: this test adequately tests both broadcasting and receiving of frames since both are needed to perform actions on a Zigbee device.

3

Total Software Points: 39

18

Page 20: Smart Wireless Router

4.0 Tolerance Analysis 4.1 Zigbee Circuit The Zigbee circuit is important because it will determine if we can connect to a Zigbee device or not with our router. An acceptable tolerance of 50 Ω ± 1 Ω is required at the input of the pcb antenna. Calculation and data sheets suggest this much tolerance to get .9db loss and still broadcast correctly. Also in the Zigbee circuit the crystal oscillator needs to be 16MHz and is required to have a max variance of 10 ppm were XTAL 1 and 2 are at .9V measured with a voltmeter. To test we will use an oscilloscope and check if both RFP/RFN at .9V when TX is busy and 20mV for receiving. RX should be at 11.8mA when on and TX is busy at 11.8mA. Both RFP/RFN are connect to the U.FL connector on the Zigbee pcb and see if it meets .9db lose from the actual calculation. As the device moves farther away it should maintain a lose of .9db. At 5m there will be a loss of signal. 4.2 Raspberry Pi The Raspberry Pi acts as the control system for the router. It runs software that is responsible for page­caching, ad­block and sends/receives control signals to the Zigbee circuit. The Raspberry must have an input voltage of 5V ± 0.5V. To test this, we will use a voltmeter in parallel with the power jack supplying the Raspberry Pi. When connected to the wall socket, the power jack should supply a voltage of 5V ± 0.5V. 4.3 Adblock Adblock services running on the router will slightly increase latencies as outgoing requests suffer a latency increase as they are checked against a list of known adblocking domains. We conducted a brief user study where we artificially increased the latency of web requests from a mobile phone and allowed users to perform basic browsing tasks on the phone. We then asked users for the optimal tradeoff between latency increase vs no ads while browsing. 90% of users said that a latency increase of 100ms was reasonable. We verified this threshold in our ‘Simulation’ section. 5.0 Safety Analysis Our project poses two dangers: working with 5Volts at 1.5 amps DC so the likelyhood of getting killed while touching it is super low it will feel like a mild pain. another hazard is burning ourselves while soldering our circuit board together. When dealing with the 2.4Ghz band we have to output 1mW or less to abide by FCC law and also when it is that low of a power there is no dangerous effects that can happen. Another danger is affecting the other 2.4Ghz band device and we will use no antenna until the device is setup correctly. Meaning antenna matching and send/receive signal.

19

Page 21: Smart Wireless Router

6.0 Simulations and Calculations 6.1 Simulating Network Requests Bandwidth and latency are important considerations when intercepting and inspecting HTTP requests. In this section, we will emulate network traffic intercepted by the proxy and calculate an estimate of the minimum latency for a typical site on the Internet when ad blocking is enabled. The site we have chosen is http://csb.stanford.edu/class/public/pages/sykes_webdesign/05_simple.html. It is a very simple HTML site which serves back an image file and some HTML code. The basic setup of the simulation consisted of running dnsmasq on a laptop to redirect all requests to our router. On the router, we ran MITMProxy listening on port 80 to intercept HTTP requests from the client. We wrote a Python plugin for MITMProxy that checked if the request matched a domain from the ‘yoyo’ list (a short open source list of ad domains available at pgl.yoy.com), then we use the ‘Host’ header in the HTTP GET request to route the request to the correct domain on the Internet and returned the response. It is important to note that this approach is significantly slower than the proxy server we will write by hand, but it’s good to have an upper bound on the latency increase caused by Adblocking. Finally, latency results were collected with Chrome’s network debugger. When adblocking is disabled through a boolean in the MITMProxy plugin, we can use Chrome’s network debugger to see that the image content of the page takes 277ms to load. Shown in figure 8. On the other hand, when adblocking is enabled through a boolean in the MITMProxy plugin, the HTML content takes 356 ms to load. Shown in figure 9. From the simulation, it is easy to see that ad­blocking instills a latency increase for each request, as it takes time for the algorithm to validate each request. This latency increase is caused by a couple of factors:

­ MITMProxy does not stream responses and requests. It blocks on retrieving the response until the entire request is received and processed.

­ The Adblock list is stored in a file and reloaded each time, for each request. This is due to a limitation of the MITMProxy plugin structure.

However, the latency increase is only ~80ms which is too fast for the user to notice. However, for multiple requests that proceed one after the other, there might be a noticeable lag. However, after router­leve page caching is implemented, the latency will go down since the router won’t need to re­fetch previous requests. Also, final page load times for webpages with

20

Page 22: Smart Wireless Router

lots of ads will go down as the mobile device will not need to load large image files or flash files that represent ad content. Once again, this simulation gives us an upper bound on the latency increase. The latency increase will surely be lower when we implement a streaming proxy with page caching from scratch.

Figure 8: simulating with Adblocked disabled

Figure 9: simulating with adblock enabled 6.2 Simulating Hardware Below is a Smith chart that helps us do antenna matching or any type of impedance matching for a circuit. This chart figure 10 is generated by CST which is freeware to help make sure the antenna matching circuit is correctly done. Using this chat, we can figure out what capacitors or inductors are needed to match our Zigbee circuit to our Zigbee antenna.

21

Page 23: Smart Wireless Router

Figure 10: antenna simulation

6.3 Calculation 6.3.1 Calculating Average Latency Increase with Ad­blocking Since latency for each request depends heavily on various transients (such as web server load, congestion in the network, etc), we have run the previous emulation 10 times and taken the average latency increase when requesting ‘prettypicture.png’ when ad­blocking is enabled and disabled.

Trial Latency when ad­blocking is disabled (ms)

Latency when ad­blocking is enabled (ms)

Latency Difference (ms)

1 278 366 88

2 253 323 70

3 241 353 112

4 288 386 98

5 275 367 80

6 262 337 75

22

Page 24: Smart Wireless Router

7 269 362 93

8 255 329 74

9 251 340 89

10 264 344 80

According to the table, average latency increase when using ad­blocking is 85.9ms. This seems like a reasonable increase. This number is likely to go down once page caching is implemented. Also, total page load times will definitely go down since the site will be stopped from loading large image/flash files which represent ad content . 6.3.2 Calculation for Antenna Matching This is a calculation that helps match the impedances between the Zigbee circuit and antenna. 50 Ω is the current impedance of the circuit. We want to ensure that the antenna has the exact same impedance. Antenna Impedance is found based off the equation below. Which is 69Ω. Zo is the impedances of the antenna H is the thickness of the dielectric. T is the trace thickness, W is the trace width and r is the relative permittivity.ε

ln( )Zo = 87√ε +1.41r

5.98H0.8W+T

Co = ln( )5.98H0.8W+T

0.67(ε +1.41)r

T pd = Co * Zo The below calculation tells us what resistance we should use for our antenna matching circuit. We know f=2.45e9Hz and Zl=(50+1.299)Ω. Where Zi is the resistance from the PCB antenna and Zc is the impedance from the capacitor. We can find the value of Zl from the datasheet. Zi = Zl + Z R X) c = ( + i − i

Z 2πfCl

Solve for C: 0 50 (− ) pF5 = ( + i 1

50(2π)(2.45e9)(C) ⇒ C = 1

23

Page 25: Smart Wireless Router

7.0 Cost and Schedule 7.1 Cost Analysis 7.1.1 Labor

Name Hourly rate Total Hour Invested Total = Hourly Rate x 2.5 x Total Hours

Invested

Dev $35.00 225 $7,875.00

Chris $35.00 225 $7,875.00

Total 450 $15,750.00

7.1.2 Parts

Item Quantity Cost Vender Item #

Raspberry Pi 1 $40.00 Raspberry Pi Raspberry Pi 2 Model B

Zigbee SoC 1 $6.08 DigiKey AT86RF233

PCB 1 $75.00 N/A

Resistors 1 $0.10 DigiKey RC0402JR­07680RL

Capacitor 2 $0.20 DigiKey GRM155R71C103KA01D

Capacitor 2 $0.24 DigiKey 0603YD105KAT2A

Capacitor 2 $0.20 DigiKey C0603C220K4GACTU

Capacitor 1 $0.10 DigiKey grp1886c1h2r0da01

Capacitor 1 $0.10 DigiKey CC0402KRX7R7BB104

Balun 1 2.63 DigiKey 748421245

Crystal 1 $1.77 DigiKey 8Z­16.000MEEQ­T

Arduino 1 $25.00 Arduino Arduino UNO R3

XBee 1 $19.00 Mouser XBee 1mW Wire Antenna

24

Page 26: Smart Wireless Router

5inch Raspberry Pi touchscreen

1 $79.99 Adafruit HDMI 4 Pi: 5" Display w/Touch and Mini Driver ­ 800x480 HDMI

7.1.3 Grand Total

Section Total

Labor $15,750.00

Parts $207.02

Grand Total $15,947.02

7.2 Schedule

Week Task Responsibility

9/15 Work on preparing project proposal Dev

Work on preparing project proposal Chris

9/22 Purchase and interface Wifi antenna to Raspberry Pi. Write any custom code if

necessary.

Dev

Design matching circuit Chris

9/29 Develop a network bridge that intercepts packets from the Wifi antenna and forwards

packets through the Ethernet port

Dev

Creating Matching circuit Chris

10/6 Develop a custom DNS server that is able to redirect host names that point to ads.

Dev

Designing interface between Zigbee and Raspberry Pi

Chris

10/13 Develop code that performs ad­blocking on domains

Dev

Combining circuits onto PCB using eagle Chris

25

Page 27: Smart Wireless Router

10/20 Develop a HTML page­cache that runs on the Raspberry Pi

Dev

using pspice to test out circuit. Chris

10/27 Test all aspects of adblocking and page­caching

Dev

Soldering components onto PCB Chris

11/3 Design and develop a rain sensor composed of an Arduino + water sensing chip. Will be used

in demos.

Dev

Testing circuit for correct output Chris

11/10 Finish developing Zigbee circuit with Chris. Test all aspects of the Zigbee circuit.

Dev

Combining circuit with rest of devices. Chris

11/17 Write code for user interface, test all aspects of router

Dev

Run full hardware test Chris

11/24 Fix any remaining issues Dev

Repair loose ends such as antenna Chris

12/1 Prepare final presentation Dev

Connect to other Zigbee device Chris

12/8 Prepare for final demos Dev

Done Chris

26

Page 28: Smart Wireless Router

8.0 Ethical Issues

1. to accept responsibility in making decisions consistent with the safety, health, and welfare of the public, and to disclose promptly factors that might endanger the public or the environment;

Maintaining privacy on the Internet is an issue for the public. Many people have had their

identities stolen through phishing attacks and other nefarious activities. Our router will stop these attacks at the source and help alleviate privacy concerns on the Internet.

On the other hand, antenna radiation generated by our device is an ethical issue since it could radiate a person if not modularized correctly. However, it is minimum risk because its range of frequencies is nowhere near dangerous radiation levels if done correctly.

2. to avoid real or perceived conflicts of interest whenever possible, and to disclose them to affected parties when they do exist;

Neither of us have a conflict of interest that prevents us from working on this project.

3. to be honest and realistic in stating claims or estimates based on available data;

We will be honest and realistic when expressing the limitations of our product and strive

to not use false claims to elevate the success of our product. For example, our solution is based on a crowdsourced database of known ad­domains. However, since new ad­domains are created all the time, it would be impossible for us to block 100% of ads and privacy scripts. However, we’re confident that the database contains 99% of known ad domains.

4. to reject bribery in all its forms;

Yes, we reject bribery.

5. to improve the understanding of technology; its appropriate application, and potential consequences;

The consequences of this technology are manifold. Adblocking services that run directly

on routers will ensure that all mobile devices experience ad­free browsing. The Zigbee module allows consumers to easily automate their homes. Both of these are major benefits for consumers.

6. to maintain and improve our technical competence and to undertake technological tasks for others only if qualified by training or experience, or after full disclosure of pertinent limitations;

27

Page 29: Smart Wireless Router

Yes, we have fully disclosed all the limitations of our solution in this document.

7. to seek, accept, and offer honest criticism of technical work, to acknowledge and correct errors, and to credit properly the contributions of others;

Our weekly meetings with TAs ensure that we get appropriate technical feedback and

guidance. We strive to rectify any mishaps in design or implementation as soon as possible.

8. to treat fairly all persons and to not engage in acts of discrimination based on race, religion, gender, disability, age, national origin, sexual orientation, gender identity, or gender expression;

We don’t discriminate on providing Zigbee and Adblocking services. All of the services

are available for everyone regardless of race, religion, gender, disability, age, national origin, sexual orientation, gender identity, or gender expression.

9. to avoid injuring others, their property, reputation, or employment by false or malicious action;

Our product does not damage property or injure others’ reputation.

10. to assist colleagues and co­workers in their professional development and to support

them in following this code of ethics. We fully encourage all of our co­workers in supporting this IEEE code of ethics.

28

Page 30: Smart Wireless Router

9.0 References: "Antenna Design and Simulation." CTS Computer Simulation Technology. N.p., n.d. Web. 10 Sept.

2015. <https://www.cst.com/Applications/Category/Antenna+Design+and+Simulation />. Atmel. "AT86RF233." Atmel. N.p., n.d. Web. 10 Sept. 2015.

<http://www.atmel.com/images/atmel­8351­mcu_wireless­at86rf233_datasheet.pdf />. "Clemson Vehicular Electronics Laboratory: Microstrip Impedance Calculator." Clemson Vehicular

Electronics Laboratory: Microstrip Impedance Calculator. N.p., n.d. Web. 10 Sept. 2015. <http://www.cvel.clemson.edu/emc/calculators/PCB­TL_Calculator/microstrip.htm /l>.

Karpfinger, Colin. "Colin Karpfinger." Colin Karpfinger. N.p., n.d. Web. 10 Sept. 2015.

<http://colinkarpfinger.com/blog/2010/the­dropouts­guide­to­antenna­design />. Micro Sd. "Raspberry Pi." Adafruit. N.p., n.d. Web. 10 Sept. 2015.

<http://www.adafruit.com/pdfs/raspberrypi2modelb.pdf/>. NXP. “Zigbee PRO Stack User Guide.” NXP. N.p., n.d. Web. 11 Sept. 2015.

<http://www.nxp.com/documents/user_manual/JN­UG­3048.pdf/> Myers, Steven. "ZigBee/IEEE 802.15.4" Myers Steven. N.p., n.d. Web. 11 Sept. 2015.

<http://pages.cs.wisc.edu/~suman/courses/838/f06/zigbee­myers­talk.pdf/> Adblock Plus. "Investigating Filter Matching Algorithms." Wladimir Palant. N.p., n.d. Web. 12 Sept. 2015. <https://adblockplus.org/blog/investigating­filter­matching­algorithms/> Adblock Plus. "Adblock Internals." Wladimir Palant. N.p., n.d. Web. 12 Sept. 2015.

<https://adblockplus.org/faq_internal/> Wifi. "Setting up Wifi with Raspberry Pi." Adafruit. N.p., n.d. Web. 12 Sept. 2015.

<https://learn.adafruit.com/adafruits­raspberry­pi­lesson­3­network­setup/setting­up­wifi­with­occidentalis/>

29