Date post: | 02-Jan-2016 |
Category: |
Documents |
Upload: | henry-short |
View: | 222 times |
Download: | 3 times |
CMPT 471Networking II
Course Information
1© Janice Regan, 2013
CMPT 471: Networking II Wed. 17:30-20:20 Suggested Textbook:
Internetworking with TCP/IP Vol. 1: Principles, Protocols, and Architecture (5/e)
Douglas Comer, Prentice-Hall, 2006
Additional References: Internetworking with TCP/IP Vol. II: Design,
Implementation, and Internals (3/e) Douglas Comer, Prentice-Hall, 1999:
Routing in the Internet (2/e) Christian Huitema, Prentice Hall PTR, 2000: Excellent book on Internet routing protocols.
© Janice Regan, 2013 2
CMPT 471: Networking II Additional References:
Unix Network Programming, the sockets networking API v1 3rd edition
Stevens, Fenner, and Rudoff, Addison Wesly, 2004 Building Internet Firewalls (2/e)
Zwicky, E. Cooper, S., Chapman, D., O'Reilly & Associates, 2000
IPv6 The New Internet Protocol (2/e) Huitema, C., Prentice Hall PTR, 1998
The DHCP Handbook 2nd edition Droms and Lemon, Sams, 2002
Unix Power Tools 3rd edition Powers, Peek, O'Reilly and Loukides, O'Reilly, 2002 .
© Janice Regan, 2013 3
Class web-site All the information discussed today and
more can always be found on the class web-site
To find the class web site go to http://www.cs.sfu.ca/CourseCentral/471/jregan
Course Central is also a useful link to abundant information useful to students taking a computing science course
© Janice Regan, 2013 4
Communications
© Janice Regan, 2013 5
CMPT 471 Website
6© Janice Regan, 2013
My availability
© Janice Regan, 2013 7
© Janice Regan, 2013 8
© Janice Regan, 2013 9
Grading Scheme
Exams
© Janice Regan, 2013 10
Assignments Five assignments
Each assignment is worth 7% of your course grade Assignments may be completed in groups of 1 to 3
students Problems similar to the assignments will appear on
the midterm and the final. Help is available by email, during office hours Complete solutions will be posted for most questions Only a selection of problems will be graded Part of the grading may be based on LAB quizzes
© Janice Regan, 2013 11
Final One 3 hour final examination 30%-40% short answer problems 60%-70% longer problems that utilize
several important concepts and require integration of those concepts.
A sample exam, including solutions, will be posted two weeks before the final exam
© Janice Regan, 2013 12
Quizzes Examples quiz problems from previous semesters with
detailed solutions are already posted on the class website Quizzes and solutions will also be posted to help you
review and keep up. Each quiz is expected to take about 20-30 minutes to
answer. Answers should consist of a short concise paragraph
of 30 sentences, about 1 page, explaining a concept or method, or solving the problem.
Keep in mind that most posted solutions are more extensive than expected quiz answers.
© Janice Regan, 2013 13
© Janice Regan, 2013 14
Important Dates
© Janice Regan, 2013 15
Important Dates
© Janice Regan, 2013 16
Assignments At least two weeks before the due date the
assignment will be posted on the website\ Assignments may be completed individually or in
groups of 1-3 students Assignments will be lab exercises illustrating the
operation of protocols and problems on material covered in class
Complete solutions to most questions will be posted Information of proper preparation of assignments and
lab problems is available on the class website.
© Janice Regan, 2013 17
Grading Information Assignments should be:
submitted electronically using the course management system
Bonus points (5%) are available for submitting assignments more than 48 hours early
No late assignments will be accepted Unofficial grades will be available in the
course management system
© Janice Regan, 2013 18
© Janice Regan, 2013 19
Readings and Notes
© Janice Regan, 2013 20
Academic Honesty
© Janice Regan, 2013 21
Academic Honesty
© Janice Regan, 2013 22
Read the policy
Getting Started: 1 You will be required to complete many parts of
your assignments using the CSIL networking laboratory A virtual networking laboratory is now available and
is accessible remotely (from Windows and Linux machines)
You will have root access on most of the virtual machines of the networking lab (except routers)
You will be running tasks that should not be run (except by a network administrator) outside the networking lab
You will be informed when the network is ready to use
© Janice Regan, 2013 23
Operating System In the CSIL labs you will be using computers
that run the LINUX operating system Prepare for your first assignment
In the first week of class familiarize yourself with Linux and writing simple scripts.
You will receive instructions on how to use the virtual networking lab next week, after this you can familiarize yourself with Using ethereal the packet capture software Accessing and using the virtual lab
© Janice Regan, 2013 24
CMPT 471Networking II
Linux Primer
Getting Ready to use the Network Lab
25© Janice Regan, 2013
Shell Scripts A shell script is an executable file containing a series
of shell commands. When the shell script is executed the commands in the file are executed in sequence by the shell.
A shell script records a series of command line actions and easily executes them again and again Assures repeatability of experiments and processes Allows long series of commands to be easily tested and
debugged There are different shell scripting languages such as
csh (C shell), tcsh sh (Bourne shell), bash (Bourne again shell) Perl ……
© Janice Regan, 2013 26
Selecting a Shell Script Language On the command line type
the name of the shell followed by return to enter the shell. exit followed by return to leave the shell. To determine which default shell you are presently using
echo $SHELL finger youruserid (your default shell)
The present shell will be indicated by the prompt To indicate which shell to use inside a shell script
in the first line of your script file #! /bin/csh To indicate which shell to use when executing a shell
script called scriptname bash scriptname arguments or csh scriptname arguments
© Janice Regan, 2013 27
Executing a Shell Script Your script file must be executable, you will
need to change the permissions to make it executable (discuss how later in this lecture)
Executing a shell script called scriptname bash scriptname arguments csh scriptname arguments source scriptname arguments ./scriptname arguments
© Janice Regan, 2013 28
Using Variables in a script You can define and use your own variables
within a shell script. VariableName=23 (no spaces around =)
Sets the value of VariableName to 23 echo $VariableName
Echo’s (prints the value of VariableName) to the output line.
VariableName2=$VariableName Sets the value of VariableName2 to be the value of
VariableName1
© Janice Regan, 2013 29
Printing from a Shell Script
To print to the standard output either use echo or run a shell command that produces output echo “This is a string”
prints the string in the brackets echo $variablename (also used on command line )
prints the value of the variable with name variablename echo “The value of variablename is; $variablename”
Prints the string ‘The value of variablename is; ” followed by the value of variablename
ls Prints a list of all files in the present directory
© Janice Regan, 2013 30
Command Line Arguments Passing command line variables into a shell
source scriptname argument1 … argumentn Inside the script the command line argument values will
each have a descriptor, the first argument’s value will be $0, the second argument’s value will be $1 and so on.
The descriptors can be used to represent the command line variables within the script echo `Second command line variable: $1` Prints the string “Second command line variable: “ followed by
the value of the second command line variable
© Janice Regan, 2013 31
Using Basic Unix Commands Any basic Unix command can be run from
the command line, or from within a shell script
To work with shell scripts you must first be familiar with basic Unix commands
Commands are used to move around within the file system, to create and operate on files, to interact with the operating system
© Janice Regan, 2013 32
Some basic commands Remember UNIX is case sensitive yppasswd username (username is optional)
Executed from your command line Will ask you to input your old password and your new passwd
twice You can only change your own passwd unless you are root
man commandname or info commandname Tell me how to use the command with name commandname
su Become the root user (superuser, substitute user) You will need to be root to complete many of your assignments.
Do so with care.. whoami Tell me my username
© Janice Regan, 2013 33
Directories Directory creation, navigation, removal
mkdir directoryname make directory directoryname
rmdir directoryname remove empty directory cd directorypath go to directory directorypath ls directorypath list files in directory directorypath cd return to your home directory ls list files in this directory pwd show path to and name of current directory cd .. Move to the parent directory of this directory (one
layer further up the directory tree
© Janice Regan, 2013 34
Directory structure
Dir1
Dir5 Dir6 Dir7
© Janice Regan, 2013 35
In myhome cd Dir2 (goes to Dir2 ) cd Dir2/Dir5 (goes to Dir5 )
In Dir5 cd .. (goes to Dir3) cd ../.. Or cd (goes to myhome) cd ../Dir6 (goes to Dir6)
Anywhere cd will take you to myhome (your home directory)
cd / takes you to the root directory
myhome
Dir2 Dir3 Dir4
Root file structure
© Janice Regan, 2013 36
Files To make a file open it using your favorite text editor mv filepath1 filepath2
Moves (renames) a file or directory mv a b file previously named a is now named b mv a ../a file a is moved from the present directory to the
parent directory of the present directory rm filepath removes (deletes) a file
rm a deletes file a from the current directory rm ../a removes file a from the parent of the present
directory grep pattern filepaths
Find all occurrences of pattern in requested files
© Janice Regan, 2013 37
Files more filename or less filename
Displays contents of file filename one page (screen) at a time
cp filename1 filename2 Make a copy of filename1 with name filename2
cat filename1 filename2 filename3 Will print the contents of each file in sequence
Contents of filename1 Contents of filename2 Contents of filename3
© Janice Regan, 2013 38
Wildcards Wildcards are used to represent multiple possibilities
* matches any number of characters ? Matches a single character
Examples ls a?
List all files in the current directory beginning with a and having a name of length 2 characters.
grep mystring */*file Find all occurences of the string “mystring” in all files whose
names end with the string “file”. The files ending with string “file” must be in a subdirectory of the present directory
rm [a-c]* Remove all files with filenames beginning with a b or c from the
current directory
© Janice Regan, 2013 39
Redirection Redirect input and/or output
> filename redirect standard output from screen to file. cat file1 file2 file3 > f4 A new file f4 is opened and the contents of file1, file2 and file 3 are
successively added to the file f4. If f4 exists it will be overwritten. < filename take input from file filename
a.out < datafile (a.out is the default output file for a compiled executable)
>> filename redirect standard output from screen to file. Appends output to an existing file
cat file1 file2 file3 >> f4 The contents of file1 then file2 then file3 will be successively
appended to the current contents of f4
© Janice Regan, 2013 40
Piping Piping allows you to send the output
of one process to become the input of another process without using io to store it in an intermediate file ls a* | more
List the files in the current directory whose names start with a, one page at a time
© Janice Regan, 2013 41
File Permissions Can use ls –l to find present permission for files drwxrwxrwx for directory -rwxrwxrwx for file
u g o 3 sets of permissions
User (u) group (g) other(o)
Each set allows or disallows read write & or execute rwx (allow all) rw- (read write allowed) r - - (read only) Order of sets is ugo
© Janice Regan, 2013 42
Setting File Permissions: 1 Permissions can be reset by using chmod chmod can specify permission in two ways
Numeric values read(4) write(2) execute(1). Sum desired values to give one digit permission value for each set Read write and execute 7, Write 2, Read and Execute 5
Adding or removing particular permissions Add execution permissions for user chmod u+x filename Remove write permissions for other chmod o+w filename Add read permissions for everyone chmod a+r filename
© Janice Regan, 2013 43
File Permissions Examples chmod u-x filename
(remove owners execute permission)
chmod a+w filename (make the file readable for all users)
chmod 644 filename (make the file readable for all users but writeable only by the
owner)
chown newowner filename (you must own the file or be root)
chgroup newgroup filename
© Janice Regan, 2013 44
Processes Command &
Run command as a background process cntrlZ
Suspend (temporarily stop) foreground process bg Move suspended process to background fg Move background process or suspended
process to the foreground cntrlC
Terminate the foreground process
© Janice Regan, 2013 45
Processes ps or ps -l
List information about all current processes
kill pidnumber Kill background process with PID pidnumber (use ps to find the pidnumber of the process)
ps -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD
8 S 37636 7058 7054 0 46 20 ? 273 ? pts/38 0:01 csh
8 S 37636 7072 7058 0 51 20 ? 296 ? pts/38 0:00 bash
To assure a process will die use kill -9 pidnumber
© Janice Regan, 2013 46