23 Mar 2013

10 Mar 2013

TCP vs UDP



TCP
UDP
Acronym for:
Transmission Control Protocol
User Datagram Protocol or Universal Datagram Protocol
Function:
As a message makes its way across the internet from one computer to another. This is connection based.
UDP is also a protocol used in message transport or transfer. This is not connection based which means that one program can send a load of packets to another and that would be the end of the relationship.
Usage:
TCP is used in case of non-time critical applications.
UDP is used for games or applications that require fast transmission of data. UDP's stateless nature is also useful for servers that answer small queries from huge numbers of clients.
Examples:
HTTP, HTTPs, FTP, SMTP Telnet etc...
DNS, DHCP, TFTP, SNMP, RIP, VOIP etc...
Ordering of data packets:
TCP rearranges data packets in the order specified.
UDP has no inherent order as all packets are independent of each other. If ordering is required, it has to be managed by the application layer.
Speed of transfer:
The speed for TCP is slower than UDP.
UDP is faster because there is no error-checking for packets.
Reliability:
There is absolute guarantee that the data transferred remains intact and arrives in the same order in which it was sent.
There is no guarantee that the messages or packets sent would reach at all.
Header Size:
TCP header size is 20 bytes
UDP Header size is 8 bytes.
Common Header Fields:
Source port, Destination port, Check Sum
Source port, Destination port, Check Sum
Streaming of data:
Data is read as a byte stream, no distinguishing indications are transmitted to signal message (segment) boundaries.
Packets are sent individually and are checked for integrity only if they arrive. Packets have definite boundaries which are honored upon receipt, meaning a read operation at the receiver socket will yield an entire message as it was originally sent.
Weight:
TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control.
UDP is lightweight. There is no ordering of messages, no tracking connections, etc. It is a small transport layer designed on top of IP.
Data Flow Control:
TCP does Flow Control. TCP requires three packets to set up a socket connection, before any user data can be sent. TCP handles reliability and congestion control.
UDP does not have an option for flow control
Error Checking:
TCP does error checking
UDP does error checking, but no recovery options.
Fields:
1. Sequence Number, 2. AcK number, 3. Data offset, 4. Reserved, 5. Control bit, 6. Window, 7. Urgent Pointer 8. Options, 9. Padding, 10. Check Sum, 11. Source port, 12. Destination port
1. Length, 2. Source port, 3. Destination port, 4. Check Sum
Acknowledgement:
Acknowledgement segments
No Acknowledgment

8 Mar 2013

POP and OOPS


Procedure  oriented programming  (POP)
Object oriented programming (OOP)
POP emphasis on algorithms (procedure)
OOP emphasis on data rather
 than procedure.
Large programs are divided into smaller programs known as functions.
Programs are divided into objects.
They have not facility to hide data.
They have facility to hide data from
outside world.
Function can transfer data from one function to another and one form to another form.
Objects can communication with
each other using functions.
It does not have powerful features like operator overloading, inheritance etc.
It contains powerful features
 like operator overloading, inheritance.
For design program it uses top-down approach.
For design program it uses bottom-up
approach.
Examples: C, COBOL, FORTRAN etc.
Examples: C++, java




Application of OOP
o      Following are the applications for object oriented language.
o      Real time systems
o      Simulation and modeling
o      Object oriented database
o      Hypertext, hypermedia and expertext
o      AI and expert systems
o      Neural network and parallel programming
o      Decision support system
o      Office automation system
o      CIM / CAM / CAD systems


Benefits of OOP
o      Following are the benefits of object oriented programming language.
o      User can create new data type or users define data type by making class.
o      Code can be reuse by using inheritance.
o      Data can be hiding from outside world by using encapsulation.
o      Operators or functions can be overloaded by using polymorphism, so same functions or operators can be used for multitasking.
o      Object oriented system can be easily upgrade from small system to large system.
o      It is easy to partition work for same project.
o      Message passing techniques make communication easier.
o      Software complexcity can be easily managed.
o      Maintenances cost is less.
o      Simple to implement.

Message Passing:
o      Objects can communicate with each others by passing message same as people passing message with each other.
o      Objects can send or receive message or information.
o      Message passing involves name of object, name of function (message) and information to be send.
o      For example, student.mark(name). Here student is object, mark is message, name is information.


  Dynamic binding:
o      Binding means link between procedure call and code to be execute.
o      Dynamic binding means link exist between procedure call and code to be execute at run time when that procedure is call.
o      It is also known late binding.
o      It is generally use with polymorphism and inheritance.
o      For example, complier comes to know at runtime that which function of sum will be call either with two arguments or with three arguments.

  Polymorphism:
o      Polymorphism is a Greek term which means ability to take more than one form.
o      For example, + is used to make sum of two numbers as well as it is used to combine two strings.
o      This is known as operator overloading because same operator may behave differently on different instances.
o      Same way functions can be overloaded. For example, sum () function may takes two arguments or three arguments etc. i.e. sum (5, 7) or sum (4, 6, 8).


   Inheritance OR Derivation:
o      The mechanism of deriving a new class from an old class is called inheritance or derivation. The old class is known as base class while new class is known as derived class or sub class.
o      The inheritance is the most powerful features of OOP.




Data Abstraction:
o      Abstraction refers representation of necessary features without including more details or explanations.
o      Classes use the concept of abstraction.
o      Classes define list of abstract attributes like height, weight etc.
o      These attributes are sometimes called data members because they hold information. The functions that operate on these data are sometimes called methods or member functions.
o      Since classes use the concept of data abstraction, they are known as Abstract Data Types (ADT).


Encapsulation:
o      Combine data and functions into a single unit (called class) known as encapsulation.
o      Encapsulation is most important features of class. By which we can combine data and functions in one unit.
o      Using encapsulation we can hide data from outside world.
o      To hide data from direct access by program is known as data hiding or information hiding.

Classes:
o      Classes are user defined data types and it behaves like built in types of programming language.


o      Object contains code and data which can be made user define type using class.


o      Objects are variables of class.


o      Once a class has been defined we can create any number of objects for that class. A class is collections of objects of similar type.


o      We can create object of class using following syntax,


Syntax:   class-name object-name;


o      Here class name is class which is already created. Object name is any user define name. For example, if student is class,


Example: student s1, s2;


o      In example s1 and s2 are name of objects for class student. We can create any number of objects for class.


OBJECT: 
o     Objects are basic runtime entity in object oriented system. 
o      Objects may be a pen, a person, a table etc.
o      Objects may define user define data types like time, vectors etc.
o      Programming problems analyzed in terms of objects.
o      Object should be chosen such that they match closely with real world objects.
o      Objects required memory space for storage just like structure of ‘C’ language.
o      One object can send message to another objects.
o      For example student and record are two objects and student object may send request to record object for marks, then record object send marks for particular student.
o      Object can interact with each other without having knowledge about data and code of each other’s.



Science, Engineering and Technology

Science, Engineering, and Technology
What is the difference between science, engineering, and technology? How do they interrelate? Here are a few simple ways to distinguish between and relate these fields. 
Science:
  • A body of knowledge
  • Seeks to describe and understand the natural world and its physical properties
  • Scientific knowledge can be used to make predictions
  • Science uses a process--the scientific method--to generate knowledge
Engineering:
  • Design under constraint
  • Seeks solutions for societal problems and needs
  • Aims to produce the best solution given resources and constraints
  • Engineering uses a process--the engineering design process--to produce solutions and technologies
Technology:
  • The body of knowledge, systems, processes, and artifacts that result from engineering
  • Almost everything made by humans to solve a need or fulfill a want/desire is a technology
  • Examples of technology include pencils, shoes, cell phones, and processes to treat water
In the real world, these disciplines are closely connected. Scientists often use technologies created by engineers to conduct their research. In turn, engineers often use knowledge developed by scientists to inform the design of the technologies they create.
Science, engineering, and technology are all situated in the context of a larger society that determines what science and engineering get done. Human values, needs, and problems determine in large part what questions scientists investigate and what problems engineers tackle. In turn, the technological products of science and engineering influence society and change human culture.


What is the Difference Between Engineering and Engineering Technology?
Engineering
Engineering Technology
Innovation
Implementation
Concept-oriented
Application-oriented
Theory
Methods
Advanced Math
Basic Math
Develop a new process
Apply a new process
Open-ended and futuristic
Specific and current
Registration as P.E. in all states
Registration as P.E. in Oklahoma and most states
Can require period of internship due to emphasis on fundamentals and theory
Usually ready to work due to emphasis on current practice in industry
Graduate studies widely available
Graduate study very limited


Difference Between a Computer Science & Information Technology Degree

Computers and technology have become a part of daily life and a necessity for any business or company to function. Careers in this field are in very high demand and have a very promising future. The Bureau of Labor Statistics foresees that there will be a growth of at least 18 percent in this field. Individuals looking to obtain a degree in this area are headed to a promising future with an endless amount of possibilities. The variety of options begins with the types of degrees available. The two degree names that we encounter most often are Computer Science and Information Technology. Prospective students in this field should be informed about the differences so that they can choose the program that best fits them.
Computer Science Degrees
Computer Science is the scientific and mathematics study of computing machines and processes. The first degrees in this area of technology are in Computer Science. The study of computer science can range from the theoretical studies of algorithms to the practical issues that come with the use of computing systems. Studies in computer science usually focus on software design and creation, computational theory, computer design, and involve a great deal of mathematics.
Information Technology Degree
Information technology is a branch of engineering that deals with using computers and telecommunications to send, receive, and store information. This is a fairly new field that has developed with an astonishing pace over the past years given that companies now rely heavily on information technology to function. Studies in Information technology focus on system analysis, software management and networking, information assurance, and informatics. Programs in this area train students to manage networks efficiently.

C Tutorial 2

                                              Tutorial-2

In this tutorial, we are going to learn about variables,different data-types and other related stuff.

What are data-types?
In C-programing, a data can be represented in different formats.
an example might be as follows, in mathematics, 12 and 12.0 are same, however in computer science, the memory required by 12 and 12.0 is different.
The number of bits required to store an integer is not the same as the number of bits stored by a floating point value(decimal point value).
So the question arises how to tell the compiler to allocate the memory for different types of data?
The answer to this is by telling the complier the data-type of the value or data which is the type of the data.
C language data types can be classified as
 

·         Primary data type
·         Derived data type
·         User-defined data type
Concept of : signed,unsigned,short and long.
This is pretty simple as signed data-type means that it will cover the positive and the negative values as well.
Unsigned data-type will cover only the positive values starting from 0.
short datatype will allocate either same or less than the main type of the data and definitely lesser memory as compared to long-datatype of the same.
short int <= int <= long int
float <= double <= long double




Type 
Size (Bits)   
Range 
Char or Signed Char
8
-128 to 127
Unsigned Char
8
0 to 255
Int or Signed Int
16
-32768 to 32767
Signed Int
16
0 to 65535
Short Int or Signed int
8
-128 to 127
Unsigned short int
8
0 to 255
Long int or signed long int
32
-2147483648 to 2147483647
Unsigned long int
32
0 to 4294967295
Float
32
3.4 e-38 to 3.4 e+38
Double
64
1.7e-308 to 1.7e+308
Long Double
80
3.4 e-4932 to 3.4 e+4932

The above values are for a 16-bit machine.

We shall discuss derived data-types and user-defined data-types in their dedicated tutorials.
As of know, knowing just the simple data types is more than enough.

What are
 variables?
Variables in computer science is something that symbolizes the known or unknown data.
Variable names are independent of the data-type of the variable.
Variables can be changed in the course of execution under proper conditions.
Variable names are nothing but temperory names given to some part of memory.

Now we are in a position to write our first program which involves usage of variables.
In this program, we are going to add two numbers and store them in a variable and display this variable.

Code:
/*Author : ks*/
#include
#include

int main(int argc,char*argv[])
{
    int number1=5;
    int number2=10;
   
    int answer=number1+number2;//Add the two numbers
    printf("The answer is %d\n",answer);
    system("PAUSE");
    return 0;
}
In the above code,number1,number2,answers are called as variables.
int number1=5, this tells the compiler that the variable number1 is going to contain an integer,so allocate memory required to store an integer.
same is with number 2 and answer.
Take a look at the statement 'printf("The answer is %d\n",answer);'
 
As stated in tutorial-1, printf() takes the format specifier, "%d" is used when we expect to print an integer value.

Here is a list of format specifiers:

%c
The character format specifier
%d
The integer format specifier.
%i
The integer format specifier (same as %d).
%f
The floating-point format specifier.
%e
The scientific notation format specifier.
%E
The scientific notation format specifier.
%g
Uses %f or %e, whichever result is shorter.
%G
Uses %f or %E, whichever result is shorter.
%o
The unsigned octal format specifier.
%s
The string format specifier.
%u
The unsigned integer format specifier.
%x
The unsigned hexadecimal format specifier.
%X
The unsigned hexadecimal format specifier.
%p
Displays the corresponding argument that is a pointer.
%n
Records the number of characters written so far.
%%
Outputs a percent sign. 

try it out yourself.

Next to format specifier, you shall find "\n". This is called as an escape sequence.
An escape sequence is combination of a backslash '\' and a letter. Its taken as one single character.

The following is a list of commonly used escape sequences.
 
\n
Newline 
\t
Horizontal Tab
\v
Vertical Tab 
\b
Backspace 
\r
Carriage Return 
\f
Form feed 
\a
Audible Alert (bell)
\\
Backslash
\?
Question mark
\’
Single quote 
\”
Double quote 



Exercise:
 
Write program to subtract,multiply and divide(this is slightly tricky, grasp the knowledge of data-types first).
Write program to find average of two numbers.
Write many simple programs till the time,either you are bored or you get proper hang of the syntax.;)
Play with different data-types and escape sequences.
****************************************************











































































































Support From Kuldeep Sheoran