This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
blog:fall2015:dshadeck:journal [2015/09/08 00:36] – [August 31, 2015] dshadeck | blog:fall2015:dshadeck:journal [2015/10/05 16:53] (current) – [September 28, 2015] dshadeck | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | =====HPC0===== | + | =====HPC 1===== |
====August 31, 2015==== | ====August 31, 2015==== | ||
Line 10: | Line 10: | ||
We have slowly been working out the kinks in the new POD set up. We were able to give each pod a host name based up its MAC address! This required Brian and I to copy all of the MACs down and submit them to Matt to add to the router. We also fixed an issue, thanks to Andrew, with Vim not using backspace! More bug searching/ | We have slowly been working out the kinks in the new POD set up. We were able to give each pod a host name based up its MAC address! This required Brian and I to copy all of the MACs down and submit them to Matt to add to the router. We also fixed an issue, thanks to Andrew, with Vim not using backspace! More bug searching/ | ||
+ | ====September 14, 2015==== | ||
+ | |||
+ | I have been brain storming ideas for a cool HPC0 project. Matt came up with a few really cool ones today such as a CLI based library system for checking out books from the lairs collection, installing Linux on multiple machines that are all different architectures (Some of them are powerpc, ARM, and MIPS). This one was appealing to me as i really did enjoy using the powerpc mac mini in the old lair and would like to restore its functionality. We also discussed making a weather display for the new lair. This would allow us to see graphical data in real time to veiw what the weather is doing in our local area. This may be a really cool project as the winter season approaches and inevitable snow days occur. | ||
+ | |||
+ | ====September 21, 2015==== | ||
+ | |||
+ | Today we finally rolled out an AWESOME new version of the pod BSD image. Matt, Brian, and i got every pod set up to copy the new image to the pods 4GB of internal flash storage. We were extremely leery of how the network would handle this mass roll out. We were astounded to see everything going smooth! Each machine was using about 12MB of network bandwidth. This is roughly saturating 100mbps speeds! Seeing how each switch has a 1GB up-link and each pod station has about 6 machines we were achieving some very impressive speeds for the low end hardware we have in place. This new image now allowed us to take advantage of the two extra gigabytes of flash storage we unexpectedly received in each pod station! Each station now has a free space of 1.7GB. This is much better than the 70MB we had with the previous version of the pod image. We are still experiencing some hanging issues up on boot but we are close to solving the issue! | ||
+ | |||
+ | ====September 28, 2015==== | ||
+ | |||
+ | Currently i have been thinking of projects that i can combine with my other existing courses to help save time and effort. The main class i have in mind is datacomm. Matt's guidelines were that the project had to have some sort of inspection and processing of data from a source. My first idea was to use wireshark & snort to filter local area network traffic and identify a specific pattern of packets in conjunction with a specific attack type. I am currently thinking of using ARP spoofing as the pattern i want to detect. This is for two reasons. first and foremost ARP spoofing is an extremely simple yet effective attack that works on a LAN level only. Being able to avoid this easy attack on your local area network can save many headaches. Secondly ARP packets are extremely unique in comparison to others. This would allow for very easy filtering and capture of these packets only. | ||
+ | |||
+ | ====October 5, 2015==== | ||
+ | |||
+ | My arp spoofing project is under way! Currently I have two Windows 10 virtual machines set up and running cain and able. This is the program I will be using to do the ARP spoofing attacks. I have been looking into Linux options for ARP spoofing as well as creating my own programs to do this. For now this is the quickest option. The next step will be to set up a service that is vulnerable to ARP spoofing to demonstrate its uses. For this i have been considering an apache web server using http instead of https. This would allow me to see if the spoofing actually worked to capture the unencrypted traffic sent between the web server and the spoofed host. to capture this traffic i will use wireshark. This will give me a pcap format file to sift through and find arp packets. From there i will creat a script that can take in a MAC address and search for arp packets that match the address. As i write this i am thinking of issues with this and maybe i need to do some more brainstorming and testing. BLAGHHH. | ||
=====Data Structures===== | =====Data Structures===== | ||
Line 38: | Line 53: | ||
- | ===September 07, 2015=== | + | ====September 07, 2015==== |
<code c> | <code c> | ||
#include < | #include < | ||
Line 105: | Line 120: | ||
dsi0 is coming along and should be done tonight! W00t W00t. | dsi0 is coming along and should be done tonight! W00t W00t. | ||
+ | |||
+ | ====September 14, 2015==== | ||
+ | |||
+ | Here is my finished dsi0 source code! | ||
+ | <code c> | ||
+ | // Author: Dan Shadeck | ||
+ | // Date: 09/09/2014 | ||
+ | // Class: CSCS2320 | ||
+ | // Project: dsi0 | ||
+ | #include < | ||
+ | |||
+ | int main(){ | ||
+ | int test [20]; | ||
+ | int choice = 0; | ||
+ | int masterindex = 0; | ||
+ | do{ | ||
+ | printf ("1) Build List\n" | ||
+ | printf ("2) Display List\n" | ||
+ | printf ("3) Instert Into List\n" | ||
+ | printf ("4) Append Into List\n" | ||
+ | printf ("5) Obtain From List\n" | ||
+ | printf ("6) Clear List\n" | ||
+ | printf ("7) Quit\n" | ||
+ | printf (" | ||
+ | |||
+ | scanf (" | ||
+ | |||
+ | |||
+ | if (choice > 7){ // If user selects a number not on the menu report the error | ||
+ | printf (" | ||
+ | } | ||
+ | |||
+ | if (choice == 1){ // Taking user input into our above array (test) | ||
+ | printf (" | ||
+ | int number = 0; | ||
+ | int index = 0; | ||
+ | int stop = -1; | ||
+ | do{ | ||
+ | if (index == 19){ | ||
+ | test[index] = stop; | ||
+ | printf (" | ||
+ | masterindex = 19; | ||
+ | break; | ||
+ | } else { | ||
+ | scanf (" | ||
+ | test[index] = number; | ||
+ | if (number == -1) { | ||
+ | masterindex = index; | ||
+ | } | ||
+ | index++; | ||
+ | } | ||
+ | } while (number != -1); | ||
+ | | ||
+ | | ||
+ | } else if (choice == 2){ // Loop for dispalying array numbers and index | ||
+ | int i; | ||
+ | for (i = 0; i <= 19; i++){ | ||
+ | int at = test[i]; | ||
+ | |||
+ | if (at == -1){ | ||
+ | printf ("# -1 @ array index %d\n", i); | ||
+ | break; | ||
+ | } else { | ||
+ | printf ("# %d @ array index %d\n", at, | ||
+ | } | ||
+ | } | ||
+ | } else if (choice == 3){ // Insert | ||
+ | int nv, ai, in; | ||
+ | printf (" | ||
+ | scanf (" | ||
+ | printf (" | ||
+ | scanf (" | ||
+ | for (in = masterindex; | ||
+ | int nnv = test[in]; | ||
+ | int nai = in + 1; | ||
+ | if (nai == 19) { | ||
+ | test[19] = -1; | ||
+ | } else { | ||
+ | test[nai] = nnv; | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | masterindex++; | ||
+ | if (masterindex > 19 ){ | ||
+ | masterindex = 19; | ||
+ | } | ||
+ | test[ai] = nv; | ||
+ | } else if (choice == 4){ // Append | ||
+ | int nv, ai, in; | ||
+ | printf (" | ||
+ | scanf (" | ||
+ | printf (" | ||
+ | scanf (" | ||
+ | ai++; | ||
+ | for (in = masterindex; | ||
+ | int nnv = test[in]; | ||
+ | int nai = in + 1; | ||
+ | if (nai == 19) { | ||
+ | test[19] = -1; | ||
+ | } else { | ||
+ | test[nai] = nnv; | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | masterindex++; | ||
+ | if (masterindex > 19 ){ | ||
+ | masterindex = 19; | ||
+ | } | ||
+ | test[ai] = nv; | ||
+ | |||
+ | } else if (choice == 5){ // Choosing an array index and removing all numbers in the array after selected index | ||
+ | int nv, ai, in; | ||
+ | printf (" | ||
+ | scanf (" | ||
+ | printf ("# %d @ array index %d\n", test[ai], | ||
+ | for (in = ai + 1; in <= masterindex; | ||
+ | int nnv = test[in]; | ||
+ | int nai = in -1; | ||
+ | test[nai] = nnv; | ||
+ | } | ||
+ | masterindex--; | ||
+ | if (masterindex < 0) { | ||
+ | masterindex = 0; | ||
+ | test[0] = -1; | ||
+ | } | ||
+ | } else if (choice == 6){ // Clear the array by testing -1 at array index 0 & updating our master index | ||
+ | test[0] = -1; | ||
+ | masterindex = 0; | ||
+ | printf (" | ||
+ | } | ||
+ | } while (choice != 7); // Quit! | ||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | sln0 is coming along smoothly! | ||
+ | |||
+ | ====September 21, 2015==== | ||
+ | |||
+ | Data structures is the most time consuming class i have ever taken in my college career. This is definitely stretching my time thin on almost every other class i am taking (thank god for HPC0 and Datacom). I was able to get sln0 done on time thanks to my some-what growing time management skills and help from Brian and Mohsin. This class has made me realize that i am an awful programmer with sub-par time management skills... Ahhh what a feeling! I am currently working on sln1 and it is definitely is much easier and less time consuming than the past two projects i have encountered. Thank god!!! | ||
+ | |||
+ | Here is my pseudo code from sln0 now that the deadline is up! | ||
+ | |||
+ | < | ||
+ | # Inserting into the list 1 | ||
+ | |||
+ | tmp2 = start -> after #tmp2 point tp the node after start | ||
+ | tmp2 -> after = mknode(6) | ||
+ | tmp2 -> after -> after = tmp # the second node after tmp2 is now tmp | ||
+ | tmp = start | ||
+ | tmp2 = start | ||
+ | # Inserting into the list 2 | ||
+ | tmp = start | ||
+ | |||
+ | if (tmp -> info == 2){ # if the first node contains a two | ||
+ | start = mknode(0) | ||
+ | start -> after = tmp # now link that to tmp AKA our node containing a two | ||
+ | } else { | ||
+ | tmp2 | ||
+ | while (tmp != NULL){ | ||
+ | if (tmp -> after -> info == 2){ # if the node after tmp contains a two | ||
+ | tmp2 = tmp -> after #set that node to tmp2 | ||
+ | tmp -> after = mknode(0) #making new node that contains 0 | ||
+ | tmp -> after -> after= tmp2 #linking them | ||
+ | } | ||
+ | tmp = tmp -> after #drives the loop | ||
+ | } | ||
+ | } | ||
+ | |||
+ | # Display the list | ||
+ | |||
+ | tmp = start | ||
+ | while (tmp != NULL){ | ||
+ | print tmp -> info | ||
+ | tmp = tmp -> after } # | ||
+ | |||
+ | # Appending to the list 1 | ||
+ | tmp = start | ||
+ | tmp2 = start | ||
+ | if (tmp -> info == 0){ #if the node contains a 0 | ||
+ | tmp = start -> after | ||
+ | |||
+ | start -> after = mknode (1) # making a new node containing a 1 | ||
+ | start -> after -> after = tmp # linking them back | ||
+ | } else { | ||
+ | tmp2 | ||
+ | while (tmp != NULL){ | ||
+ | if (tmp -> info == 0){ # if the node tmp points to has a 0 | ||
+ | tmp2 = tmp -> after # tmp2 is now the node after tmp | ||
+ | tmp -> after = mknode(1) # making a new node | ||
+ | tmp -> after -> after = tmp2 # linking them | ||
+ | } | ||
+ | tmp = tmp -> after | ||
+ | } | ||
+ | |||
+ | #Copying the list | ||
+ | start2 | ||
+ | tmp = start | ||
+ | while (tmp != NULL){ | ||
+ | start2 = tmp -> info | ||
+ | tmp = tmp -> after | ||
+ | } | ||
+ | |||
+ | # Appending to the list 2 | ||
+ | tmp = start | ||
+ | tmp2 = start #SEE APPEND 1 | ||
+ | if (tmp -> info == 8){ | ||
+ | tmp = start -> after | ||
+ | start -> after = mknode(12) | ||
+ | start -> after -> after = tmp | ||
+ | } else { | ||
+ | tmp2 | ||
+ | while (tmp != NULL){ | ||
+ | if (tmp -> info == 8){ | ||
+ | tmp2 = tmp -> after | ||
+ | tmp -> after = mknode(12) | ||
+ | tmp -> after -> after = tmp2 | ||
+ | } | ||
+ | tmp = tmp -> after | ||
+ | } | ||
+ | |||
+ | # Grabbing from list #1 | ||
+ | tmp = start | ||
+ | tmp2 = start | ||
+ | if (tmp -> info == 6){ | ||
+ | start = start -> after | ||
+ | } else { | ||
+ | tmp2 | ||
+ | tmp3 | ||
+ | while (tmp != NULL){ | ||
+ | if (tmp -> after -> info == 6){ | ||
+ | tmp3 = tmp -> after | ||
+ | tmp2 = tmp -> after -> after | ||
+ | tmp -> tmp2 | ||
+ | } | ||
+ | tmp = tmp -> after | ||
+ | } | ||
+ | } | ||
+ | # Grabbing from list #2 | ||
+ | tmp = start2 | ||
+ | tmp2 = start2 | ||
+ | if (tmp -> info == 0){ | ||
+ | start2 = start2 -> after | ||
+ | } else { | ||
+ | tmp2 | ||
+ | tmp3 | ||
+ | while (tmp != NULL){ | ||
+ | if (tmp -> after -> info == 0){ | ||
+ | tmp3 = tmp -> after | ||
+ | tmp2 = tmp -> after -> after | ||
+ | tmp -> tmp2 | ||
+ | } | ||
+ | tmp = tmp -> after | ||
+ | } | ||
+ | } | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | ====September 28, 2015==== | ||
+ | < | ||
+ | CFLAGS = -fPIC -Wall | ||
+ | INC = -I ../../inc | ||
+ | AR = ar | ||
+ | CC = gcc | ||
+ | SRC = $(shell /bin/ls -1 *.c 2>/ | ||
+ | OBJ = $(SRC: | ||
+ | LIB = $(shell /bin/pwd | /bin/sed ' | ||
+ | NAME = $(shell echo " | ||
+ | all: intro $(SRC) $(OBJ) lib | ||
+ | |||
+ | intro: | ||
+ | ifneq ($(MAKECMDGOALS), | ||
+ | @printf " | ||
+ | @printf " | ||
+ | endif | ||
+ | |||
+ | debug: CFLAGS += -DDEBUG -g | ||
+ | debug: DEBUG = debug | ||
+ | debug: $(SRC) $(OBJ) lib | ||
+ | |||
+ | .c.o: | ||
+ | ifneq ($(MAKECMDGOALS), | ||
+ | @printf " | ||
+ | @$(CC) $(CFLAGS) $(INC) -c $< 2>> ../ | ||
+ | else | ||
+ | $(CC) $(CFLAGS) $(INC) -c $< | ||
+ | endif | ||
+ | |||
+ | lib: | ||
+ | ifneq ($(MAKECMDGOALS), | ||
+ | @printf " | ||
+ | @$(AR) rcs ../ | ||
+ | @echo | ||
+ | else | ||
+ | $(AR) rcs ../ | ||
+ | $(CC) -shared -o ../ | ||
+ | endif | ||
+ | |||
+ | clean: | ||
+ | @rm -f .*.sw[op] *.save* *~ *.o $(OBJ) core ../ | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====October 5, 2015==== | ||
+ | #include " | ||
+ | <code c> | ||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // | ||
+ | // at the indicated place. insert() needs to manage | ||
+ | // the necessary connections pointers) to maintain list | ||
+ | // integrity, along with ensuring the start and end | ||
+ | // indicators of the list remain relevant and up-to-date. | ||
+ | // | ||
+ | // behavior: on a NULL list- allocate a list and proceed | ||
+ | // on a NULL newNode- return list as is | ||
+ | // | ||
+ | // note: you are expected to make use of the getpos() and | ||
+ | // setpos() functions to aid you in accomplishing this | ||
+ | // task. Don't needlessly reinvent the wheel. | ||
+ | // | ||
+ | // as with the other functions, you may use no more | ||
+ | // than one return() statement per function. | ||
+ | // | ||
+ | List *insert(List *myList, Node *place, Node *newNode) | ||
+ | { | ||
+ | if(myList == NULL) { //check if list is NULL | ||
+ | myList = mklist(); //make new list | ||
+ | } | ||
+ | if(newNode != NULL) { //checks if newNode is not NULL | ||
+ | if(myList -> first == NULL || myList -> last == NULL) { //checks beginning and end | ||
+ | myList -> first = newNode; | ||
+ | myList -> last = newNode; | ||
+ | } else { | ||
+ | int pos = getpos(myList, | ||
+ | if(pos == 0) { | ||
+ | myList -> first = newNode; | ||
+ | } else { | ||
+ | Node *before = setpos(myList, | ||
+ | before -> after = newNode; | ||
+ | } | ||
+ | newNode -> after = place; | ||
+ | } | ||
+ | } | ||
+ | //returns | ||
+ | return(myList); | ||
+ | } | ||
+ | |||
+ | // Author: Dan Shadeck | ||
+ | // 09/29/2015 | ||
+ | // Data Structures | ||
+ | </ | ||
+ | |||
+ | <code c> | ||
+ | #include < | ||
+ | #include " | ||
+ | |||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // displayf() - display the list in a specified orientation, | ||
+ | // with or without positional values (as indicated | ||
+ | // by the mode parameter). | ||
+ | // | ||
+ | // | ||
+ | // 1 display the list forward, with positional values | ||
+ | // | ||
+ | // note: positional values are indexed starting from 0 | ||
+ | // | ||
+ | // behavior: on a NULL list, output " | ||
+ | // on an EMPTY list, output "-> NULL" | ||
+ | // on error (invalid mode): MOD by 2 and do the result | ||
+ | // (or the logical equivalent) | ||
+ | // | ||
+ | // format: output is to be on a single line, with node values | ||
+ | // space-padded. and separated by " | ||
+ | // against the left margin, of the forms: | ||
+ | // | ||
+ | // for forward: | ||
+ | // | ||
+ | // or, if being displayed with node positions: | ||
+ | // | ||
+ | // for forward: [0] val0 -> [1] val1 -> ... -> [N-1] valN-1 -> [N] valN -> NULL | ||
+ | // | ||
+ | // note: ALL output ends with a newline character | ||
+ | // | ||
+ | void displayf(List *myList, int mode) | ||
+ | { | ||
+ | if(myList == NULL) { | ||
+ | printf(" | ||
+ | } else if (mode==0){ | ||
+ | Node *tmp = myList -> first; | ||
+ | char ran = ' | ||
+ | while (tmp != NULL){ | ||
+ | ran = ' | ||
+ | printf ("%hhd -> ", tmp -> info); | ||
+ | tmp = tmp -> after; // getting the next value | ||
+ | } | ||
+ | if(ran == ' | ||
+ | printf(" | ||
+ | } else { | ||
+ | printf(" | ||
+ | } | ||
+ | } else if (mode==1){ | ||
+ | Node *tmp = myList -> first; | ||
+ | int count = 0; | ||
+ | char ran = ' | ||
+ | while (tmp != NULL){ | ||
+ | ran = ' | ||
+ | printf ("[%d] %hhd -> ", count, tmp -> info); | ||
+ | tmp = tmp -> after; //getting the next value | ||
+ | count++; | ||
+ | } | ||
+ | if(ran == ' | ||
+ | printf(" | ||
+ | } else { | ||
+ | printf(" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // this is displaying the list with or with out position values | ||
+ | |||
+ | // Author: Dan Shadeck | ||
+ | // 09/29/2015 | ||
+ | // Data Structures | ||
+ | |||
+ | </ | ||
+ | |||
+ | <code c> | ||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // getpos() - a list library utility function to identify the actual | ||
+ | // position of a given node in an indicated list. | ||
+ | // | ||
+ | // note: Indexing of the list starts from 0 | ||
+ | // | ||
+ | // behavior: on error (NULL list or given node), return negative | ||
+ | // value (-1), on out-of-bounds condition, return -2 | ||
+ | // | ||
+ | // you are to have only ONE return statement for this | ||
+ | // entire function. Change the existing one as needed. | ||
+ | // | ||
+ | int getpos(List *myList, Node *given) | ||
+ | { | ||
+ | int count = 0; | ||
+ | char broke = ' | ||
+ | if(myList == NULL || given == NULL) { //checks if both list and given are NULL | ||
+ | count = -1; | ||
+ | } else { | ||
+ | Node *tmp = myList -> first; | ||
+ | while (tmp != NULL){ | ||
+ | if (tmp == given){ | ||
+ | broke = ' | ||
+ | break; | ||
+ | } | ||
+ | tmp = tmp -> after; //getting the next value | ||
+ | count++; | ||
+ | } | ||
+ | } | ||
+ | if(broke == ' | ||
+ | count = -2; | ||
+ | } | ||
+ | return(count); | ||
+ | } | ||
+ | |||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // setpos() - a list library utility function to set a node pointer | ||
+ | // to the node at the indicated position of a list. | ||
+ | // | ||
+ | // note: Indexing of the list starts from 0 | ||
+ | // | ||
+ | // behavior: on error (NULL list or negative/ | ||
+ | // return NULL. | ||
+ | // | ||
+ | // you are to have only ONE return statement for this | ||
+ | // entire function. Change the existing one as needed. | ||
+ | // | ||
+ | Node *setpos(List *myList, int pos) | ||
+ | { | ||
+ | //returning node variable | ||
+ | Node *node = NULL; | ||
+ | if(myList != NULL && pos >= 0) { //checking if list is null and pos index | ||
+ | Node *tmp = myList -> first; | ||
+ | int counter = 0; | ||
+ | while(tmp != NULL) {//while loop; checks tmp not NULL | ||
+ | if(counter == pos) { | ||
+ | node = tmp; | ||
+ | break; | ||
+ | } | ||
+ | tmp = tmp -> after; | ||
+ | counter++; | ||
+ | } | ||
+ | } | ||
+ | //returns | ||
+ | return(node); | ||
+ | } | ||
+ | |||
+ | // Author: Dan Shadeck | ||
+ | // 09/29/2015 | ||
+ | // Data Structures | ||
+ | |||
+ | </ | ||
+ | |||
+ | <code c> | ||
+ | #include " | ||
+ | |||
+ | ////////////////////////////////////////////////////////////////////// | ||
+ | // | ||
+ | // mklist() - a list library function to allocate and initialize a | ||
+ | // new list. | ||
+ | // | ||
+ | // behavior: on error, return NULL. | ||
+ | // | ||
+ | // note: you are to have only ONE return statement for this | ||
+ | // entire function. Change the existing one as needed. | ||
+ | // | ||
+ | List *mklist(void) | ||
+ | { | ||
+ | List *newlist = (List *) malloc(sizeof(List)); | ||
+ | |||
+ | return(newlist); | ||
+ | |||
+ | } | ||
+ | |||
+ | // extra comment just to be clear that this is a list library function to allocate and initialize a new list | ||
+ | |||
+ | // Author: Daniel Shadeck | ||
+ | // 9/29/2015 | ||
+ | // Data Structures | ||
+ | |||
+ | </ | ||
+ | =====Data Communications===== | ||
+ | |||
+ | ====August 31, 2015==== | ||
+ | |||
+ | I was sad to miss the first day of data communications as this class is definitely the one that interests me the most. We looked at what the best way to network the new classroom would be and decided that having a switch in the campus network closet would the best idea. We set up out switch with the proper IP address, subnet mask, and gateway to get it ready to deploy! | ||
+ | |||
+ | |||
+ | ====September 07, 2015==== | ||
+ | |||
+ | I am excited to see Matt is bringing back the sleep data project. I feel that this a valuable learning tool to understand basic hardware hacking. We went over the project page and should get a start tomorrow! | ||
+ | |||
+ | ====September 14, 2015==== | ||
+ | |||
+ | Here is some code we have created in class to help sift through the sleep data! | ||
+ | |||
+ | great progress. | ||
+ | |||
+ | <code c> | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | FILE *fptr; | ||
+ | unsigned char byte; | ||
+ | unsigned char chksum = 0; | ||
+ | unsigned char chksumchk = 0; | ||
+ | unsigned short int msglen = 0; | ||
+ | unsigned short int imsglen = 0; | ||
+ | unsigned char time_sec = 0; | ||
+ | unsigned short int sub_sec = 0; | ||
+ | unsigned char seq_num = 0; | ||
+ | unsigned char dtype = 0; | ||
+ | unsigned char *dblock; | ||
+ | char pktflag = -1; | ||
+ | int i = 0; | ||
+ | |||
+ | fptr = fopen (" | ||
+ | |||
+ | while ((byte = fgetc(fptr)) != EOF) | ||
+ | { | ||
+ | if (pktflag | ||
+ | { | ||
+ | if (byte == 0x41) | ||
+ | { | ||
+ | pktflag = 0; | ||
+ | } | ||
+ | } | ||
+ | else if (pktflag == 0) // check for 2nd byte of packet | ||
+ | { | ||
+ | if (byte == 0x34) | ||
+ | { | ||
+ | pktflag = 1; | ||
+ | } | ||
+ | else | ||
+ | pktflag = -1; | ||
+ | } | ||
+ | else if (pktflag == 1) // store checksum byte | ||
+ | { | ||
+ | pktflag = 2; | ||
+ | chksum | ||
+ | } | ||
+ | else if (pktflag == 2) // store msglen bytes | ||
+ | { | ||
+ | pktflag = 3; | ||
+ | msglen | ||
+ | byte = fgetc(fptr); | ||
+ | msglen | ||
+ | } | ||
+ | else if (pktflag == 3) // store inverse msglen bytes | ||
+ | { | ||
+ | imsglen = byte; | ||
+ | byte = fgetc(fptr); | ||
+ | imsglen = imsglen | (unsigned short int)byte << 8; | ||
+ | if ((msglen & imsglen) == 0) | ||
+ | pktflag = 4; | ||
+ | else | ||
+ | pktflag = -1; | ||
+ | } | ||
+ | else if (pktflag == 4) | ||
+ | { | ||
+ | time_sec = byte; | ||
+ | pktflag = 5; | ||
+ | } | ||
+ | else if (pktflag == 5) | ||
+ | { | ||
+ | pktflag = 6; | ||
+ | sub_sec = byte; | ||
+ | byte = fgetc(fptr); | ||
+ | sub_sec = sub_sec | (unsigned short int)byte << 8; | ||
+ | } | ||
+ | else if (pktflag == 6) | ||
+ | { | ||
+ | seq_num = byte; | ||
+ | pktflag = 7; | ||
+ | } | ||
+ | else if (pktflag == 7) | ||
+ | { | ||
+ | dtype = byte; | ||
+ | pktflag = 8; | ||
+ | chksumchk = dtype; | ||
+ | |||
+ | dblock | ||
+ | for(i=0; i< | ||
+ | { | ||
+ | (*(dblock+i)) = fgetc(fptr); | ||
+ | chksumchk | ||
+ | } | ||
+ | |||
+ | if (chksum == chksumchk) // we have a valid packet | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | for(i=0; i< | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | } | ||
+ | } | ||
+ | |||
+ | // fprintf(stdout, | ||
+ | } | ||
+ | |||
+ | fclose(fptr); | ||
+ | |||
+ | return(0); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====September 21, 2015==== | ||
+ | |||
+ | We made some really cool additions to the code today! We now are able to graphicaly track out signal strength packets with a nifty graph thanks to the gd library. While our graph is not impressive it definitely is a great start. Matt showed us a graph from his personal code and i was more than impressed. To think that the library we are using can produce such impressive results was great encouragement to keep on trucking along! Here is what he have as of today. | ||
+ | |||
+ | <code c> | ||
+ | |||
+ | // gcc -o read read.c -lgd | ||
+ | // http:// | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | FILE *fptr; | ||
+ | gdImagePtr img; | ||
+ | gdPoint points[2000]; | ||
+ | unsigned char byte; | ||
+ | unsigned char chksum = 0; | ||
+ | unsigned char chksumchk = 0; | ||
+ | unsigned short int msglen = 0; | ||
+ | unsigned short int imsglen = 0; | ||
+ | unsigned char time_sec = 0; | ||
+ | unsigned short int sub_sec = 0; | ||
+ | unsigned char seq_num = 0; | ||
+ | unsigned char dtype = 0; | ||
+ | unsigned char *dblock; | ||
+ | char pktflag = -1; | ||
+ | int i = 0; | ||
+ | int j = 0; | ||
+ | int num = 0; | ||
+ | int invalid = 0; | ||
+ | int valid = 0; | ||
+ | int total = 0; | ||
+ | time_t mytime = 0; | ||
+ | unsigned int tmp = 0; | ||
+ | unsigned int color[3]; | ||
+ | |||
+ | struct tm *pkt_time; | ||
+ | |||
+ | fptr = fopen (" | ||
+ | |||
+ | img = gdImageCreateTrueColor(2000, | ||
+ | |||
+ | byte = fgetc(fptr); | ||
+ | while (!feof(fptr)) | ||
+ | { | ||
+ | if (pktflag | ||
+ | { | ||
+ | if (byte == 0x41) | ||
+ | { | ||
+ | pktflag = 0; | ||
+ | } | ||
+ | } | ||
+ | else if (pktflag == 0) // check for 2nd byte of packet | ||
+ | { | ||
+ | if (byte == 0x34) | ||
+ | { | ||
+ | pktflag = 1; | ||
+ | } | ||
+ | else | ||
+ | pktflag = -1; | ||
+ | } | ||
+ | else if (pktflag == 1) // store checksum byte | ||
+ | { | ||
+ | pktflag = 2; | ||
+ | chksum | ||
+ | } | ||
+ | else if (pktflag == 2) // store msglen bytes | ||
+ | { | ||
+ | | ||
+ | msglen | ||
+ | byte = fgetc(fptr); | ||
+ | msglen | ||
+ | } | ||
+ | else if (pktflag == 3) // store inverse msglen bytes | ||
+ | { | ||
+ | imsglen = byte; | ||
+ | byte = fgetc(fptr); | ||
+ | imsglen = imsglen | (unsigned short int)byte << 8; | ||
+ | if ((msglen & imsglen) == 0) | ||
+ | pktflag = 4; | ||
+ | else | ||
+ | pktflag = -1; | ||
+ | } | ||
+ | else if (pktflag == 4) | ||
+ | { | ||
+ | time_sec = byte; | ||
+ | pktflag = 5; | ||
+ | } | ||
+ | else if (pktflag == 5) | ||
+ | { | ||
+ | pktflag = 6; | ||
+ | sub_sec = byte; | ||
+ | byte = fgetc(fptr); | ||
+ | sub_sec = sub_sec | (unsigned short int)byte << 8; | ||
+ | } | ||
+ | else if (pktflag == 6) | ||
+ | { | ||
+ | seq_num = byte; | ||
+ | pktflag = 7; | ||
+ | } | ||
+ | else if (pktflag == 7) | ||
+ | { | ||
+ | dtype = byte; | ||
+ | chksumchk | ||
+ | |||
+ | dblock | ||
+ | for(i=0; i< (msglen-1); i++) | ||
+ | { | ||
+ | (*(dblock+i)) | ||
+ | chksumchk | ||
+ | } | ||
+ | |||
+ | if (chksum == chksumchk) // we have a valid packet | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | switch (dtype) | ||
+ | { | ||
+ | case 0x03: | ||
+ | fprintf(stdout, | ||
+ | tmp = (*(dblock+0)); | ||
+ | tmp = tmp | (unsigned int)(*(dblock+1)) << 8; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+2)) << 16; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+3)) << 24; | ||
+ | fprintf(stdout, | ||
+ | break; | ||
+ | |||
+ | case 0x80: | ||
+ | fprintf(stdout, | ||
+ | break; | ||
+ | |||
+ | case 0x84: | ||
+ | fprintf(stdout, | ||
+ | points[num].x = num; | ||
+ | points[num].y = ((*dblock) - 30) * -1; | ||
+ | num++; | ||
+ | break; | ||
+ | |||
+ | case 0x8a: | ||
+ | fprintf(stdout, | ||
+ | tmp = (*(dblock+0)); | ||
+ | tmp = tmp | (unsigned int)(*(dblock+1)) << 8; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+2)) << 16; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+3)) << 24; | ||
+ | |||
+ | tmp = tmp | (unsigned int)(*(dblock+3)) << 24; | ||
+ | mytime = tmp; | ||
+ | pkt_time = localtime(& | ||
+ | fprintf(stdout, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | break; | ||
+ | |||
+ | default: | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | j = -1; | ||
+ | for(i=(msglen-2); | ||
+ | { | ||
+ | if (j == 15) | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | j = 0; | ||
+ | } | ||
+ | else | ||
+ | j++; | ||
+ | |||
+ | fprintf(stdout, | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | fprintf(stdout, | ||
+ | valid++; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | invalid++; | ||
+ | } | ||
+ | |||
+ | total++; | ||
+ | pktflag | ||
+ | } | ||
+ | |||
+ | byte = fgetc(fptr); | ||
+ | // fprintf(stdout, | ||
+ | } | ||
+ | |||
+ | fprintf(stdout, | ||
+ | fclose(fptr); | ||
+ | |||
+ | #define BLACK 0 | ||
+ | #define WHITE 1 | ||
+ | #define RED 2 | ||
+ | |||
+ | color[BLACK] = gdImageColorAllocate(img, | ||
+ | color[WHITE] = gdImageColorAllocate(img, | ||
+ | color[RED] = gdImageColorAllocate(img, | ||
+ | |||
+ | gdImageFilledRectangle(img, | ||
+ | gdImageRectangle(img, | ||
+ | |||
+ | for(i = 0; i < num; i++) | ||
+ | { | ||
+ | gdImageLine(img, | ||
+ | } | ||
+ | |||
+ | fptr = fopen(" | ||
+ | gdImagePngEx(img, | ||
+ | fclose(fptr); | ||
+ | gdImageDestroy(img); | ||
+ | |||
+ | return(0); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====September 28, 2015==== | ||
+ | Brian and i have been working on using gd to create a better graph for the signal strength info we collect from the packets. here is what we have so far. | ||
+ | |||
+ | <code c> | ||
+ | |||
+ | // gcc -o read read.c -lgd | ||
+ | // http:// | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | #include < | ||
+ | |||
+ | int main() | ||
+ | { | ||
+ | FILE *fptr; | ||
+ | gdImagePtr img; | ||
+ | gdPoint points[2000]; | ||
+ | unsigned char byte; | ||
+ | unsigned char chksum = 0; | ||
+ | unsigned char chksumchk = 0; | ||
+ | unsigned short int msglen = 0; | ||
+ | unsigned short int imsglen = 0; | ||
+ | unsigned char time_sec = 0; | ||
+ | unsigned short int sub_sec = 0; | ||
+ | unsigned char seq_num = 0; | ||
+ | unsigned char dtype = 0; | ||
+ | unsigned char *dblock; | ||
+ | char pktflag = -1; | ||
+ | int i = 0; | ||
+ | int j = 0; | ||
+ | int num = 0; | ||
+ | int invalid = 0; | ||
+ | int valid = 0; | ||
+ | int total = 0; | ||
+ | time_t mytime = 0; | ||
+ | unsigned int tmp = 0; | ||
+ | unsigned int color[3]; | ||
+ | |||
+ | struct tm *pkt_time; | ||
+ | |||
+ | fptr = fopen (" | ||
+ | |||
+ | img = gdImageCreateTrueColor(2000, | ||
+ | |||
+ | byte = fgetc(fptr); | ||
+ | while (!feof(fptr)) | ||
+ | { | ||
+ | if (pktflag | ||
+ | { | ||
+ | if (byte == 0x41) | ||
+ | { | ||
+ | pktflag = 0; | ||
+ | } | ||
+ | } | ||
+ | else if (pktflag == 0) // check for 2nd byte of packet | ||
+ | { | ||
+ | if (byte == 0x34) | ||
+ | { | ||
+ | pktflag = 1; | ||
+ | } | ||
+ | else | ||
+ | pktflag = -1; | ||
+ | } | ||
+ | else if (pktflag == 1) // store checksum byte | ||
+ | { | ||
+ | pktflag = 2; | ||
+ | chksum | ||
+ | } | ||
+ | else if (pktflag == 2) // store msglen bytes | ||
+ | { | ||
+ | | ||
+ | msglen | ||
+ | byte = fgetc(fptr); | ||
+ | msglen | ||
+ | } | ||
+ | else if (pktflag == 3) // store inverse msglen bytes | ||
+ | { | ||
+ | imsglen = byte; | ||
+ | byte = fgetc(fptr); | ||
+ | imsglen = imsglen | (unsigned short int)byte << 8; | ||
+ | if ((msglen & imsglen) == 0) | ||
+ | pktflag = 4; | ||
+ | else | ||
+ | pktflag = -1; | ||
+ | } | ||
+ | else if (pktflag == 4) | ||
+ | { | ||
+ | time_sec = byte; | ||
+ | pktflag = 5; | ||
+ | } | ||
+ | else if (pktflag == 5) | ||
+ | { | ||
+ | pktflag = 6; | ||
+ | sub_sec = byte; | ||
+ | byte = fgetc(fptr); | ||
+ | sub_sec = sub_sec | (unsigned short int)byte << 8; | ||
+ | } | ||
+ | else if (pktflag == 6) | ||
+ | { | ||
+ | seq_num = byte; | ||
+ | pktflag = 7; | ||
+ | } | ||
+ | else if (pktflag == 7) | ||
+ | { | ||
+ | dtype = byte; | ||
+ | chksumchk | ||
+ | |||
+ | dblock | ||
+ | for(i=0; i< (msglen-1); i++) | ||
+ | { | ||
+ | (*(dblock+i)) | ||
+ | chksumchk | ||
+ | } | ||
+ | |||
+ | if (chksum == chksumchk) // we have a valid packet | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | switch (dtype) | ||
+ | { | ||
+ | case 0x03: | ||
+ | fprintf(stdout, | ||
+ | tmp = (*(dblock+0)); | ||
+ | tmp = tmp | (unsigned int)(*(dblock+1)) << 8; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+2)) << 16; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+3)) << 24; | ||
+ | fprintf(stdout, | ||
+ | break; | ||
+ | |||
+ | case 0x80: | ||
+ | fprintf(stdout, | ||
+ | break; | ||
+ | |||
+ | case 0x84: | ||
+ | fprintf(stdout, | ||
+ | points[num].x = num; | ||
+ | points[num].y = ((*dblock) - 30) * -1; | ||
+ | num++; | ||
+ | break; | ||
+ | |||
+ | case 0x8a: | ||
+ | fprintf(stdout, | ||
+ | tmp = (*(dblock+0)); | ||
+ | tmp = tmp | (unsigned int)(*(dblock+1)) << 8; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+2)) << 16; | ||
+ | tmp = tmp | (unsigned int)(*(dblock+3)) << 24; | ||
+ | |||
+ | tmp = tmp | (unsigned int)(*(dblock+3)) << 24; | ||
+ | mytime = tmp; | ||
+ | pkt_time = localtime(& | ||
+ | fprintf(stdout, | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | break; | ||
+ | |||
+ | default: | ||
+ | fprintf(stdout, | ||
+ | fprintf(stdout, | ||
+ | j = -1; | ||
+ | for(i=(msglen-2); | ||
+ | { | ||
+ | if (j == 15) | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | j = 0; | ||
+ | } | ||
+ | else | ||
+ | j++; | ||
+ | |||
+ | fprintf(stdout, | ||
+ | } | ||
+ | break; | ||
+ | } | ||
+ | |||
+ | fprintf(stdout, | ||
+ | valid++; | ||
+ | } | ||
+ | else | ||
+ | { | ||
+ | fprintf(stdout, | ||
+ | invalid++; | ||
+ | } | ||
+ | |||
+ | total++; | ||
+ | pktflag | ||
+ | } | ||
+ | |||
+ | byte = fgetc(fptr); | ||
+ | // fprintf(stdout, | ||
+ | } | ||
+ | |||
+ | fprintf(stdout, | ||
+ | fclose(fptr); | ||
+ | |||
+ | # | ||
+ | #define WHITE 1 | ||
+ | #define RED 2 | ||
+ | |||
+ | color[BLACK] = gdImageColorAllocate(img, | ||
+ | color[WHITE] = gdImageColorAllocate(img, | ||
+ | color[RED] = gdImageColorAllocate(img, | ||
+ | |||
+ | gdImageFilledRectangle(img, | ||
+ | gdImageRectangle(img, | ||
+ | |||
+ | for(i = 0; i < num; i++) | ||
+ | { | ||
+ | | ||
+ | } | ||
+ | |||
+ | fptr = fopen(" | ||
+ | gdImagePngEx(img, | ||
+ | fclose(fptr); | ||
+ | gdImageDestroy(img); | ||
+ | |||
+ | return(0); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | ====October 5, 2015==== | ||
+ | |||
+ | Lets hope that today we have a break through on the chart. |