0% found this document useful (0 votes)
28 views

CS 403 - Module 1

Uploaded by

Judielyn Cualbar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

CS 403 - Module 1

Uploaded by

Judielyn Cualbar
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 21

CS 403 COURSE MODULE MODULE NO.

1
NORTH CENTRAL MINDANAO COLLEGE
Maranding, Lala, Lanao del Norte

COLLEGE OF ENGINEERING AND COMPUTER SCIENCE


Department of Computer Science
CS 403-NETWORK PRINCIPLES AND PROGRAMMING
1st Semester of A.Y. 2020-2021

Topic

THE INTRODUCTION, OSI MODEL AND UNIX/LINUX COMMANDS/ LINUX BASICS

Rationale

Networking is referred to as electronically linking machines for information-sharing purposes. Networks


function on one simple principle: "pass it on." Each layer is responsible for a very specific job, and then passes
the data on to the next layer. Control is transferred from one layer to the next in the OSI model, beginning at
the application layer ( Layer 7) in one station, and continuing to the bottom layer, going through the channel
to the next station and back up the hierarchy. The OSI model takes over the role of inter-networking and
divides it into what is called a vertical stack composed of the 7 layers. Some industry also used some basic
commands for their network.

Intended Learning Outcomes

ILO 1: Understand the OSI Model.


ILO 2: Know the seven layers of OSI Model.
ILO 3: Learn the basic commands in Linux.
Activity/Activities

Discussion Online, Online Quiz

Discussion

What is Computer Network?


A computer network is a group of devices connected with each other through a transmission medium such as
wires, cables etc. These devices can be computers, printers, scanners, Fax machines etc. The purpose of
having computer network is to send and receive data stored in other devices over the network.

The Open Systems Interconnection (OSI) reference model has served as the most basic elements of computer
networking since the inception in 1984. The OSI Reference Model is based on a proposal developed by the
International Standards Organization (ISO). The original objective of the OSI model was to provide a set of
design standards for equipment manufacturers so they could communicate with each other. The OSI model
defines a hierarchical architecture that logically partitions the functions required to support system-to-system
communication.
The Open Systems Interconnect model, or OSI model, divides up jobs that have to happen for a smooth
network experience. The model allows network engineers to develop and improve individual layers

1
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1
regardless of what's going on with the others.
To put this into perspective, the main function of a web browser (such as Internet Explorer) is to show web
pages. It does this by decoding HTML so that you can see the web page an author meant you to see. The web
browser itself doesn't care about what the voltage levels are on the Ethernet cable connecting your PC to the
router it uses, it just relies on them to be correct
Layers of communication
When you do something on a network (for example, send an email from London to New York) think of these
layers as being stacked on top of each other with you at the top on layer-7. At the other end in New York
there is another stack of the same layers with your friend on top of that respective stack. Once sent by you the
data goes through all the layers, from the application layer down to the physical layer, then across wires to
your friend's physical layer where it goes back up the stack again.
In fact there are lots more little stacks of layers in between you in London and your friend in New York
which your data has to go up, then down again. This happens when the routers in each ISP between you and
your friend need to look at the data to see where it should go to; the data will go from the physical layer
(layer-1) back up to the network layer (layer-3) where it will be examined, then sent back down to the
physical layer to continue its journey.
Want to see how it works?
If you want to get an idea of this in action open up a command line (Windows Key+R, type "cmd") and type
"tracert bbc.co.uk" to watch the journey unfold. You'll see that when you call up the BBC web page, the data
packets take a journey which can go all over the world (even if you're right next door to the server--that's the
network layer!)
You'll also see that the BBC website lives at 212.58.244.69 which is the IP address of the server (IPv4). This
could be a different IP as the BBC uses lots of servers to serve its websites, but luckily you don't usually have
to remember the IP address and just need to type the friendlier domain name "bbc.co.uk" and the IP address
is worked out behind the scenes using a service called Domain Name Services (the application layer!).

But there's more ...

The OSI model is used for all kinds of networks, not just the internet, and network engineers love to mix-
and-match each layer. You might be developing a network for managing high-speed trains so it'll probably
have some pretty clever applications (layer-7) for running the timetable, controlling the stability and
everything else a high-speed train needs. As Ethernet is cheap to use you employ that for the physical
connections (layer-1) that run through-out the train connecting the various applications to each other.
Likewise as Ethernet doesn't carry data well over very long distances you would probably use optical fibre
for the physical connections (layer-1) between stations. As everything works within the same OSI model you
are able to mix and match various technologies for each layer.
Almost all of the protocols for each of the layers are set by standards groups during annual conferences
where they try to improve existing protocols or invent new ones. By using standardised protocols at each
layer you could ask a manufacturer to build a box that uses 802.3 (Ethernet covering layers I to 3) while you
work on your application, knowing exactly how the box will function.
The OSI model is one of those important things that sits behind everything on any network and provides a
structure that allowed the internet to function. Without the OSI model it would be have been nearly impossible to
connect networks together and we wouldn't have the internet (or World Wide Web) as we know it today.

2
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

There are seven layers of the 051 model working from top to bottom.

Application (Layer-7): The 'top' layer. This is the stuff you see when using the Internet (i.e. webpages). It
knows the difference between what an email should look like and what a web page should look like.

Presentation (Layer-6): This layer encrypts and decrypts anything that is encoded. So, for example, you can
log into your online bank securely. The data bits being sent down the line will look jumbled until the right
software at the right place decodes them on the application layer.

Session (Layer-5): The session layer establishes connections between computers. If you visit a webpage, the
session layer makes sure you're connected to the server until everything is transferred. So for example if
you're in a chat room, the session layer keeps the room open.

Transport (Layer-4): This is the first layer that doesn't care what the actual data is. The transport layer just
packages bits into nice bundles called 'data packets'. These packets are mostly used so that the computers can
tell if something gets lost along the way.

Network (Layer-3): The network layer performs all the routing functions, making sure that packets from the
transport layer aren't just wandering around the wires, but that they actually have somewhere to go (much like
the sorting office in the postal system).

Data Link (Layer-2): The data link layer is primarily the switches within the network. These put most bits
into frames for easier routing by the network layer and work out how the physical layer is connected (i.e.
which computer is connected to which port).

Physical (Layer-1): The 'bottom' layer. The physical layer is the actual infrastructure that underpins
everything above. This covers the physical fibre, copper cables, volts, zeros and ones that make up the nuts

3
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

and bolts of any network.

Basic Linux/Unix Commands with Examples

Linux is the most popular server OS. Linux is a clone of UNIX. Knowing one is as good as knowing the other.

File Management becomes easy if you know the right commands.

Sometimes, commands are also referred as "programs" since whenever you run a command, it's the
corresponding program code, written for the command, which is being executed.

Let's learn the must know Linux commands.

Listing files (ls)

If you want to see the list of files on your UNIX or Linux system, use the 'ls' command.

It shows the files /directories in your current directory.

Note:

 Directories are denoted in blue color.


 Files are denoted in white.
 You will find similar color schemes in different flavors of Linux.

Suppose, your "Music" folder has following sub-directories and files.

You can use 'ls -R' to shows all the files not only in directories but also subdirectories 

4
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

NOTE: The command is case-sensitive. If you enter, "ls - r" you will get an error.

'ls -al' gives detailed information of the files. The command provides information in a columnar format. The
columns contain the following information:

1st Column File type and access permissions

2nd Column # of HardLinks to the File

3rd Column Owner and the creator of the file

4th Column Group of the owner

5th Column File size in Bytes

5
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1
6th Column Date and Time

7th Column Directory or File name

Let's see an example - 

Listing Hidden Files

Hidden items in UNIX/Linux begin with - at the start, of the file or directory.

Any Directory/file starting with a '.' will not be seen unless you request for it.  To view hidden files, use the
command.

ls -a

Creating & Viewing Files

The 'cat' server command is used to display text files. It can also be used for copying, combining and creating
6
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

new text files.  Let's see how it works.

To create a new file, use the command

1.  cat > filename


2.  Add content
3.  Press 'ctrl + d' to return to command prompt.

To view a file, use the command -

cat filename

Let's see the file we just created -

Let's see another file sample2

The syntax to combine 2 files is -

cat file1 file2 > newfilename

Let's combine sample 1 and sample 2.

As soon as you insert this command and hit enter, the files are concatenated, but you do not see a result. This
is because Bash Shell (Terminal) is silent type.  Shell Commands will never give you a confirmation
message like "OK" or "Command Successfully Executed". It will only show a message when something goes
wrong or when an error has occurred.

To view the new combo file "sample" use the command

cat sample
7
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

Note: Only text files can be displayed and combined using this command.

Deleting Files

The 'rm' command removes files from the system without confirmation.

To remove a file use syntax -

rm filename

Moving and Re-naming files

To move a file, use the command.

mv filename new_file_location

Suppose we want to move the file "sample2" to location /home/guru99/Documents. Executing the command

mv sample2 /home/guru99/Documents

mv command needs super user permission. Currently, we are executing the command as a standard user.
Hence we get the above error. To overcome the error use command.

sudo command_you_want_to_execute
8
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

Sudo program allows regular users to run programs with the security privileges of the superuser or root.

Sudo command will ask for password authentication. Though, you do not need to know the root password.
You can supply your own password. After authentication, the system will invoke the requested command.

Sudo maintains a log of each command run. System administrators can trackback the person responsible for
undesirable changes in the system.

guru99@VirtualBox:~$ sudo mv sample2 /home/quru99/Documents


[sudo] password for guru99: ****
guru99@VirtualBox:~$

For renaming file:

mv filename newfilename

NOTE: By default, the password you entered for sudo is retained for 15 minutes per terminal. This eliminates
the need of entering the password time and again.

You only need root/sudo privileges, only if the command involves files or directories not owned by the user or
group running the commands

Directory Manipulations

Enough with File manipulations! Let's learn some directory commands.

9
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

Creating Directories

Directories can be created on a Linux operating system using the following command

mkdir directoryname

This command will create a subdirectory in your present working directory, which is usually your "Home
Directory".

For example,

mkdir mydirectory

If you want to create a directory in a different location other than 'Home directory', you could use the
following command -

mkdir

For example:

mkdir /tmp/MUSIC

will create a directory 'Music' under '/tmp' directory

You can also create more than one directory at a time. 

Removing Directories

10
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

To remove a directory, use the command -

rmdir directoryname

Example

rmdir mydirectory

will delete the directory mydirectory

Tip: Ensure that there is no file / sub-directory under the directory that you want to delete. Delete the
files/sub-directory first before deleting the parent directory.

Renaming Directory

The 'mv' (move) command (covered earlier) can also be used for renaming directories. Use the below-given
format:

mv directoryname newdirectoryname

Let us try it:

Other Important Commands

The 'Man' command

Man stands for manual which is a reference book of a Linux operating system. It is similar to HELP file found
in popular software.

To get help on any command that you do not understand, you can type

11
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1
man

The terminal would open the manual page for that command.

For an example, if we type man man and hit enter; terminal would give us information on man command

The History Command

History command shows all the commands that you have used in the past for the current terminal session. This
can help you refer to the old commands you have entered and re-used them in your operations again.

12
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

The clear command

This command clears all the clutter on the terminal and gives you a clean window to work on, just like when
you launch the terminal.

Pasting commands into the terminal

Many times you would have to type in long commands on the Terminal. Well, it can be annoying at times, and
if you want to avoid such a situation then copy, pasting the commands can come to rescue.

For copying, the text from a source, you would use Ctrl + c, but for pasting it on the Terminal, you need to
use Ctrl + Shift + p. You can also try Shift + Insert or select Edit>Paste on the menu

NOTE: With Linux upgrades, these shortcuts keep changing. You can set your preferred shortcuts via

13
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

Terminal> Edit> Keyboard Shortcuts.

Printing in Unix/Linux

Let's try out some easy unix command list which can print files in a format you want. What more, your
original file does not get affected at all by the formatting that you do. Let us learn about these commands and
their use.

'pr' command

This command helps in formatting the file for printing on the terminal. There are many options available with
this command which help in making desired format changes on file. The most used 'pr' options are listed
below.   

Option Function

-x Divides the data into 'x' columns

-h "header" Assigns "header" value as the report header

-t Does not print the header and top/bottom


margins

-d Double spaces the output file

-n Denotes all line with numbers

-l page length Defines the lines (page length) in a page.


Default is 56

-o margin Formats the page by the margin number

14
www.ncmc.edu.ph
CS 403 COURSE MODULE Let us try some of the options and study their effects.
MODULE NO.1

Dividing data into columns

'Tools' is a file (shown below).

We want its content to be arranged in three columns. The syntax for the same would be:

pr -x Filename

The '-x' option with the 'pr' command divides the data into x columns.

Assigning a header

The syntax is:

pr -h "Header" Filename

15
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

The '-h' options assigns "header" value as the report header.

As shown above, we have arranged the file in 3 columns and assigned a header

Denoting all lines with numbers

The syntax is:

pr -n Filename

This command denotes all the lines in the file with numbers.

These are some of the 'pr' command options that you can use to modify the file format.

Printing a file

Once you are done with the formatting, and it is time for you to get a hard copy of the file, you need to use
the following command:

lp Filename

16
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

or

lpr Filename

In case you want to print multiple copies of the file, you can use the number modifier.

In case you have multiple printers configured, you can specify a particular printer using the Printer modifier

Installing Software

In windows, the installation of a program is done by running the setup.exe file. The installation bundle
contains the program as well various dependent components required to run the program correctly.

In Linux/UNIX, installation files are distributed as packages. But the package contains only the program itself.
17
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

Any dependent components will have to be installed separately which are usually available as packages
themselves.

You can use the apt commands to install or remove a package. Let's update all the installed packages in our
system using command -

sudo apt-get update

The easy and popular way to install programs on Ubuntu is by using the Software center as most of the
software packages are available on it and it is far more secure than the files downloaded from the internet.

18
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

Linux Mail Command

For sending mails through a terminal, you will need to install packages 'mailutils'.

The command syntax is -

sudo apt-get install packagename

Once done, you can then use the following syntax for sending an email.

mail -s 'subject' -c 'cc-address' -b 'bcc-address' 'to-address'

This will look like:

Press Cntrl+D you are finished writing the mail. The mail will be sent to the mentioned address.

Exercise

Refer to our google classroom

Assessment

19
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

Answer this short quiz.


1. Why do engineers use a “model” to organize their approach to solving a large and complex
problem?
a) Because it allows them to build something small and test it
in a wind tunnel
b) Because talking about a model delays the actual start of the
hard work
c) Because they can break a problem down into a set of smaller
problems that can be solved independently
d) Because it helps in developing marketing materials
2. Which is the top layer of the network model used by TCP/IP networks?
a) Application
b) Transport
c) Internetwork
d) Link
3. Which of the layers concerns itself with getting a packet of data across a single physical
connection?
a) Application
b) Transport
c) Internetwork
d) Link
4. What does CSMA/CD stand for?
a) Carrier Sense Multiple Access with Collision Detection
b) Collision Sense Media Access with Continuous Direction
c) Correlated Space Media Allocation with Constant Division
d) Constant State Multiple Address Channel Divison
5. What does URL stand for?
a) Universal Routing Linkage
b) Uniform Retransmission Logic
c) Uniform Resource Locator
d) Unified Recovery List

Reflection

Why OSI model and the Linux commands are very important?

Resources

 Barker, D. (2020). The OSI network model explained: " Database and Network Journal, vol 42.
gale.
 Barker, D. (n.d.). The OSI network model explained.
 Severance, C. (n.d.). Introduction to Networking.

Prepared By

Judielyn L. Cualbar
CECS Faculty

20
www.ncmc.edu.ph
CS 403 COURSE MODULE MODULE NO.1

21
www.ncmc.edu.ph

You might also like