CSE30 SP21 Assignment 5 Assignment – 5 (CSE30: Computer Organization and Systems) Instructors: Bryan Chin SP21 Due: Friday, May 7th 11:59PM Please read over the entire assignment before starting to...

C programming + Assembly language. All the instructions is said in the pdf. the starter code is given. All also need to submit the file on Gradescope and run the tests on it in order to make sure it is working fine and I get credit for it.



CSE30 SP21 Assignment 5 Assignment – 5 (CSE30: Computer Organization and Systems) Instructors: Bryan Chin SP21 Due: Friday, May 7th 11:59PM Please read over the entire assignment before starting to get a sense of what you will need to get done in the next week. REMEMBER: Everyone procrastinates but it is important to know that you are procrastinating and still leave yourself enough time to finish. Follow the suggested development flow discussed in lecture (soapbox talk). Background (Optional Reading) In the area of network security and privacy there is a category of devices that focus on network tracking and advertisement blocking called DNS sinkholes. From Wikipedia (https://en.wikipedia.org/wiki/Domain_Name_System): “The Domain Name System (DNS) is a hierarchical and decentralized naming system for computers, services, or other resources connected to the Internet or a private network. The DNS system associates various information with domain names assigned to each of the participating entities. One important function of DNS is that it translates more readily memorized domain names, such as www.ucsd.edu, to the numerical IP addresses needed for locating and identifying computer services and devices with the underlying network protocols. By providing a worldwide, distributed directory service, the Domain Name System has been an essential component of the functionality of the Internet since 1985.” When your computer connects to the network, it is given the IP address of a DNS server where DNS queries are to be sent. An end-user application, like a web browser, will make a DNS request for every DNS name associated with a web page that you visit. The DNS server will respond with the IP address for each DNS name. The open source project, pihole (https://pi-hole.net/), turns a raspberry pi into a DNS server (and DNS sinkhole) for your local/home network. Computers on your local network are then configured to make DNS requests directly to the pihole DNS server. The pihole DNS server will either respond to your DNS name request directly (it keeps copies of commonly requested domain names) or will query higher level DNS servers on your behalf to get the IP address and then forward the response to your computer. By placing the pihole DNS server between your computer and the internet, DNS servers allow the pihole to filter DNS requests to block sites that you do not want to visit (like advertising, tracking sites, malware etc). A DNS sinkhole includes a database of sites keyed by DNS names that are to be blocked. When a DNS sinkhole receives a DNS request for a blocked site from say a web browser on your computer, it responds not with the actual IP address of the requested site but substitutes the IP address of the DNS sinkhole. The application then attempts to connect to the DNS sinkhole instead. The DNS sinkhole takes the place of the real site and in the case of a web page connection it returns a blank page (blocking access to the actual page requested), or for other types of applications drops the request. In the Figure 1 below we show what this looks like at a client web browser when the IP address for a blocked address (adservice.google.com) is returned. The warning page from the DNS sinkhole web server replaces the actual web page. Figure 1 : Warning Page Assignment Overview Jarvis needs to block certain websites from being accessible. The way to do that is to build a DNS blocker. Your assignment is to help build a system that checks if a website is blocked or not given a list of blocked websites and an input file which has the list of websites one would like to access. You will do this by implementing a hash table-based in-memory database using single linked chains for collision resolution. The database will contain DNS names of websites you wish to block. You will load a real DNS block list into the database and then make some queries for different DNS names. If a DNS name is found in the database, it will respond with a blocked message. If the DNS name is not in the database, it will respond with a not blocked message. Figure 2 shows a sample visualization of a hash table once it has been loaded with a database of DNS names of blocked websites. Figure 2 : Visualization of a hash table - a short video reviewing hashing can be found on canvas - “Hashing for HW5” Part 0: Getting started We’ve provided you some starter code with a Makefile here. Download all the files to use. This assignment has both - C programming as well as ARM assembly. We have placed the reference solution binary at: /home/linux/ieng6/cs30sp21/public/bin/dnsblockA5reference. This can only be executed in the pi-cluster. It will NOT run if you try to execute it in ieng6. https://canvas.ucsd.edu/courses/25087/external_tools/82 https://github.com/cse30-sp21/A5_starter In order to run your program you MUST ssh into the pi-cluster on ieng6. Both your ieng6 and pi-cluster accounts share the same files so anything you copy to ieng6 (scp to ieng6) will ALSO be on the pi-cluster when you ssh in. Compile and run your program ONLY on the pi-cluster, it will not work on ieng6.From Your Personal Computer 1. Open a Terminal 2. ssh into your ieng6 account 3. Download the starter code 4. From ieng61, ssh into the pi-cluster using the following command (may not work if executing from your personal computer): $ ssh @pi-cluster.ucsd.edu Example: $ ssh [email protected] 5. You are ready to start! (REMEMBER: when you exit, you need to do so twice if you want to get back to your local machine!) Makefile: The Makefile provided will create a dnsblock executable from the source files provided. Compile it by typing make into the terminal. Run make clean to remove files generated by make. gdb: To run with gdb, the command is gdb [executable] to start gdb with your executable. r [arguments] will run your executable with [arguments] Part 1: dnsblock program [50 points] Step 1. Command line Parsing Your program will be called using the following syntax: dnsblock [-s] [-t tablesize] -b blockfile < input.txt="" the="" -s="" option="" prints="" out="" the="" following="" information="" after="" the="" hash="" table="" has="" been="" loaded.="" it="" works="" by="" walking="" down="" each="" chain="" to="" find="" the="" total="" number="" of="" entries="" and="" the="" length="" of="" the="" longest="" and="" shortest="" collision="" chain,="" it="" also="" keeps="" track="" of="" the="" website="" which="" was="" blocked="" the="" most="" number="" of="" times.="" table="" size:="" 1873="" total="" entries:="" 75064="" longest="" chain:="" 65="" shortest="" chain:="" 18="" maximum="" block="" count:="" 10="" the="" -t="" tablesize="" option="" allows="" an="" override="" of="" the="" default="" size="" of="" the="" hash="" table="" array="" (use="" 1873="" as="" a="" default)="" to="" tablesize.="" making="" this="" a="" small="" positive="" number="" may="" help="" you="" to="" debug="" your="" chaining="" routines.="" the="" simple="" hash="" function="" we="" are="" using="" (see="" below)="" often="" works="" better="" with="" prime="" numbers="" for="" the="" size="" of="" the="" hash="" table.="" 1="" you="" can="" also="" log="" directly="" into="" the="" pi-cluster="" if="" you="" are="" on="" a="" ucsd="" network="" (e.g.="" on="" campus,="" or="" use="" ucsd="" vpn).="" the="" -b="" blockfile="" must="" be="" specified="" as="" it="" is="" the="" filename="" of="" the="" block="" list="" test="" file="" to="" load="" into="" the="" database.="" if="" not="" specified="" it="" is="" an="" error.="" you="" will="" open="" the="" file="" using="" fopen()="" in="" read="" only="" mode="" (“r”),="" read="" the="" file="" with="" getline()="" and="" then="" close="" the="" file="" using="" fclose()after="" eof="" is="" reached.="" the="" blockfile="" will="" never="" be="" empty="" -="" it="" will="" at="" least="" have="" one="" entry="" in="" it.="" step="" 2.="" load="" the="" hashtable="" from="" the="" blockfile="" each="" entry="" in="" the="" hash="" chain="" is="" of="" the="" following="" type:="" typedef="" struct="" node="" {="" char="" *dnsname;="" int="" count;="" struct="" node="" *next;="" }="" node;="" create="" the="" hash="" table="" on="" the="" head="" where="" htable="" is="" a="" pointer="" to="" the="" table.="" node="" **htable;="" using="" calloc(),="" allocate="" space="" for="" the="" hash="" table="" to="" contain="" tablesize="" elements="" of="" (node="" *).="" this="" way="" the="" table="" is="" zero="" filled="" (where="" all="" the="" (node="" *)="" pointers="" are="" null="" to="" start.="" the="" blockfile="" is="" an="" ascii="" text="" file="" of="" blocked="" dns="" names.="" each="" line="" of="" the="" file="" will="" contain="" a="" single="" dns="" name="" terminated="" by="" a="" newline="" (‘\n’).="" lines="" that="" start="" with="" a="" #="" or="" a="" ‘\n’="" are="" skipped="" over="" (ignored="" -="" not="" inserted="" into="" the="" hash="" table).="" you="" can="" assume="" all="" other="" lines="" are="" ok.="" until="" you="" reach="" the="" end="" of="" the="" file,="" read="" the="" text="" file,="" one="" line="" at="" a="" time="" using="" a="" getline()="" loop,="" remove="" the="" trailing="" ‘\n’="" from="" the="" input="" (you="" can="" use="" a="" routine="" like="" strchr()if="" you="" like)="" and="" then="" generate="" a="" hash="" value="" for="" each="" entry="" in="" the="" block="" dns="" file="" (refer="" hash="" function="" part="" described="" later="" in="" the="" write="" up).="" using="" the="" hash="" value,="" you="" will="" check="" if="" the="" entry="" is="" already="" in="" the="" table.="" if="" the="" dns="" name="" you="" are="" trying="" to="" add="" to="" the="" database="" is="" already="" in="" the="" table,="" using="" fprintf()="" you="" will="" print="" a="" message="" line="" (as="" below)="" to="" stderr="" and="" go="" to="" the="" next="" entry="" in="" the="" blockfile.="" loadtable="" duplicate="" entry:="" ads.google.com="" if="" this="" dnsname="" is="" not="" in="" the="" table,="" you="" need="" to="" insert="" it="" into="" the="" hash="" table.="" use="" malloc()="" to="" allocate="" a="" node="" and="" use="" strdup()="" to="" allocate="" the="" space="" (pointed="" at="" by="" a="" dns="" name="" member)="" to="" contain="" a="" dns="" name="" string.="" insert="" the="" new="" entry="" at="" the="" front="" of="" the="" collision="" chain="" at="" the="" bucket="" specified="" by="" the="" hash="" value.="" step="" 3.="" print="" the="" stats="" if="" the="" -s="" option="" is="" given="" you="" will="" walk="" the="" hash="" table="" from="" the="" first="" chain="" pointer="" (offset="" 0)="" to="" the="" last="" (offset="" tablesize="" –="" 1).="" for="" each="" entry="" you="" walk="" the="" chain="" and="" while="" doing="" so="" count="" the="" number="" of="" entries="" on="" the="" chain.="" you="" need="" to="" keep="" track="" of="" the="" shortest="" and="" longest="" chain="" as="" well="" as="" the="" total="" number="" of="" entries="" in="" the="" table.="" the="" shortest="" length="" of="" a="" chain="" is="" greater="" than="" equal="" to="" 1="" (if="" the="" hash="" table="" has="" no="" nodes="" in="" a="" particular="" offset="" -="" it="" is="" not="" a="" chain).="" you="" also="" need="" to="" keep="" track="" of="" the="" number="" of="" times="" a="" website="" was="" blocked="" for="" -="" you="" need="" to="" print="" the="" maximum.="" step="" 4.="" query="" mode="" after="" the="" table="" is="" built,="" you="" will="" read="" standard="" input="" (until="" a="" ctrl-d="" is="" pressed="" on="" a="" line="" by="" itself="" and="" the="" program="" will="" exit)="" using="" getline().="" you="" can="" type="" on="" each="" line="" input,="" a="" dns="" name="" that="" you="" will="" check="" to="" see="" if="" it="" is="" blocked="" (found="" in="" the="" hash="" table)="" or="" is="" not="" blocked="" (not="" found="" in="" the="" hash="" table).="" lines="" that="" start="" with="" a="" #="" or="" a="" ‘\n’="" are="" skipped="" over.="" you="" can="" also="" create="" a="" test="" file="" and="" test="" it="" with:="" dnsblock="" -s="" -b="" blocklist.txt="">< test_file.txt your output will be dns name input followed by a space and either [blocked] or [not blocked]: below we provided the output of executing the program with test_file.txt file that was provided as part of the starter code. ach.magnificentpool.com [not blocked] events3alt.adcolony.com [blocked] ach.mine-vn.com [not blocked] ach.nibirupool.com [not blocked] www.amazonco.uk [blocked] table size: 1873 total entries: 2919 longest chain: 7 shortest chain: 1 maximum block count: 1 how to develop your code there are four files, makefile test_file.txt="" your="" output="" will="" be="" dns="" name="" input="" followed="" by="" a="" space="" and="" either="" [blocked]="" or="" [not="" blocked]:="" below="" we="" provided="" the="" output="" of="" executing="" the="" program="" with="" test_file.txt="" file="" that="" was="" provided="" as="" part="" of="" the="" starter="" code.="" ach.magnificentpool.com="" [not="" blocked]="" events3alt.adcolony.com="" [blocked]="" ach.mine-vn.com="" [not="" blocked]="" ach.nibirupool.com="" [not="" blocked]="" www.amazonco.uk="" [blocked]="" table="" size:="" 1873="" total="" entries:="" 2919="" longest="" chain:="" 7="" shortest="" chain:="" 1="" maximum="" block="" count:="" 1="" how="" to="" develop="" your="" code="" there="" are="" four="" files,="">
May 07, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here