Saturday, September 15, 2007

Synchronous --In Todays World-- DCN386 Week2

How did they change the computer to a asynchronous to synchronous to achieve this is a personal computer your forced to invest into a NIC card, this allows the pc to transmit data, in a synchronous <-= sends big blocks of data, synchronous transmission, the NIC card is the machine that is installed into your computer to allow this to happen theirs Ethernet Nics their areToken Ring NICS, they all send data in big blocks, pretend we have a nice big file, what allows asynchronous INT14, synchronous INT52, take data in memory and transfer a whole block of data and get transfer to the NIC, the NIC can receive this, one INT big block, incase of Ethernet how big is the block with either it will take data up to 1500 bytes and move it to the nic the nic has a block of data, up to 1500 bytes the NIC like a the UART, NICS also prepare the data, 1000 or 500 bytes long,

Last questions test 1 what is Ethernet and how does it work?

look at the synchronous aspect of Ethernet, it will put extra stuff in front |SourceAddress| and |DestinationAddress|, before it sends data it puts 8 bytes, the total 64 bit frame, in front of everything, this is called a Preamble, and all the bits are 0101010101010101010, The Preamble sets up the synchronization, how can this help with the timing, it would look like positive and negative pulses, on off pulses, now lets pretend we are NICs, we have to start talking to each other we have to make sure we are talking at the same speed, because we are sending big blocks of data, must talk exactly at the bps speed, this is the purpose of the Preamble, the receiving nic tunes into this and understands, both nics work at the same speed, ordinary nics to 1000billion bps, the nic does not sample at the wrong moment, Ethernet has two tricks, a 1 bit type, ur nic determines if it a 1 bit or a 0 bit, it maintains sync of the digital pulse itself, it syncs and when its reading in the bytes and it maintains sync, because the sampling of the digital signal to maintain a connection, because its doing this protocols can do an enhanced data checking, this is almost 100% error detection, all use this use this system called CRC cyclic redundancy checking, an error checking process, all protocols use this.
In the exam ten protocol questions they all do error checking in the same way

INT52 interrupt cpu, it downloads 1500 in the memory in the nic 1200 bits turn them in memory, its data, but to a nic it’s a big binary number, 1500 bytes long, nic has a micro processor, good to do division, we divide the data by a magic number, the text polynomial, x31+x17….ignore this no one can ever remember just understand the magic number is a standard magic number, the only thing, it 2 standard magic number 32 and 16 bits, soon protocols will have 64 bits, the bigger the more accuracy is built in to the CRC, …so pretend its 32 number and it does long division, what CRC does it ends up with a 32 bit remainder, which is the CRC, they stick this at the end of the data and its ready to be transmitted, when its transmitted same division same magic number and it comes up with the remainder and compares it, and if their identical then the NIC is 99% protected.
Synchronous transmission and Asynchronous transmission….5-6lines paragraph,

Asynchronous -The Past- Week2 DataCommunications

Every computer was made asynchronous, but all the computers in Canada has been modified to send data with synchronization involved, asynchronous transmission is characterized, its most essential feature it sends data at one byte, one character at a time, each character is a separate transmission event,
How does a compute/transmit?
you can write your own commands, what’s an interrupt, do something and pass control to the Central Processing Unit, there are a lot of interrupts….sending a character to one machine to the next,
01000010A
01000001B
Lets say we want to send the B to Belgium what you do you do, have software, INT14 it does one thing it stops the CPU looks at a specific address in the computer memory it will take the data and send it to a special chip on you mother board, every mother board has one of theses a UART, take your computer apart u will find one of these, Universal Asynchronous Receiver Transmitter, every mother board has one, weather you have one, sadly you don’t use ur UART, it does three incredible things, it moves in parallel bus, but you cant send data 8 bits at the same time, because to send 8 bits at the same time you would need 8 leads in it and you don’t find it, theirs essentially two, one for sending and one for receiving, you got to send data 1 bit at a time, in a serial manner, when you send stuff to ur printer you send it parallel, the UART takes ur data and sends it through the serial port, 1 INT and all it send was 1 Char, a million char it’s a million INT, imagine that you want to send a huge file to your buddy the CPU gets interrupted every time, you cant just send eight bits out of your serial port the UART has to prepare each character, it prepare 8 bits, how does it do that?
Here are our 8 bits B 01000010, its ready to get sent out but first, the UART put some extra info in the a start bit and a stop bit , it will add something called a parity bit, the start bit can be zero or one,
The start bit is always 0’s
Why is that?
Back in the day when ur grand-mama was taking datacom their was a teletype device, some one can type to one typewriter and go to the other one down the line, if no one was sending data, the type writer would send a constant stream of 1 bits, this tradition exist today for the 70% of people using modems, two modems are not sending data but a constant stream of 1 bits, imagine constant stream of 1 bits then it gets a 0, it sees the char coming it reads the whole character and at the end it discovers a stop bit, which is a 1, which faithfully it puts the line in an idle condition waiting for the next character to arrive, UART puts a start bit and end bit, and the parity bit, the parity bit is an error checking mechanism, in the old days, when you were settings up your Operating Software, you set it up odd or even parity, what does this mean ODD parity, odd parity means the number of 1 bits in the character has to be odd, lets look at the B
0100010 we want to send it somewhere the ur is going to put the party bit which would be a 1
101000010
Because the number between the start and stop has to be a number, it’s a even number it will use the parity bit to be odd, imagine a bit error has happened, and a character has changed, it arrives at the destination and it starts to count the 1 bits, and it counts 4 and four is not an odd number, so theirs an error, this is prob the most dangerous idea someone has had, what if the bolt of lighting hit it and it changed two characters and it found the odd the number so its correct, but its NOT correct, still this is efficient enough to work ,

Why do 70% of the world do this? Cause its cheap, cause its virtually free. Telephones network exist to send asynchronous data. The reason it works asynchronous is dealing with 8 bits at a time…

A UART gets a 0 it will sample the first bit then it will sample the remain ding bit, and it will tell if its off, if it had a constant string sooner or later it will tell it cant tell the difference between a zero or a one, it only has to sample the voltage level 8 times, it can still tell a 1 from a 0, then comes the 1 bit and re-idles the start position, every char interrupts the CPU, sends the data, same with receiving, INT14 sends the char to computer memory if you send a million byes you are sending a million int, each int with a start bit and parity, asynchronous is identified sending one character at a time, cheap easy, bad slow and error prone so error prone, Christianson, though parity bit checking is the pits, he will write a computer program that will improve the bits, X-MODEM just a program first of the great Asynchronous protocols, it transmits asynchronous data, with an improvement, its very simple,
How is this!?
Lets say you have a file, foo.txt. and you want to send it to your buddy, all you do is run x-modem, call your body, buddy stats x-modem, as soon as they know they are both running it will see each char and store it in memory in fact x-modem reads in 128 char and stores them in memory then it does parity checking
01000010
01000001
10111100 <-- parity bite, a BLOCK CHECK CHARACTER, then x modem starts sending 128 characters, then it sends an x char locks and checks char, x character running on the other machine will save it and when it receives 129 it will block check carrier, it compares by doings its own block character check, if its both the same and 90% guaranteed, so this has improved error checking, if their different x-char will send a char to the other machine asking for a re-transmission, how does it do it sends a NACK, negative acknowledgement, special 8 bit code means their has been a error, if there is no errors the machine sends an ACK, acknowledgement char, when you log into the cisco routers through the console char, HYPER TERMINAL is crappy or x-modem, x-modem, y-modem, z-modem, file transfer protocols, the original intent was improving error detections, we evolved to file transfer programs. That’s it for asynchronous.  This is Test 1,

Thursday, September 13, 2007

Winter 32 divide 4 eight bit octets

32 divide 4 eight bit octets
Each octet 0-255
Network Id Host Id
Network Id, common and shared by all computer through each physical segment.
192.176.11, Each would have a unique have host id. 201
Each physical segment has a unique network id, another physical physical segment will have another Id, then it would be shared by the computers on the physical segment. Give each physical segment a unique host id.

What is a physical Segment,
Broadcast Domain portion where it is forwarded it, Routers DO not forward broadcasts, All devices one port of router or two routers is a physical segment, all hosts on a physical segment share a physical segment.
Host, unique ip address to for the network, all devices physical segment share the common Network Id, specified by the sub mask. Each Physical segment unique network Id, all computer share the physical segment id
Class A B C [D E]

Class A 0 bit of the first octet, 0000001, ~ 1.0.0.0 , 11111110 ~ 127.0.0.0 < loop back address

33.0.0.0, all computer will be 33, then host id to individual computer
1.0.0.0 ~126.0.0.0
Host ID east remember the last three octets are reserved to host id
Each 256 address
Take Three Octets
256x256x256 ~ 16 million possible address, subtract -2 from it cannot be all 0 or 1

33.0.0.0 all computers start out with it
16 mill dif host Ids First 33.0.0.1 ….increment to 255, 33.0.1.0….increment 255, 33.255.255.254 16.7 mill address

Class B Binary 1.0


Class B 152.77.0.0 255.255.0.0 5000 hosts
Our job to set up addressing

Tuesday, September 11, 2007

OPS435 Week 2 Lecture 3

Week 2 Lecture 3 OPS435

The handout is the page tells you the 9 steps the shell tells, you interprets
3. ~
4. ‘ ‘ $()
5. $
6. * ? []
7. ‘ ‘ “ “ \
8. < > >>

Once you go through steps 1-8 the shell has interpreted the command and executes it 80% kernel, 20% shell, if its built in then its already in the shell, if its not a built in command the shell has to pass it on to the kernel before the kernel executes the command it has to copy it from the database to memory, the kernel does not know where it is in the database, that’s another function of the shell, it must tell the kernel where to it is in the database, How does it know….path variable

Lets say where doing the ls command, it must go into the $PATH variable and its going to go to the first variable and sees if its their and goes to the next and when it find it it passes the information to the kernel, then the kernel will go and copy the command or utility from the database to the shell and assign it a unique PID number, it will go back into memory and release the command then the kernel goes and nudges and shell and says its done and asks what do you want me to do next, to finish this one off we have a command
Mail –s “$host System Maintenance Warning!” ‘cat ~/userlist*’ < maint01

There are two commands, command substitution ‘ ‘, the car command will be executed before the mail command is executed

As soon as the command their it executes Token Splitting, then it looks inside the ‘ ‘ and find the tild which is 3, it will take the tild character and replace it with the home directory, then it goes to number 6 because of the star it is looking at the ‘cat ~/userlist*’ it will go into the home directory and look at any file starting with the name user list, userlist* will be replaced will all the files with the names matched, the cat command read the contents of the files, so the whole cat command will be replaced with the STDOUT of that command and will be replaced from ‘cat ~/userlist*’ this and will send the content of the directory of all the user names, so when this is done the shell will continue to 5 and down, so were looking at the $host and will replace the $host with matrix, 6 no, 7 quotes yes the quotes are their, the quotes will be removed, 8 I/O Redirection yes < STDIN which will open the file read the contents and pass the contents to the command, during step 8 it will open the FILE, all the interpretation is done when all of its done, in step 9, after step 9 it will pass it to the kernel, it will go to the path variable to find where the mail command is located, once its done the shell jobs is done and the kernel will take over from their.

> clears the file and prepares it for receiving data,

1,4(1,3,6,9) 5,7,8,9


Another example when the shell does not go through the path variable, 1 when the command is built in 2 the mail command, instead of the mail command you put in /bin/mail…will the shell go to the path variable…no because we have already specified where the path is so the shell does not have to find it because this is absolute addressing. The shell is about different characters, that is how you ask the shell to do things, if you don’t know the special characters you do not speak the shell’s language.



Covering a couple of commands you are going to need a number of commands for Lab 1, Lets start off with the sort command, sort command not a easy command, and is very complex if you make use of all the capabilities, lets go through the command, there are two different sort command the old and the new,
Sort sorts the contents of the file and puts them in an order, what order, it uses ASCII code for its default code for sorting everything you may use many option to change what it is to do, but remember its done automatically by ASCII code, both new and old work that way.
Capital A 101 comes before small a 141, Numbers come before Capitals

With the sort command you can specify, lets do this
sort f1
if you simply do this command will start sorting from what character, the first character, most files are split in fields, you can specify which field you want, it automatically goes to field one though,

The difference between old and new how you specify how u want to do this
The old is SKIP SORT the programmers that divised there is no other reason, the reason its called this, say you want to start on field number 2 instead of says start on field 2, the skip sort asks what field do you want to skip to start on so
Sort +1 f1
+ means skip 1 and this command will start on field 2

With the sort command you say start on this one and stop on this one, multiple fields of starting and stopping lets say you wanna start on field two and stop at four

Sort +1 -4 f1

Lets say you want to continue
Sort +1 -4 +5 -9
On 5 and stop at 9, what field are we going to do its ASCII
6 through 9 are numbers, if you wanan sort numerically you have to tell the command you have to use –n so if +5 -9 is only numeric you put the n here
Sort +1 -4d +5 -9n

The d is for dictionary field, that is basically how it works, now you can also specify….not important….how to start on a certain character field #5 and char #6 you can be very precise, you can look that up in your man pages if you wish. Particular char then a field, so that the skip sort command the new skip command is called key word sort the only difference is how to specify the fields you want to stop and start on, it keys exactly to the field you want to go to

Sort –k
As soon as k keyword sort command, so we want to do 2 4 so.,,
Sort –k2,4d –k6,9n

It is the same as
Sort +1 -4d +5 –9n

We are going to look at some other options on this command, the default delimiter is white space, tab and new line this is called white space,
Now what is the delimiter in the file /etc/passwd its semicolon, what if you want to sort in a file with semicolon so you have to have the option to change the delimiter
Sort –t: that will specify what type of delimiter it is.

Sort /etc/passwd

Sort –t: -k3n /etc/passwd
Or
Sort –t: +2n /etc/passwd

-f force case insensitive, don’t differentiate between upper case and lower case you use –f

-r sort in reverse

Lets try another command cut, what is the purpose, you can cut data from a file, you may cut portions for any particular purpose, so the cut command you specify what is it you want to cut

Cut f1

The type of data it was designed to used the default delimiter was a tab, it is not white space but a tab, so any time you use it you should know the default delimiter was a tab, if its not a tab you are going to have to change the delimiter what is the delimiter change for the cut command

Cut –d: f1

You cut either fields or characters with this command and the way you do this, there is another option in their which is cutting fields

Cut –d: -f3 f1

Three through 5
Cut –d: -f3-5 f1
Three through 5 & 7
Cut –d: -f3-5,7 f1
Range and the command says and this

Also –c characters you can cut characters so you can say
Cut –c10-20,25,28

And that’s the cut command, another command

Paste

One easy way to remember how it works, everyone knows how cat works
Cat 1 2
Its going to append the two together vertically, the paste command works similar, instead of vertically it appends them horizontally, its going to put a delimiter which is a tab between the two

Paste –d+ banana

Instead of the tab it will have plus signs.

Paste –s
Which means squeeze its going to take the whole file and squeeze all the files into one single line. Single file only.

Remember all the commands you are using it does not do anything to the file, the original data remains as it was.

Here we are going to try something, assign a variable age you year of birth in this format
YYYMMDD
$age = 19871223
Echo $age |cut –c1-4
1987
Echo “The year of my birth is $(echo $age | cut –c1-4)”
The year of my birth is 1987
Echo “The month of my birth is $(echo $age |cut –c5-6)”
The year of my birth is 12

The shell basics with commands, okay Chapter 3.
Login Files, when you log onto the system there are a couple of files that are automatically excuted when you log in the shell environment is predetermined by these three files
/etc/profile – this sets the environment for every user, same file to every user, which belongs to root, and super user can use this to set up the file for every user
Two other files
~/.bash_profile – the user is in charge of this, if you want to change your environment you would go into this file, if you want ur prompt to look different you can go into this file, if you want to create a new command you can put alias command and when you log in it will stay their.
~/.bashrc – this belongs to the user as well, and you can go to either one and make changes to you environment.

~/.bash_logout - when you log out , want something done when you log out u do this


Open up ~/.bash_profile
cat ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME=""

export USERNAME BASH_ENV PATH

PS1="\[\033[21;255;44m\u@\033[21;255;44m\h:\033[1;255;41m\w$\033[0m\] "
LS_OPTIONS='-N --color=tty -T 0'


Cd what does this command do, takes you to your come directory

Cd - - takes you back to where you were before
Pwd
Random – echo $RANDOM you get a random number, if using a program and you want to generate random numbers that is how your going to do it

Shell Built Commands are on the slides….

Special operators …first semi colon what does that mean to the shell?

Cd
echo
Cat
Sort

Writing a program so on every line lets say we want to do all the commands all the same way but we want it on one line
Cd ; echo; cat ; sort

; - command separator
& - used for

Sleep 10 – shell sleep for 10 seconds
Sleep 10 &
[5] 15962
Job #5 and is running in the background and gives you the environment to play with still, it will assign the job number and run in the background, if you hit the return it wills say job #1 is done.

The labs are normally due the date, but we going to do if u don’t finish on Friday up to next Friday.

DAT702 Week 2 Lecture Three

Week 2 Lecture Three

The lines connecting each table are relationships between each other, the connection allows you to put data in the corresponding field if data is in the first field, the constraint belongs to the foreign key table, one of the most important tools networking people will do is moving data. How many people have a Royal Bank account in Canada, about 6 million, you will be bringing data in bulk, we are going to be doing it in Access as well as MySQL, Access does not like a lot of tables opened up, which table are we going to use first, courses and students, grades must be last because of the constraints, the students file is tab delimited and is correct the very first line is the headings of the table, in MySQL you cannot have headings in the file,

Now we are going to open:
File/Import/students.txt

Defaults to Delimited, Tab, Click first row contains the field names, Text Qualifier =Always None, next then loaded

Two constraints which are the students and courses to the foreign key which is the grades table, data must be imported to the constraints then when the constraints are loaded you are able to load data into the grades table. Remember the Constraints to the foreign key. Appropriately

In Access go to Query/ Right Click screen SQLView type

SELECT *
FROM students;

OPS335 Week 2 Second Lecture

OPS335
Second Lecture

Today we are going to be talking about Disks, 1956 IBM made the first disk which was 5mb, about 50 years ago, and cost about $50, 000, contrast this from 2007 called the Desk Star 1000, 1TB - $500, there is new way to give 50% more capacity, as technology progresses everything gets cheaper. Disks, we use them for Non- Volatile Storage, information is saved when your computer is turned off, that is one of the systems storage, your memory is Volatile, what ever is in RAM is gone, but in you hard drive the data will still be their, we use this type of storage to store programs, video clips, photographs. Now you can purchase, NAS, Network Attached Storage, you can buy them now at Tiger Direct or Future Shop, it plugs into your Ethernet. You can store stuff on it, drives may go away in the future because of chip memory, hard drives are mechanical with moving parts the disk is rotating, chip memory will probably be faster in the future, you may buy memory cards for you camera this is an example of chips out doing Disks. A picture of a disk…we can write on the top and read at the bottom we have 8 surfaces we can do our reading and writing, in the example of the cylinders the tracks are concentric tracks its circles into circles, if you take a look at one particular track and ask yourself how much data the track can hold and multiply the track by 8, it will give you the capacity of the cylinder, the cylinder is the sum of the tracks in one sweep through the surfaces of the platters, so you have a sector here which is the smallest part of the track, a sector is typically 512 bytes, if you have a file it will be written into a whole sector the system cannot read more then a sector at a time, they cannot read one byte but a sector at a time, these are all of the attributes of a hard drive,

Disks

Looking at the zones of the drives, the top platter, you have 5 different zones, every zone the number of sectors, you can count the sectors and in our example its 9 sectors, as you get closer to the centre its harder to squeeze in data, as it branches out form the centre you can have more tracks, in the early days a disk only had one zone,

Disks

C=T*H*S*Z
The formula Computing Disk Capacity
C is the capacity size of the drive measured in bytes
T is the number of tracks on one recordable surface
S is the number of sectors per track
H is the number read/write heads (usually the same surfaces)
Z is the size of one sector usually 512 bytes

For pcs a sector is 512 bytes, lets take an example we have a disk with one platter, if it has one platter it has two surfaces, so it has 2 sets of r/w heads, we have 18 sectors /tracks and 80 tracks and 512 bytes per sector
H=1 platter * 2
S=18 sectors/track
T =80 tracks bytes /sectord
Z = 512 bytes/sector

Echo 2 *80*18*512
1474560 bytes
Divide by 1024 we get 1440Kb = 1.44mb this is like a floppy this formula works for every single hard drive unless you have a hard drive with multiple zones, then you have to work out the capacity for each zone, if you have six zones on the hard drive you have to do the complication 6 times and write it down, 1024 bytes is one kilobyte, kilo, mega, gig, tera peta, exa, zeda, remember we only 10^88 electrons in the universe, those are the standards, take a look at the example he did, he wants to know what is the capacity of one cylinder,
The capacity of one cylinder,
1440kb =1.44mb
Capacity= 2*18*80*512
=1474569bytes
=1024

1474569/80x2 -this is one cylinder
36864 bytes

Cylinder, we have two plates, if you have 2 plates you have four surfaces, the track 0, 1 platter is two surfaces, the cylinder will be the first track and the track under it.

Cylinder Y= H*S*Z
=2*18*512
=18432 bytes 1 cylinder
Size of one Track divide by 2
T=9216 bytes

Why is it important to know what a cylinder, because when we partition a hard drive we have to partition a hard drive, every partition you make has to be an even number of cylinder, so the smallest partition you can make is one cylinder, Linux on the other hand cylinder/track/sectors/heads does not really care that much,
fdisk –l shows the partition table,
dd if=/dev/sda of=mymbr bs=512 count=1
copy from to
file – what kind of file is your mbr
with fdisk with p it will show you the partition, if you want to delete d of partition number 2 and p will print and you will not longer have a partition 2.


Capacity = 64* 32*17547*512
18399936
C= 128*16*17547*512

E-mails are sent a week before
What is in /boot:
/boot – kernel ram disk file, grub file.