You are on page 1of 24

COURSE MODULE NORTH CENTRAL MINDANAO

MODULE WEEK NO.1

COLLEGE
Maranding, Lala, Lanao del Norte

College of Engineering and Computer Science


CS 403: Network Principles and Programming
Semester of A.Y. 2020-2021

Introduction

This module discusses the computer networks, the OSI model and its seven layers and the basic commands in Linux.
You will also know why the receiver will receive data from the sender.

Rationale

You may encode the rationale in this section.

Intended Learning Outcomes

A. Understand the OSI Model.


B. Know the seven layers of OSI Model.
C. Learn the basic commands in Linux.
Activity

Give at least one scenario that apply the seven layers of OSI model.

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
1
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1
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 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!).

2
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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.

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

3
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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).

4
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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 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:

5
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

 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 

6
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK 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


7
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

5th Column File size in Bytes

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

8
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

Creating & Viewing Files


The 'cat' server command is used to display text files. It can also be used for
copying, combining and creating 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

9
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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

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

10
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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

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


11
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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.

Creating Directories

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


command

12
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1
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
To remove a directory, use the command -

rmdir directoryname

13
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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

man
14
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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.

15
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK 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
16
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

select Edit>Paste on the menu

NOTE: With Linux upgrades, these shortcuts keep changing. You can set your
preferred shortcuts via 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


17
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1
-l page length Defines the lines (page length) in a
page. Default is 56

-o margin Formats the page by the margin


number
Let us try some of the options and study their effects.

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.

18
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

Assigning a header
The syntax is:

pr -h "Header" Filename

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.

19
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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

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

20
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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. 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

21
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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.

Linux Mail Command

22
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1

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.

Summary

 You can format and print a file directly from the terminal. The formatting you
do on the files does not affect the file contents
 In Unix/Linux,  software is installed in the form of packages. A package
contains the program itself. Any dependent component needs to be
downloaded separately.
 You can also send e-mails from terminal using the 'mail' network
commands. It is very useful linux commands.

Exercise

Refer to our google classroom.

Assessment

Answer this short quiz and submit your answer on or before August 25, 2020.

1. Why do engineers use a “model” to organize their approach to solving a large and
23
Crafted by Mr. Arvin Narvaza
COURSE MODULE MODULE WEEK NO.1
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 and Additional Resources

 The OSI network model explained by David Barker


 Barker, David. "The OSI network model explained." Database and Network
Journal, vol. 42, no. 5, Oct. 2012, p. 3+. Gale Academic OneFile Select,
https://link.gale.com/apps/doc/A304051887/GPS?
u=phncmc&sid=GPS&xid=c1d38e18. Accessed 20 Aug. 2020.
 Introduction to Networking by Charles Severance.

24
Crafted by Mr. Arvin Narvaza

You might also like