Thursday, October 8, 2015

CCNA Secrets



Programming Raspberry PI with C
Programming  Raspberry Pi with Python



If you want to become CCNA, not just a paper CCNA,
you have found the right place.
Power up your computer, make yourself comfortable
and enjoy the ride!


CCNA Lessons

Don't Panic!
Your 59 Lessons
are still here.

CCNA Learning By Doing

Here you will learn
all about

Practical Networking.



Disclaimer!
This is a personal weblog. The opinions expressed here represent my own and not those of my employer.  I try to have an open mind you can expect that my opinions may and probably will change in time. You may leave some comments but I reserve the right to ignore them completely. 


The technical content of this blog is a product of weekend/sleepless-and-or-hotel night/after-work technical struggle. Despite all efforts, it may be inaccurate and reflects the author's knowledge as of the time of writing the posts. The author of the posts will not assume any liability or responsibility to any person or entity with respect to loss or damages incurred from information contained in this blog. Any resemblance to some other training materials and/or CCNA/CCNP/CCIE exams is completely coincidental.


© 
Jaro 2013

C Programming


Programming Raspberry PI with C
Programming  Raspberry Pi with Python



October 8th 2015.

“Dude, do it the right way or don’t do it at all, ” – says Raspberry PI. So here I am reading:

“The C Programming Language”

by Brian W. Kernighan, Dennis Ritchie
  1. Getting Started.

Getting Started


What can I do with Raspberry PI? 


I can learn how to program it.


Let’s begin then.



Information Gathering

Each program is made of functions and variables. Code must be compiled to produce executable file.


Reflection

Functions
A function contains statements which end with semicolon ; . Statement specify what need to be done. Function main() has a special meaning as it marks where the program should start its execution. Data (variables) can be provided to the function inside the parentheses (). They are called arguments. I already know that functions can manipulate data (arguments) and return data as well. The returned data can be used by other functions. The braces {} will contain block of instructions.


Variables
Variables store values that will be used during computation.


Compilation and Linking
It is a process of converting the source code into code that the processor can understand and execute.


Functions
A function contains statements which end with semicolon . Statement specify what need to be done. Function main() has a special meaning as it marks where the program should start its execution. Data (variables) can be provided to the function inside the parentheses (). They are called arguments. I already know that functions can manipulate data (arguments) and return data as well. The returned data can be used by other functions. The braces {} will contain block of instructions.


Variables
Variables store values that will be used during computation.


Compilation and Linking
It is a process of converting the source code into code that the processor can understand and execute.

Creation

Based on the first reading I recreated the program.

hello.c


 #include <stdio.h>   
     
  int main() {   
     
   printf("Hello World!\n");   
     
   return 0;   
  }  


#include

During the compilation process the content of the file 'stdio.h', which c compiler knows how to locate, will be included with the source code. This particular file is called standard library which allows my program to use function printf() that will display the string 'Hello World' on the screen.

int main() {

Function main() which starts execution of each C program will take no arguments as the parentheses are empty. The left brace will mark where the block of statements will go.

printf("Hello World!\n");

Function printf() is part of standard library that displays the argument (here string 'Hello World!') on the screen. The special character \n will add new line after the string. The backslash \ is so called escape sequence informing the program that what follows has a special meaning. For instance \n is new line, \t is tabulator. Each C statement must end with semicolon ; which is mandatory. Otherwise it will contain errors and will not compile.

return 0;

This statement will return code '0' to the operating system that started execution of the program. The code '0' means that the program ended without any problem.

}

Closing brace ends the block of code in the function main().
Compilation of this program to produce an executable file in Raspberry PI:

 gcc -o hello hello.c  

Running code:
 ./hello  

Testing

Exercise 1-1.
Run the 'hello, world' program on your system. Experiment with leaving out parts of the program, to see what error messages you get.

Error 1

 #include <stdio.h   
     
  int main() {   
     
   printf("Hello World!\n");   
     
   return 0;   
  }  

Result while compiling:


 jaro@eurisko ~/code/c/orangeAcademy $ gcc -o hello hello.c    
  hello.c:1:18: error: missing terminating > character   
  jaro@eurisko ~/code/c/orangeAcademy $  

Error 2


 #include <stdio.h>   
     
  int main( {   
     
   printf("Hello World!\n");   
     
   return 0;   
  }  

Results while compiling:
 jaro@eurisko ~/code/c/orangeAcademy $ gcc -o hello hello.c    
 hello.c:3:11: error: expected declaration specifiers or ‘...’ before ‘{’ token   
 jaro@eurisko ~/code/c/orangeAcademy $  

Error 3 
 #include <stdio.h>   
     
  int main() {   
     
   printf("Hello World!\n);   
     
   return 0;   
  }  
Results while compiling:


 jaro@eurisko ~/code/c/orangeAcademy $ gcc -o hello hello.c    
 hello.c: In function ‘main’:   
 hello.c:5:12: warning: missing terminating " character [enabled by default]   
 hello.c:5:5: error: missing terminating " character   
 hello.c:7:5: error: expected expression before ‘return’   
 hello.c:8:1: error: expected ‘;’ before ‘}’ token   
 jaro@eurisko ~/code/c/orangeAcademy $  

Error 4


 #include <stdio.h>   
     
  int main() {   
     
   printf("Hello World!\n")   
     
   return 0;   
  }  

Results while compiling:
 jaro@eurisko ~/code/c/orangeAcademy $ gcc -o hello hello.c   
 hello.c: In function ‘main’:   
 hello.c:7:5: error: expected ‘;’ before ‘return’   
 jaro@eurisko ~/code/c/orangeAcademy $  

Exercise 1-2.
Experiment to find out what happens when prints 's argument string contains \c, where c is some character not listed above.



 #include <stdio.h>   
     
  int main() {   
     
   printf("Hello World!\h");   
     
   return 0;   
  }  

Results while compiling:
 jaro@eurisko ~/code/c/orangeAcademy $ gcc -o hello hello.c   
 hello.c: In function ‘main’:   
 hello.c:5:12: warning: unknown escape sequence: '\h' [enabled by default]   
 jaro@eurisko ~/code/c/orangeAcademy $  

Wednesday, October 7, 2015

Let Us Get Started




Here is the little study corner that is going to be devoted to 'practical networking' through a number of challenges. That's what makes it interesting: facing the challenges and getting better at what we do.


"I don't have access to the equipment to study practical aspects of networking," you say. Well, neither do I. So you and I have two choices: we can bitch about life unfairness and dwell on what we don't have, or we can embrace what we have and push it to its limits.


So what do we have that can be used to practice networking?



  • Packet Tracer - Free
  • GNS3 emulator - Free
  • IOL (IOS On Linux) - well this one isn't technically free but if you are persistent, you might be able to get it.
Installing those is certainly a challenge (as for the last one finding/cracking/installing/using is very difficult) but this whole section is about challenges. So, don't expect me to give you everything on a silver platter. I am here to help you get sweaty and dirty, not pamper you.

I am going to try to challenge you through interesting labs and questions. I don't like Packet Tracer emulator very much but, what the hell, I am going to give it a shot and see how much I can get out of it. Here's our topology we are going to play with:


If you have installed Packet Tracer using the link above and launched the topology I have included, you have completed the first task. 

In the 'Learning By Doing' Section I will use both Packet Tracer and IOL. Below is the topology diagram for IOL emulator:



Come back soon for more. We're going to have fun, I promise.

Cisco: Beginner Level

Main Page |  CCNA Exercises   |   CCNP Labs | Contact Lesson Labs: Lesson 2 - Lab . CCNA Lessons: 01 - Connecting to Ci...