Sunday, March 16, 2008

Chapter 3 - Data Transmission

Data is transmitted through some transmission medium (substance that allows the traveling of waves) between the transmitter and the receiver.

Transmitter - the origin of the signal
Receiver - the destination of the signal

Guided media - physical path for data to be transmitted over. The data are guided to its destination. Example - twisted pair or coaxial cable
Unguided media - wireless. The data are not guided. Example - air or water

Absolute bandwidth is the range of frequencies (max freq. - min. freq) of the signal or communication channel(medium). Since absolute bandwidth of many signals tends to be infinite, relative bandwidth is used most of the time. Relative bandwidth or effective bandwidth is the amount of bandwidth required to represent the majority of the energy in the signal. When bandwidth is mentioned, it is usually meant as the relative bandwidth. The unit for bandwidth is Hertz (Hz).

Two forms of transmission: Analog vs Digital Transmission
Analog transmission is a way of transmitting any data, analog or digital, through an analog signal.
Modem - (modulator demodulator) is used to encode digital data into an analog signal. It is used in analog transmission.
Analog signals will loser its power(attenuation) as it travels farther.

Digital transmission is a way of transmitting data through a digital signal.
Codec - (coder decoder) is used to encode analog data into a digital signal or digital data into analog signal. It is used in digital transmission.
Digital signals will usually be in a sequence of zeros and ones. The digital signal will also be affected by attenuation.


Channel Capacity - maximum rate for data transmission over a specified communication channel. It is the ideal value for the data rate and it is unattainable. Data rate is the amount of data that is transmitted over a certain time. It is measured in bits per seconds(bps).

Shannon Capacity - used when theoretical max data rate of channel is desired.

  • C = B log_2(1+SNR)
  • C - channel capacity/data rate (bps)
  • B - bandwidth of signal (Hz)
  • SNR - Signal to noise ratio. Can be found by dividing noise's power by the signal's power
  • Signal and noise must be in the units Watts (W) in this formula. Sometimes, they are given in decibels so they will need to be converted.

Nyquist Bandwidth - used when max data rate of channel is desired or when noise is not a factor and signaling levels are.
  • R = 2B log_2(M)
  • R - data rate/ channel capacity (bps). Sometimes R is replaced with C.
  • B - bandwidth of signal (Hz).
  • M - amount of signaling levels or symbols. Example: binary signaling will have M = 2 since there will be 2 possible signaling levels, 0 and 1.


The information above is based on the textbook Data and Computer Communications by William Stallings.

Sunday, March 9, 2008

Computer Architecture: Measuring Computer Performance

Performance can be measured in many different ways depending on what you're looking for. One primary attribute of computer performance is its execution time. Execution time is the total amount of time needed to perform a task. Lower execution time means better performance so performance and execution time are inversely related.

  • Performance = 1/Execution time
When comparing performances between two computers, if A is n times faster than B it means
  • n = Performance(A)/Performance(B) = Execution Time(B)/Execution Time(A)

The execution time takes into account every time factor that a program encounters, like user inputs and outputs. A more focused way to measure performance is CPU time. CPU time is the amount of time the CPU actually works on the task.

  • CPU time = Total instructions * (average clock cycles per instruction) * clock cycle time
Every program generates instructions for the computer to carry out. Each instruction takes a certain amount of time to do. In a computer, time is referred to as clock cycles or period. They are based on the clock of the computer. Clock cycle is inversely related to its clock period. In the above equation, clock cycle time is just the clock period.

Amdahl's Law
When you improve only a part of a computer's performance, you need to use a different equation to calculate the CPU time.
  • CPU time_after = [(CPU time_before)/amount of improvement + Unchanged CPU time]
Another way to put this equation is:
  • 1 / [(1-P) + (P/S)] where P is the proportion that improved(0 < P < 1) and S is the speedup.


The information above is based on the textbook Computer Organization and Design by David A. Patterson and Hennessy.

Saturday, March 1, 2008

C Programming Part 2: Data Types, Variables, and Constants

How are data stored in C?

  • Data are stored as variables or constants.
  • Variables are just memory locations that hold specified values/data.
  • Variables and constants are assigned a data type during creation.
  • Data types limit the possible values the variable/constant can have.
  • There are data type modifiers which will further limit or increase the range of values.
  • The modifiers are short, long, signed, and unsigned. They are placed before the data type.
  • Examples: short int, unsigned char, long float.
  • Some data type modifiers can also be used as data types. They just act like int.

C Data Types
TypeDescriptionBitsRange
charcharacters8-128 to 127
unsigned charsmall unsigned int80 to 255
intintegers32-2,147,483,648 to +2,147,483,647
unsigned intunsigned integers320 to 4,294,467,295
shortsmall integers16-32,768 to 32,767
unsigned shortunsigned small integers160 to 65,535
longintegers32-2,147,483,648 to +2,147,483,647
unsigned longunsigned integers320 to 4,294,467,295
floatfloating point #s32
doublefloating point #s (greater precision)64
long doublefloating point #s (even greater precision)96


Variables

  • The format of declaring a variable is: data_type variable_name; (i.e. int one;)
  • The first character of a variable name MUST be a letter but the rest can be a letters, numbers or underscores(_) .
  • Variables are case sensitive.
  • The maximum length of the name will depend on the compiler. Although, there is a C standard that states that the initial 63 characters are significant for an internal identifier (name used for variables, types, or labels). The standard for an external identifier is that the first 31 characters are significant.
  • It is a good practice to initialize (assign it a base value) a variable when you first declare it. It is known as defining a variable when you do both the initialization and declaration. The main small difference between the two is that defining it means that memory space is taken up. In a declaration, no memory is used and only the data type is mentioned.
  • Ex. Declaration: int one; | Definition: int one = 1;
  • Variables are considered local, global, or external depending on where they are defined and used. This will be discussed more in a later section.
  • It is possible to declare all variables on one line (i.e. int one, two, three;). Generally, it is a better practice to declare or define them on separate lines.
Constants
  • Constants are data that will not be modified.
  • Constants are generally defined near the very top of the code and its name is all capitalized.
  • They do not take up any variable storage space(memory).
  • The format for defining a constant is: #define CONSTANT_NAME constant_value
  • Constants can be assigned decimal, octal(put a 0 before the value; i.e. 0742), or hexadecimal(put a 0x before the value; i.e. 0xA2) values.
  • To assign a data type(long or float) to a constant, put a L or F after the constant value.
  • Ex. #define PI 3.14F
Special Constants
  • Another type of constant is an enumeration constant. It is created in this format: enum enumeration_type {constant_name1, constant_name2,...}
  • The first constant in a enumeration will be given the value 0 unless otherwise specified. The second constant will have the value of the previous constant plus one. Thus the second constant will be given the value 1 unless it or the constant before was assigned a specific value. This procedure continues on for the rest of the constants in the enumeration.
  • Ex. enum boolean {FALSE, TRUE, MAYBE=5, NO}; FALSE will have a value of 0 and TRUE will have a value of 1. MAYBE will have a value of 5 and NO will have a value of 6.
  • Constants can also be a character(using ''), or a string("").
  • Some character constants can act as escape sequences(used to represent action or other characters that can't be represented normally).

Escape Sequences
SequenceDescription
\aAlert
\bBackspace
\fFormfeed
\nNewline
\rCarriage return
\tHorizontal tab
\vVertical tab
\\Backslash
\?Question mark
\'Single quote
\"Double quote
\0Null (automatically at end of string)
\oooASCII char. in octal
\xhhASCII char. in hex

Sunday, February 24, 2008

C Programming Part 1

Basic computer programming things to know:
C is a low-level computer programming language that is mainly used for system programming.

compiler - a program that converts source code (the code a person creates) into object code (the code a computer understands).

linker - a program that combines object code with other object codes or libraries to create an executable program.

Go here and download MS Visual C++ 2008 Express Edition to obtain a C compiler for Windows. There are many other compilers out there that will also work.

Here is a compiler for the Linux OS.

Use notepad, vi or any other simple text editor (if you use MS Word, make sure to save as a text file) to create your source code.

You will be using the Windows command line (from Visual Studio 2008 Command Prompt) or the Linux terminal window to compile and run your codes.

Here is a list of commands for the MS Visual 2008 C++ command line:(the outside quotation marks are not part of the command)

MS Visual 2008 C++ Command Line
CommandsDescription
cd dir_namechanges directory to dir_name (cd \ brings you to root folder)
mkdir dir_namecreates a directory with the name dir_name
dirlists everything in directory
clsclears screen
notepad file_name.copens file_name.c in notepad (if file doesn't exist, it will create one)
type file_name.cshows you the content of file_name.c
cl file_name.ccompiles and links file_name.c
file_nameruns the file file_name.exe
move file_name dir_name
moves the file, file_name, into the directory dir_name
del file_name
deletes the file file_name
(Hold Ctrl and C)breaks out of the program (useful when stuck in an infinite loop)


Here is a list of commands for the Linux terminal window:
Linux Terminal Window Commands
CommandsDescription
cd dir_namechanges directory to dir_name (cd \ brings you to root folder)
mkdir dir_namecreates a directory with the name dir_name
dirlists every file in directory
vi file_name.copens file_name.c in vi editor (if file doesn't exist, it will create one)
:w (vi editor command)saves the file
:q (vi editor command)quits the vi editor
cat file_name.cshows you the content of file_name.c
cc -o name file_name.ccompiles file_name.c and creates an output file called name
./nameruns the file called name


Basic C Program, Hello World:

#include <"stdio.h"> // Quotation marks are not supposed to be in this line of code.
main()
{
printf("hello world\n");
}

The simple code above will show the text hello world.

  • The #include <"stdio.h"> (no quotation in real code - blogger problem) is used to add the standard input/output library (a library is just preprogrammed keywords/commands) to the code.
  • The // indicates a comment. Anything to the right of the // is not considered part of the code.
  • Every C file must include a main() {}. It is called the main function and it is the first place the computer looks at when running the code.
  • The printf is just a function that displays whatever is provided inside the parenthesis.
  • The quotation marks inside the parenthesis indicates that hello world is a string (ordered sequence of characters).
  • The \n indicates that a new line is to be created next.
  • The ; indicates the end of the statement.

Saturday, February 23, 2008

Chapter 5 - Signal Encoding Techniques Part 2

5.2/ Digital Data, Analog Signals
A modem (modulator-demodulator) is used to modulate, encode, digital data into an analog signal and vice versa.

Basic techniques to convert digital data into analog signals:

  1. ASK (Amplitude Shift Keying) - represents digital data as different amplitudes in a carrier signal. For a binary data, zero amplitude can represent a binary 0 and another amplitude will represent a binary 1.
  2. FSK (Frequency Shift Keying) - represents digital data as different frequencies in a carrier wave. BFSK is binary FSK.
  3. PSK (Phase Shift Keying) - represents digital data as different phases in a carrier signal. BPSK is binary PSK.
5.3/ Analog Data, Digital Signals
digitization - conversion of analog to digital.
A codec (coder-decoder) is a device used to digitize (encode) or decode data.

Basic techniques to convert analog data into digital signals:
  1. PCM (Pulse Code Modulation) - the sampling of analog data at a minimum rate (twice the frequency) and the conversion of the samples to a digital (usually binary) code.
  2. DM (Delta Modulation) - the differential of the sampling of analog data is converted to a digital code.

5.4/Analog Data, Analog Signals

Basic techniques to convert analog data into analog signals:
  1. AM (Amplitude Modulation) - involves modification of the amplitude of the transmitted signal to represent data.
  2. PM (Phase Modulation) - involves using the phase to represent data.
  3. FM (Frequency Modulation) - involves modification of the frequency of the transmitted signal to represent data.

The information above is based on the textbook Data and Computer Communications by William Stallings.

Friday, February 22, 2008

Chapter 5 - Signal Encoding Techniques

Modulation - process of encoding source data onto a carrier signal in order to transmit data. Modulation techniques require variation to either the amplitude, frequency, or phase.

Carrier Signal - aka carrier wave or carrier, is a continuous and single-frequency signal that is able to be modulated with another data signal to transmit data.


Analog - Continuous. Ex - sinusoid.
Digital - Discrete and discontinuous. Series or sequence. Uses specific constant values, like 1 and 0. Ex - square wave.

4 Possible Encoding Combinations:

  1. Digital data to digital signal
  2. Analog data to digital signal
  3. Digital data to analog signal
  4. Analog data to analog signal

5.1/ Digital Data, Digital Signals
Data is the information, usually a binary one or zero, one wants to transmit. Each data element is a bit. Signal is the way that the data is transmitted. Signal is any quantity that can be changed over time or space. In electronics, voltage or current can be a signal.

A digital signal will be a series of discrete voltage fluctuations or pulses. The pulses are known as signal elements or symbols. A digital symbol is a pulse with constant amplitude. An analog symbol is a pulse with constant frequency, phase, and amplitude. Data can be transmitted by encoding data bits into symbols.

Unipolar - A signal is unipolar when all signal elements are either all positive or all negative.
Polar - Positive and negative values are both used in signal.

Bit - Binary data; zero or one.
Data rate - aka data signaling rate or bit rate, is the amount of bits that are transmitted per second. (Unit is bits/second)
The inverse (1/data rate) of the data rate is the amount of time it takes for one bit to be transmitted.

Modulation rate - the rate at which a carrier signal changes. (Units - baud or symbols/second)

Digital Signal Encoding Formats
  1. NRZ-L (Nonreturn to Zero-Level)
    • 0 = high, 1 = low

  2. NRZI (Nonreturn to Zero Inverted)
    • 0 = no transition at beginning of bit, 1 = transition at beginning of bit

  3. Bipolar AMI (no net DC component)
    • 0 = no signal, 1 = positive or negative, with alternation for successive bits

  4. Pseudoternary (opposite of Bipolar AMI)
    • 0 = positive or negative, with alternation for successive bits , 1 = no signal

  5. Manchester
    • 0 = high to low transition in middle of bit, 1 = low to high transition in middle of bit

  6. Differential Manchester (A transition will always occur in middle of bit)
    • 0 = transition at beginning of bit, 1 = no transition at beginning of bit



Factors that affect the receiving end of the signal:
  1. SNR (signal-to-noise ratio) - Inversely related to bit error rate.
  2. Data Rate - Directly related to BER (bit error rate).
  3. Bandwidth - Directly related to data rate.
Bit error rate - aka bit error ratio, is the ratio of incorrect bits to the total number of bits.

Methods to compare encoding techniques:
  1. Signal spectrum
    • less high-frequency components
    • no DC (direct-current) components
    • transmitted power mostly in middle of bandwidth instead of ends

  2. Clocking
    • connection synchronization (determining beginning and end of bits)

  3. Error detection
    • speed

  4. Signal interference and noise immunity
    • expressed in BER

  5. Cost and complexity
    • low cost for high availability


The information above is based on the textbook Data and Computer Communications by William Stallings.