fcpc notesl

339
Fundamentals of Computer and Programming in C (CSE -101 F) Prepared By: Ms.Aanchal Aggarwal [email protected] A.P in CSE department CSE/IT 1/338

Upload: himanshu-sukheja

Post on 06-Nov-2015

218 views

Category:

Documents


0 download

DESCRIPTION

bye bye

TRANSCRIPT

  • Fundamentals of Computer and Programming in C (CSE -101 F)

    Prepared By:Ms.Aanchal [email protected] in CSE departmentCSE/IT*/338

    CSE/IT

  • SyllabusCSE-101-F Fundamentals of Computers & Programming in C

    Section AAn Overview of Computer System and Operating Systems:Fundamentals :- Evaluation of computers, Hardware organization of a computer, Introduction to microprocessor, generations of microprocessors, Commonly used CPUs, Input/Output devices, Input/Output ports and connectors.Operating System Basics: Introduction to Operating system, Functions of an Operating Systems,Classification of Operating Systems, Basic introduction to DOS, UNIX/LINUX OS, Windows XP.Section BBasic Introduction to System Software and Programs:-Machine Language, Assembly Languages, Low level languages, High level Languages, Types of high level languages, Compiler, Interpreter, Assembler, Loader, Linker, Relationship between Compiler, Interpreter, Loader and Linker.Basic Introduction to Computer Networks :-Data Communication, modulation, Network devices, LAN, LAN topologies, WAN, OSI Reference model, Introduction to Internet and protocols : TCP/IP Reference model, Backbone network, Network connecting devices, Hypertext documents, HTTP, DNS, Network Security.

    CSE/IT*/338

    CSE/IT

  • SyllabusSection CAn Overview of C:Constants, Variables and Data types, operators and Expressions, managing I/O operations, Decision Making and branching, Decision Making and looping, Arrays, Character Arrays and Strings, User Defined Functions.Structure and Union in C :Defining structure, declaring variables, Accessing structure members, structure initialization, copying and comparing structures variables, operations on individual members, Array of structure, structure with structure,unions, size of structure. Section DPointers in C :Introduction, Understanding Pointers, Accessing the address of a variable, Declaring Pointer Variables, Initialization of Pointer Variables, Accessing a variable through its pointer, Chain of Pointers, Pointer Expressions, Pointer Increments and Scale Factors, pointers and Arrays, Pointer and Character Strings, Arrays of Pointers, Pointers as Function Arguments, Functions Returning Pointers, Pointers to Functions.Dynamic Memory Allocation and File Management in C :-Introduction, Dynamic memory allocation, allocating a block of memory: Malloc, allocating multiple blocks ofmemory: Calloc. Releasing the used space: Free, Altering the size of block: Realloc, Defining and opening file, closing file, I/O operation on files, error handling during I/O operations, Random Access to files and command line arguments.

    CSE/IT*/338

    CSE/IT

  • Assessment CriteriaTotal : 150 MarksTheory Exam : 100 MarksMarks of Class Work:50Sessional :15 MarksPre-University :15 MarksAttendance :10 MarksClass Performance :10 MarksCSE/IT*/338

    CSE/IT

  • BackgroundBasics of computerKnowledge of operating systemsKnowledge of programming languagesKnowledge of compilers and interpretersCSE/IT*/338

    CSE/IT

  • ReferencesFundamental of Computers and Programing with C, by A. K. Sharma, Dhanpat Rai Publications, New Delhi. Fundamental of Information Technology, by A.Leon & M.Leon.Computer Networks ,4th Edition, by Andrew S. Tanenbaum Programming in C, by Lipschutz, SCHAUM SERIES OUTLINES

    CSE/IT*/338

    CSE/IT

  • Guidelines and Instructions for studentsExaminer will set 9 questions in total.Two questions from each section and one question covering all sections which will be Q.1.Q.1 is compulsory and of short answer type. Each question carries equal mark (20 marks).Students have to attempt 5 questions in total.75% Attendance is compulsory.Within the semester 3 Assignments and 11 Tutorials would be given.

    CSE/IT*/338

    CSE/IT

  • Assignments Assignment 1:Explain constants,variable and data types in cExplain User Defined Functions.Differentiate between Structures and unionAssignment 2:What are Pointers.Explain with exampleExplain the use of malloc(),calloc(),realloc()Explain Command line arguments

    CSE/IT*/338

    CSE/IT

  • Tutorial-1Q1.C is a middle level language. Comment on it.Q2.What are the different operators available in C.Q3.Explain the syntax of IF, IF-ELSE, Construct in detail.Q4.Explain the syntax of switch case with example.

    CSE/IT*/338

    CSE/IT

  • Tutorial-2Q1.Explain the different loops available in c with an example.Q2.Explain user defined function with an example.Q3.Difference between call by value and call by reference.Q4.Explain the different inbuilt functions available in c.

    CSE/IT*/338

    CSE/IT

  • Tutorial-3Q1.Explain pointers with Character string.Q2.Explain pointer to function.Q3. What is the O/P: Main(){int j,a[]= {10,20,30,40,50} For (j=0;j
  • Section -ACSE/IT*/338

    CSE/IT

  • An Overview of ComputerEvolution of ComputersHardware organization of computerIntroduction to microprocessorGenerations of microprocessorsCommonly used CPUsInput/Output devicesInput/Output ports and connectors.

    CSE/IT*/338

    CSE/IT

  • Evolution of Computers The need for a device to do calculations along with growth in commerce and other human activities explain the evolution of computers. Having the right tool to perform right has always been important for human beings. In this post, I have mentioned some important history in the evolution of computers.In the beginning, when the task was simply counting or adding, people used either their fingers or pebbles along lines in the sand in order to simply the process of counting, people in Asia minor built a counting device called ABACUS, the device allowed users to do calculations using a system of sliding beads arranged on a rack.With the passage of time, many computing devices such as Napier bones and slide rule were invented. It took many centuries for the advancement in computing devices. In 1642, a French mathematician, Blaise Pascal invented the first functional automatic calculator. The brass rectangular box also called Pascaline, used eight movable dials to add sums and eight figures only.CSE/IT*/338

    CSE/IT

  • Cont CSE/IT*/338

    CSE/IT

  • Cont The real beginning computer was made by an English mathematician Charles Babbage in 1822. He proposed a engine to perform difference equations, called a difference engine. It would print results automatically. However, Babbage never quite made a fully functional difference engine, and in 1833, he quit working on it to concentrate on analytical engine. The basic design of the engine included input devices in the form of perforated cards containing operating system as a store for memory of 1,000 numbers up to 50 decimal digits long. It also contained a controlled unit that allowed processing instructions at any sequence, output device to produce printed results. Babbage borrowed the idea of punch cards to encode the instructions in the machine from the Joseph Marie jacquards loom.

    CSE/IT*/338

    CSE/IT

  • ContA computer as shown in Fig. performs basically five major operations or functions irrespective of their size and make. That are: -1) It accepts data or instructions by way of input2) It stores data3) It can process data as required by the user4) It gives results in the form of output5) It controls all operations inside a computerCSE/IT*/338

    CSE/IT

  • Hardware Organization of Computer Central Processing Unit (CPU) Memory Input device Output device: Mass storage deviceCSE/IT*/338

    CSE/IT

  • Input Device An input device presents data to the processing unit in a machine-readable form. Although the keyboard is a common input device for a small computer, a system may also support various other input devices such as Optical Character Recognition (OCR), Magnetic Ink Character Recognition (MICR), mark sense reader, etc

    CSE/IT*/338

    CSE/IT

  • Output Device Output devices receive information from the CPU and present it to the user in the desired Form. Output devices include display screen loudspeakers,printers, plotters, etc.

    CSE/IT*/338

    CSE/IT

  • CPU This part of the computer that executes program instructions is known as the processor or Central Processing Unit (CPU). In a microcomputer, the CPU is based on a single electronic component, the microprocessor chip, within the system unit or system cabinet. The system unit also includes circuit boards, memory chips, ports and other components. A microcomputers system cabinet will also house disk drives, hard disks, etc., but these are considered separate from the CPU. The CPU has two parts The Control Unit (CU) and the Arithmetic Logic Unit (ALU). In a microcomputer, both are on a single microprocessor chip.CSE/IT*/338

    CSE/IT

  • Memory Unit Memory - also known as the primary storage or main memory - is a part of the microcomputer that holds data and instructions. Part of the contents of the memory is held only temporarily, that is, it is stored only as long as the microcomputer is turned on. When you turn the machine off, the contents are lost. The capacity of the memory to hold data and program instructions varies in different computers. The original IBM PC could hold approximately several thousand characters of data or instructions only. But modern microcomputers can hold millions or even billions of characters in their memory CSE/IT*/338

    CSE/IT

  • Control Unit The control unit tells the rest of the computer system how to carry out a programs instructions. It directs the movement of electronic signals between memory which temporarily holds data, instructions and processes information - and the ALU. It also directs these control signals between the CPU and input/output devices.CSE/IT*/338

    CSE/IT

  • ALU Arithmetic Logic Unit, usually called the ALU, performs two types of operations arithmetical logical. Arithmetical operations are the fundamental mathematical operations consisting of addition, subtraction, multiplication and division. Logical operations consist of comparisons. That is two pieces of data are compared to see whether one is equal to, less than, or greater than the other.CSE/IT*/338

    CSE/IT

  • Introduction to Microprocessor Microprocessor incorporates most or all of the functions of a computer's central processing unit (CPU) on a single integrated circuit (IC, or microchip). The first microprocessors emerged in the early 1970s and were used for electronic calculators, using binary-coded decimal (BCD) arithmetic on 4-bit words. Other embedded uses of 4-bit and 8-bit microprocessors, such as terminals, printers, various kinds of automation etc., followed soon after. Affordable 8-bit microprocessors with 16-bit addressing also led to the first general-purpose microcomputers from the mid-1970s on.Since the early 1970s, the increase in capacity of microprocessors has been a consequence of Moore's Law, which suggests that the number of transistors that can be fitted onto a chip doubles every two years. Although originally calculated as a doubling every year, Moore later refined the period to two years. It is often incorrectly quoted as a doubling of transistors every 18 months. CSE/IT*/338

    CSE/IT

  • P1 (086) First-Generation microprocessorsThe first generation of processors represents the series of chips from Intel that were found in the first PCs. IBM, as the architect of the PC at the time, chose Intel processors and support chips to build the PC motherboard, setting a standard that would hold for many subsequent processor generations to come.CSE/IT*/338

    CSE/IT

  • 8088 and 8086 microprocessorsIntel introduced a revolutionary new processor called the 8086 back in June of 1978. The 8086 was one of the first 16-bit processor chips on the market; at the time virtually all other processors were 8-bit designs. The 8086 had 16-bit internal registers and could run a new class of software using 16-bit instructions. It also had a 16-bit external data path, which meant it could transfer data to memory 16 bits at a time.The address bus was 20 bits wide, meaning that the 8086 could address a full 1MB (220) of memory. This was in stark contrast to most other chips of that time that had 8-bit internal registers, an 8-bit external data bus, and a 16-bit address bus allowing a maximum of only 64KB of RAM (216).CSE/IT*/338

    CSE/IT

  • 80186 and 80188 microprocessorsAfter Intel produced the 8086 and 8088 chips, it turned its sights toward producing a more powerful chip with an increased instruction set. The company's first efforts along this line - the 80186 and 80188 - were unsuccessful. But incorporating system components into the CPU chip was an important idea for Intel because it led to faster, better chips, such as the 286. The relationship between the 80186 and 80188 is the same as that of the 8086 and 8088; one is a slightly more advanced version of the other. Compared CPU to CPU, the 80186 is almost the same as the 8088 and has a full 16-bit design. The 80188 (like the 8088) is a hybrid chip that compromises the 16-bit design with an 8-bit external communications interface. The advantage of the 80186 and 80188 is that they combine on a single chip 15 to 20 of the 80868088 series system components - a fact that can greatly reduce the number of components in a computer design. The 80186 and 80188 chips were used for highly intelligent peripheral adapter cards of that age, such as network adapters CSE/IT*/338

    CSE/IT

  • 8087 CoprocessorIntel introduced the 8086 processor in 1976. The math coprocessor that was paired with the chip-the 8087-often was called the numeric data processor (NDP), the math coprocessor, or simply the math chip. The 8087 is designed to perform high-level math operations at many times the speed of the main processor. The primary advantage of using this chip is the increased execution speed in number-crunching programs, such as spreadsheet applications.CSE/IT*/338

    CSE/IT

  • COMMANLY USED CPU

    CPU (Central Processing Unit) The CPU is the brain of the computer. Sometimes referred to simply as the processor or central processor, the CPU is where most calculations take place. In terms of computing power, the CPU is the most important element of a computer systemCSE/IT*/338

    CSE/IT

  • Slot 1, Slot A, Socket 7, Socket 478CPU socketis the connector that interfaces between a computer's motherboard and the processor itself. Most CPU sockets and processors in use today are built around the pin grid array (PGA) architecture, in which the pins on the underside of the processor are inserted into the socket, usually with zero insertion force (ZIF) to aid installation. In contrast to this, a couple current and upcoming sockets use a land grid array (LGA) in which the pins are on the socket side instead and come in contact with pads on the processor. Slot based processors are cartridge shaped and fix into a slot that looks similar to expansion slots.General In general sockets and slots are used so that the Processor and the motherboard of a computer are able to communicate with each other. And it depends on the processor on what type of socket or slot that it might use.CSE/IT*/338

    CSE/IT

  • Slot 1, Slot A, Socket 7, Socket 478Slot 1, Slot A, and Socket 7 are all various types of CPU (Central Processing Unit) Interfaces. Interfaces are the connection points between the motherboard and any add on or changeable components including processor chips, peripherals, extension cards, etc. There are two main types of interfacesslots and sockets. Slot style interfaces accept Single Edge Contact (SEC) cartridges. An SEC is a way to package microprocessors so that there is a slim single edge which connects to the interface, allowing for perpendicular mounting to the motherboard.Socket style interfaces work on a principle or plug and socket similar to that of a common wall socket. The component to be plugged into the interface will have a Pin Grid Array (PGA)-a square chip package with a pin pattern often of high density.In the evolution of motherboards and CPU interfaces, the socket style interface was the preference among manufactures until the mid to late 90s when slots became the preferred interface. Although both are present in the market, the current shift is back toward socket style CPU interfaces. CSE/IT*/338

    CSE/IT

  • Dual ProcessorA computer that contains two CPUs. Dual processor systems (DP systems) have two independent CPU chips and differ from a dual core system (DC system), which has two processors built into the same CPU chip.Not all operating systems or programs (for example Word) are able to support dual processors. CSE/IT*/338

    CSE/IT

  • Quad ProcessorA quad processor system is any system with 4 CPUs working in parallel. Typically, all 4 CPUs are of the same type.Quad processor systems are uncommon for home computer users.CSE/IT*/338

    CSE/IT

  • INPUT DEVICESParts of Computer, which are used to feed data and commands are called Input DevicesSome Input Devices are:KeyboardMouseJoy StickScannerVoice Input System

    CSE/IT*/338

    CSE/IT

  • Cont Keyboard is the most commonly used Input Device. The keys on the keyboard can be classified as follows:Alphabetic keysNumeric keysFunction keysSymbols keysSpecial keys

    CSE/IT*/338

    CSE/IT

  • Cont Mouse is a pointing device which is used to draw, move and resize the picture and words. It has a small ball inside ,which when rolls, moves the rollers, which move the pointer on the screen of monitor. it has two buttons on the top

    CSE/IT*/338

    CSE/IT

  • Cont A joystick consists of vertical bar. It can be rotated in various directions. This rotation moves the cursor to the desired position.

    CSE/IT*/338

    CSE/IT

  • OUTPUT DEVICESOutput devices are the devices which are used to get final result of work done on computer.Following are some Output Devices:Monitor or Visual Display Unit PrintersSpeakersCSE/IT*/338

    CSE/IT

  • Cont Every Computer has a television like device. It is called monitor or visual display unit. It is used to display information to us.

    CSE/IT*/338

    CSE/IT

  • ContThese days a lot of printers are available in the market which can be divided as follows:Impact PrintersNon-Impact PrintersCSE/IT*/338

    CSE/IT

  • Cont Speakers are used to listen sounds from a computer system. When you are watching a cartoon film, the picture appears on the monitor, but you can hear cartoon character talking only if speakers are attached to your computer

    CSE/IT*/338

    CSE/IT

  • INPUT/OUTPUT PORTSThis is the standard input and output facilities in Isis. Input from and output to any endpoint is handled using the same mechanism known as a port, which allows the same procedures to be used for reading, writing, and other operations, regardless of where the data is coming from or going to. It will usually not be necessary to look at anything in this list, and of course, nothing in the list should ever be modified manually. CSE/IT*/338

    CSE/IT

  • ContOne can do the following - :Open a portClose a PortRead and Write DataPort Position Port StatusPort QueriesPort Utilities

    CSE/IT*/338

    CSE/IT

  • CONNECTORSThe part of a cable that plugs into a port or interface to connect one device to another. Most connectors are either male (containing one or more exposed pins) or female (containing holes in which the male connector can be inserted). Every house or office today is equipped with a multitude of connectors. Connectors are devices used for mating and de-mating electrical power connections. Connectors are responsible for power transfers and information transfers among machines and people that are spread over different locations.All electronic devices require a constant source of power to function and like all electronics even computers require power to function. Computer PSU is a term given to any the wires that that convert lethal electricity into usable and safe electricity. Each PSU requires connectors to function and this article is going to elaborate on the connectors used in these power supplies.CSE/IT*/338

    CSE/IT

  • ContCSE/IT*/338

    CSE/IT

  • Introduction to Operating systemIntroduction to Operating SystemFunctions of an Operating SystemTypes of an Operating System Introduction to DOS ,UNIX/LINUX OS, Windows XP CSE/IT*/338

    CSE/IT

  • Introduction to Operating System The operating system is the core software component of your computer. It performs many functions and is, in very basic terms, an interface between your computer and the outside world. In the section about hardware, a computer is described as consisting of several component parts including your monitor, keyboard, mouse, and other parts. The operating system provides an interface to these parts using what is referred to as "drivers". This is why sometimes when you install a new printer or other piece of hardware, your system will ask you to install more software called a driver.CSE/IT*/338

    CSE/IT

  • Functions of an Operating System Resource managementThe resource management function of an OS allocates computer resources such as CPU time, main memory, secondary storage, and input and output devices for use.Data managementThe data management functions of an OS govern the input and output of the data and their location, storage, and retrieval. Job (task) managementThe job management function of an OS prepares, schedules, controls, and monitors jobs submitted for execution to ensure the most efficient processing. A job is a collection of one or more related programs and their data standard means of communication between user and computer.CSE/IT*/338

    CSE/IT

  • ContCSE/IT*/338

    CSE/IT

  • Types of an Operating System Windows XP Professional Edition Windows XP Home Edition Windows 2000 Windows ME Windows 98 Windows NT Windows 95 DOS UNIX/LINUX CSE/IT*/338

    CSE/IT

  • Introduction to MS-DOSAn operating system is a set of interrelated programs that manage and control computer processing.The Microsoft Disk Operating System, MS-DOS, is a traditional microcomputer operating system that consists of four major components. The Operating-system loader - It brings the operating system from the startup into RAM. - Bootstrapping The MS-DOS BIOS - BIOS stands for Basic Input/Output systems - Loaded from the file IO.SYS during initialization. - Layer that sits between operating system kernel and hardware. CSE/IT*/338

    CSE/IT

  • Cont The User Interface (shell) - Conventional program that allows the user to interact with the operating system. - Default MS DOS user interface is a shell program called Command.com The MS-DOS Kernel - Heart of the operating system - it is a proprietary program supplied by Microsoft corporation.

    CSE/IT*/338

    CSE/IT

  • MS-DOS Kernel

    The kernel provides a collection of hardware-independent services called system functions. - File Management - Memory Management - Device Input and Output - Process controlCSE/IT*/338

    CSE/IT

  • File ManagementBlock Devices are accessed on a sector basis. The MS- DOS kernel through the device driver sees a block as a logical fixed size array of sectors. the device driver in turn translates the logical sector requests from the MS DOS into physical locations on the block device.MS DOS file system is divided into four parts - Boot Sector - Always at the beginning of a partition. - Contains OEM identification, a loader routine , and a BIOS parameter block.

    CSE/IT*/338

    CSE/IT

  • Cont - File Allocation Tables (FAT) - Provides a map to the storage locations of files on the disk by indicating which clusters are allocated to each file. - Second copy of FAT as back up. - Free cluster is found by scanning the FAT for a zero value. - Root directory - Root directory entries are 32 bytes long. - Each entry includes a filename and extension, size, starting FAT entry, the time and date the file was created and the files attributes. CSE/IT*/338

    CSE/IT

  • *UNIXUNIX is multi-user and multi-tasking operating system.Multi-tasking: Multiple processes can run concurrently.Example, different users can read mails, copy files, and print all at once.CSE/IT*/338

    CSE/IT

  • *Logging In UNIXEnter login name and password !System password file: /etc/passwd (usually).You can change password using the command: passwd.CSE/IT*/338

    CSE/IT

  • *UNIX ShellAfter a successful login, the shell program is run. The default shell of bingsuns: tcsh bingsun2% psPID TTY TIME CMD2159 pts/2 0:00 tcshShell is a command line interpreter that reads user commands and executes them.CSE/IT*/338

    CSE/IT

  • *Unix ShellsCommon Shells: Bourne shell, the C shell, and the Korn shell.The shell on bingsuns is tcsh (tc shell).Users can switch between shells, using the commands bash, csh, ksh, sh.Control D (^d) to return back to original shell, or just use the command: exit.CSE/IT*/338

    CSE/IT

  • *Some shell commandsMost Important command: man (manual pages).Help: unix commands, C functions.Usage: man Try man man !Example:man ls, man passwd, man printf.CSE/IT*/338

    CSE/IT

  • *Some shell commands (cont)pwd: working directory (/u0/users/2/kliu1).ls: list contents of directorymkdir : make directoryrmdir : remove an empty directoryrm r : remove a directory with all the contentscd : change directory, ~/ means your home directorycp : copy command.CSE/IT*/338

    CSE/IT

  • *File SystemHierarchical arrangement of files and directories.Top level: root or /e.g.: cd /Current directory, .. One level higher directorye.g.: cd . No change for it is current directoryor cd .. Change to parent directory.CSE/IT*/338

    CSE/IT

  • *File System (cont)Pathname: absolute and relative.Absolute pathname: /u0/users/2/kliu1Relative pathname: abc.CSE/IT*/338

    CSE/IT

  • * UNIX EditorsDifferent editors: emacs, pico, viemacs pico vi CSE/IT*/338

    CSE/IT

  • Starting Windows XPWindows XPStarts when computer is turned onElements of the desktopIconPointerDesktopDate/Time controlTaskbarStart buttonNotification areaCSE/IT*/338

    CSE/IT

  • Starting Windows XP shows the Windows XP desktopCSE/IT*/338

    CSE/IT

  • Starting Windows XPWindows XP desktop uses a graphical user interfaceGraphical user interface (GUI)Displays icons to represent items stored on the computerIcons: Pictures of familiar objectsCSE/IT*/338

    CSE/IT

  • The Windows XP DesktopDesktopArea that appears on the screen when Windows XP startsA workspace for projects and toolsUses default settings when the computer is first startedDefault settings: settings preset by the operating systemAppearance can be changed by the userCSE/IT*/338

    CSE/IT

  • Using a Pointing DeviceA pointing deviceHelps the user interact with objects on the computer screenComes in many shapes and sizesMouseMost common pointing deviceCSE/IT*/338

    CSE/IT

  • Anatomy of a WindowControlsLocated in a windowGraphical or textual objects used forManipulating the windowUsing the programExamplesMenu barSizing buttonsStatus barTitle barToolbarWorkspace CSE/IT*/338

    CSE/IT

  • SECTION-2Basic Introduction to System Software and ProgramsBasic Introduction to Computer NetworksCSE/IT*/338

    CSE/IT

  • Basic Introduction to System Software and Programs 1. Introduction to Programming Language2. Characteristics of good Programming Language3. Machine Language 3.1) Advantages of Machine language 3.2) Disadvantages of Machine language4. Low Level Language5.High Level Language6.Compiler 7.Interpreter 8.Assembler 9.Loader10.LinkerCSE/IT*/338

    CSE/IT

  • Introduction to Programming LanguageThe term programming language usually refers to high-level languages, such as BASIC, C, C++, COBOL, FORTRAN, Ada and Pascal. High-level programming languages, while simple compared to human languages, are more complex than the languages the computer actually understands, called machine languages. Each different type of CPU has its own unique machine language. Lying between machine languages and high-level languages are languages called assembly languages. Regardless of what language you use, you eventually need to convert your program into machine language so that the computer can understand it. There are two ways to do this: 1) compile the program. 2) interpret the programCSE/IT*/338

    CSE/IT

  • Characteristics of good Programming Language

    1. Clarity of source code the extent to which inherent language features support source code that is readable and understandable and that clearly reflects the underlying logical structure of the program.2. Complexity management (architecture support) the extent to which inherent language features support the management of system complexity, in terms of addressing issues of data, algorithm, interface, and architectural complexity.3. Concurrency support the extent to which inherent language features support the construction of code with multiple threads of control (also known as parallel processing).4. Distributed system support the extent to which inherent language features support the construction of code to be distributed across multiple platforms on a network.5. Maintainability the extent to which inherent language features support the construction of code that can be readily modified to satisfy new requirements or to correct deficiencies.

    CSE/IT*/338

    CSE/IT

  • Cont6. Mixed language support the extent to which inherent language features support interfacing to other languages.7. Object-oriented programming support the extent to which inherent language features support the construction of object-oriented code.8. Portability the extent to which inherent language features support the transfer of a program from one hardware and/or software platform to another.9. Real-time support the extent to which inherent language features support the construction of real-time systems.CSE/IT*/338

    CSE/IT

  • Machine Language

    The lowest-level programming language (except for computers that utilize programmable microcode) Machine languages are the only languages understood by computers. While easily understood by computers, machine languages are almost impossible for humans to use because they consist entirely of numbers. Programmers, therefore, use either a high-level programming language or an assembly language. An assembly language contains the same instructions as a machine language, but the instructions and variables have names instead of being just numbers.CSE/IT*/338

    CSE/IT

  • Advantages of Machine language It is a most efficient in term of storage area use and execution speed and it also allows programmer to utilize the computer's potential for processing data.The only advantage is that program of machine language run very fast because no translation program is required for the CPU.In machine language, the very basic and specific commands may be used, like to where the specific data will be stored, how operations and functions be carried out. and since it is in a code the machine can understand, it may not need a compiler.CSE/IT*/338

    CSE/IT

  • Disadvantages of Machine Language 1. It is very difficult to program in machine language. The programmer has to know details of hardware to write program.2. The programmer has to remember a lot of codes to write a program which results in program errors.3. It is difficult to debug the program CSE/IT*/338

    CSE/IT

  • Assembly language

    Machine languages consist entirely of numbers and are almost impossible for humans to read and write. Assembly languages have the same structure and set of commands as machine languages, but they enable a programmer to use names instead of numbers.

    Each type of CPU has its own machine language and assembly language, so an assembly language program written for one type of CPU won't run on another. In the early days of programming, all programs were written in assembly language. CSE/IT*/338

    CSE/IT

  • Comparison Between Assembly & Machine LanguageMachine language is the actual bits used to control the processor in the computer, usually viewed as a sequence of hexadecimal numbers (typically bytes). Assembly language is a more human readable view of machine language. Instead of representing the machine language as numbers, the instructions and registers are given names (typically abbreviated words, or mnemonics, eg ld means "load"). An assembly language program (ie a text file) is translated to machine language by an assembler. A disassembler performs the reverse function. Machine language faster than assembly language even than assembly language depend upon machine language. CSE/IT*/338

    CSE/IT

  • Advantage of Assembly languageAssembly language is a symbolic representation of a processor's native code.Using machine code allows the programmer to control precisely what the processor does. It offers a great deal of power to use all of the features of the processor. The resulting program is normally very fast and very compact. In small programs it is also very predictable. Timings, for example, can be calculated very precisely and program flow is easily controlled. It is often used for small, real time applications.CSE/IT*/338

    CSE/IT

  • Disadvantage of Assembly languageThe programmer needs to have a good understanding of the hardware being used. As programs become larger, assembly language get very cumbersome.Maintenance of assembly language is notoriously difficult, especially if another programmer is brought in to carry out modifications after the code has been written. Assembly langauge also has no support of an operating system, nor does it have any complex instructions. Storing and retrieving data is a simple task with high level languages; assembly needs the whole process to be programmed step by step. Mathmatical processes also have to be performed with binary addition and subtraction when using assembly which can get very complex. Finally, every processor has its own assembly language. Use a new processor and you need to learn a new language each time.CSE/IT*/338

    CSE/IT

  • High Level Language

    Programs written in high-level languages are translated into assembly language or machine language by a compiler. Assembly language programs are translated into machine language by a program called an assembler. Every CPU has its own unique machine language. Programs must be rewritten or recompiled, therefore, to run on different types of computers. A programming language such as C, FORTRAN, or Pascal that enables a programmer to write programs that are more or less independent of a particular type of computer. Such languages are considered high-level because they are closer to human languages and further from machine languages. In contrast, assembly languages are considered low-level because they are very close to machine languages.CSE/IT*/338

    CSE/IT

  • Advantages of High Level LanguageIn high level languages we can write programs in English like manner and is more convenient to use. Programmer can perform complex task by using high level languages with less efforts.There are different high level languages such as FORTRAN (Formula Instructions), BASIC (Beginners All Purpose Symbolic Instruction Code), COCOL (Common Business Oriented Language), PASCAL, C++, Visual Basic, VB. Net etc.High level languages have many advantages. High level languages are very similar to nature language such as English so they are very easy to learn and use. For higher level languages programmers needs not to learn about internal structure of the computer. CSE/IT*/338

    CSE/IT

  • Cont High level language programs require less time and efforts that due the preparation cost of the program. High level programs are very easy to maintain than lower level languages. In lower level languages instruction are difficult and very hard to locate, correct and modify but in high level languages it is very easy to understand and modify when desired. In high level languages programmer needs not to write all steps because computer take cares of all small error. Compilers of high level languages automatically catch and point out the errors made by the programmers.CSE/IT*/338

    CSE/IT

  • Disadvantages of HighLevel LanguageThough it is much easier to code in a high level language, oftentimes access to more low-level functionalities are lost. For instance, the ability to communicate directly with the compiler and alter code before it gets transferred into machine code is lost. To make it more easier for the programmer to understand and write code. High level programming languages like C, C++ and Java give you comfort and a pool of options because they basically use a syntax that is similar to the everyday English we speak. Coding a computer today is just one step below to talking to a human. It is that easy. Now, why are low-level programming languages important? Low level programming languages are important because of space and speed. If you write a program in a high level language, say Java, first the Java Compiler will compile it to byte code. Now, this byte code is again compiled during run time to assembly code(low level) which in turn is again converted to executable code.But, when you write low level code, it is directly converted into executable code avoiding all the other steps. This will incredibly save you space and increase speed.CSE/IT*/338

    CSE/IT

  • Types of High Level Language

    a) BASIC- In computer programming, BASIC is a family of high-level programming languages. The original BASIC was designed in 1964. At the time, nearly all use of computers required writing custom software, which was something only scientists and mathematicians tended to do. The language and its variants became widespread on microcomputers in the late 1970s and 1980s. BASIC remains popular to this day in a handful of highly modified dialects and new languages influenced by BASIC such as Microsoft Visual Basic b) COBOL - COBOL is one of the oldest programming languages. Its name is an acronym for COmmon Business-Oriented Language, defining its primary domain in business, finance, and administrative systems for companies and governments

    CSE/IT*/338

    CSE/IT

  • Types of High Level Language

    c) FORTRAN - Fortran is a general-purpose, procedural, imperative programming language that is especially suited to numeric computation and scientific computing. Originally developed by IBM at their campus in south San Jose, California in the 1950s for scientific and engineering applications, Fortran came to dominate this area of programming early on and has been in continual use for over half a century in computationally intensive areas such as numerical weather prediction, finite element analysis, computational fluid dynamics, computational physics and computational chemistry. CSE/IT*/338

    CSE/IT

  • CompilationCompilation is a process that translates a program in one language (the source language) into an equivalent program in another language (the object or target language).A compiler is a computer program that translates a program in a source language into an equivalent program in a target language.A source program/code is a program/code written in the source language, which is usually a high-level language.A target program/code is a program/code written in the target language, which often is a machine language or an intermediate code CSE/IT*/338

    CSE/IT

  • CompilationCSE/IT*/338

    CSE/IT

  • Cont.. CSE/IT*/338

    CSE/IT

  • Symbol Table Identifiers are names of variables, constants, functions, data types, etc.Store information associated with identifiersInformation associated with different types of identifiers can be differentInformation associated with variables are name, type, address,size (for array), etc.Information associated with functions are name,type of return value, parameters, address, etc.The scanner, parser, and semantic analyzer put names of identifiers in symbol table.The semantic analyzer stores more information (e.g. data types) in the table.The intermediate code generator, code optimizer and code generator use information in symbol table to generate appropriate code.

    CSE/IT*/338

    CSE/IT

  • Literal table Store constants and strings used in programreduce the memory size by reusing constants and stringsCan be combined with symbol tableCSE/IT*/338

    CSE/IT

  • Parse treeDynamically-allocated, pointer-based structureInformation for different data types related to parse trees need to be stored somewhere.Nodes are variant records, storing information for different types of data Nodes store pointers to information stored in other data structure, e.g. symbol table CSE/IT*/338

    CSE/IT

  • InterpreterAn interpreter translates some form of source code into a target representation that it can immediately execute and evaluate. The structure of the interpreter is similar to that of a compiler, but the amount of time it takes to produce the executable representation will vary as will the amount of optimization. The following diagram shows one representation of the differences. CSE/IT*/338

    CSE/IT

  • Cont CCSE/IT*/338

    CSE/IT

  • Compiler characteristics spends a lot of time analyzing and processing the programthe resulting executable is some form of machine- specific binary codethe computer hardware interprets (executes) the resulting codeprogram execution is fast

    CSE/IT*/338

    CSE/IT

  • Interpreter characteristics:relatively little time is spent analyzing and processing the programthe resulting code is some sort of intermediate codethe resulting code is interpreted by another programprogram execution is relatively slow

    CSE/IT*/338

    CSE/IT

  • AssemblersThere are two main classes of programming languages: high level (e.g., C, Pascal) and low level. Assembly Language is a low level programming language. Programmers code symbolic instructions, each of which generates machine instructions.

    An assembler is a program that accepts as input an assembly language program (source) and produces its machine language equivalent (object code) along with the information for the loader.

    CSE/IT*/338

    CSE/IT

  • Advantages of coding in assembly language Provides more control over handling particular hardware componentsMay generate smaller, more compact executable modulesOften results in faster executionCSE/IT*/338

    CSE/IT

  • Disadvantages of coding in assembly language Not portableMore complexRequires understanding of hardware details (interfaces)CSE/IT*/338

    CSE/IT

  • Assembler 1. Generate machine instructionsevaluate the mnemonics to produce their machine codeevaluate the symbols, literals, addresses to produce their equivalent machine addressesconvert the data constants into their machine representations2. Process pseudo operations CSE/IT*/338

    CSE/IT

  • Two Pass Assembler A two-pass assembler performs two sequential scans over the source code:Pass 1: symbols and literals are definedPass 2: object program is generatedCSE/IT*/338

    CSE/IT

  • Data Structures

    Location counter (LC): points to the next location where the code will be placedOp-code translation table: contains symbolic instructions, their lengths and their op-codes (or subroutine to use for translation)Symbol table (ST): contains labels and their valuesString storage buffer (SSB): contains ASCII characters for the stringsConfiguration table: contains pointer to the string in SSB and offset where its value will be inserted in the object codeCSE/IT*/338

    CSE/IT

  • ContCSE/IT*/338

    CSE/IT

  • LinkerIn computer science, a linker or link editor is a program that takes one or more objects generated by a compiler and combines them into a single executable program.

    On UNIX variants the term loader is often used as a synonym for linker. Other terminology was in use, too. For example, on SINTRANIII the process performed by a linker (assembling object files into a program) was called loading (as in loading executable code onto a file). Because this usage blurs the distinction between the compile-time process and the run-time process, this article will use linking for the former and loading for the latter. However, in some operating systems the same program handles both the jobs of linking and loading a program.CSE/IT*/338

    CSE/IT

  • Cont CSE/IT*/338

    CSE/IT

  • Cont Linkers can take objects from a collection called a library. Some linkers do not include the whole library in the output; they only include its symbols that are referenced from other object files or libraries. Libraries exist for diverse purposes, and one or more system libraries are usually linked in by default.The linker also takes care of arranging the objects in a program's address space. This may involve relocating code that assumes a specific base address to another base. Since a compiler seldom knows where an object will reside, it often assumes a fixed base location (for example, zero). Relocating machine code may involve re-targeting of absolute jumps, loads and stores CSE/IT*/338

    CSE/IT

  • Dynamic linkingMany operating system environments allow dynamic linking, that is the postponing of the resolving of some undefined symbols until a program is run. That means that the executable code still contains undefined symbols, plus a list of objects or libraries that will provide definitions for these. Loading the program will load these objects/libraries as well, and perform a final linking.CSE/IT*/338

    CSE/IT

  • Advantages Often-used libraries (for example the standard system libraries) need to be stored in only one location, not duplicated in every single binary.If an error in a library function is corrected by replacing the library, all programs using it dynamically will benefit from the correction after restarting them. Programs that included this function by static linking would have to be re-linked first CSE/IT*/338

    CSE/IT

  • Disadvantages Known on the Windows platform as "DLL Hell", an incompatible updated DLL will break executables that depended on the behavior of the previous DLL.A program, together with the libraries it uses, might be certified (e.g. as to correctness, documentation requirements, or performance) as a package, but not if components can be replaced. (This also argues against automatic OS updates in critical systems; in both cases, the OS and libraries form part of a qualified environment.)

    CSE/IT*/338

    CSE/IT

  • LoaderPart of the OS that brings an executable file residing on disk into memory and starts it running Steps -: Read executable files header to determine the size of text and data segments Create a new address space for the program Copies instructions and data into address space Copies arguments passed to the program on the stack Initializes the machine registers including the stack ptr Jumps to a startup routine that copies the programs arguments from the stack to registers and calls the programs main routine CSE/IT*/338

    CSE/IT

  • Basic Introduction to Computer NetworksData Communication ModulationNetwork devices LAN, LAN topologies WAN,OSI Reference model TCP/IP Reference model, Backbone networkNetwork connecting devices, HTTPDNS Network Security

    CSE/IT*/338

    CSE/IT

  • What is data communicationNot to be confused with telecommunicationAny process that permits the passage from a sender to one or more receivers of information of any nature, delivered in any easy to use form by any electromagnetic system.Data communication-Defined as a subset of telecommunication involving the transmission of data to and from computers and components of computer systems.More specifically data communication is transmitted via mediums such as wires, coaxial cables, fiber optics, or radiated electromagnetic waves such as broadcast radio, infrared light, microwaves, and satellites.

    CSE/IT*/338

    CSE/IT

  • History of Data CommunicationTransistor developed by Bell Labs (which is now ???) 1947Hush-a-Phone CaseCarterphone caseMCI and Long DistanceCreation of networks (LANs and WANs)Data Link ProtocolsMicrocomputersCSE/IT*/338

    CSE/IT

  • Features of CommunicationFour things requiredSender, receiver, medium, and messageTypes of messagesFileRequestResponseStatusControlCorrespondenceUnderstandabilityError DetectionCSE/IT*/338

    CSE/IT

  • Cont.CSE/IT*/338

    CSE/IT

  • Network ApplicationsThe network applications environment consists of several important components:Application programsOperating systemsData communication systemsDatabase management systemsThe application environment is illustrated in Figure 1-10CSE/IT*/338

    CSE/IT

  • Other Data Communication ApplicationsBatch applicationsData entry applicationsDistributed applicationsInquiry/response applicationsInteractive applicationsSensor-based applicationsCombined applicationsCSE/IT*/338

    CSE/IT

  • Introduction to ModulationModulation is the process of varying some characteristic of a periodic wave with an external signals. Modulation is utilized to send an information bearing signal over long distances. The characteristics (amplitude, frequency, or phase) of the carrier signal are varied in accordance with the information bearing signal.The information bearing signal is also known as the modulating signal. The modulating signal is a slowly varying signal as opposed to the rapidly varying carrier frequency.

    CSE/IT*/338

    CSE/IT

  • Contd. CSE/IT*/338

    CSE/IT

  • 2/45Contd.Encoding and Modulation TechniquesCSE/IT*/338

    CSE/IT

  • ContTypes of ModulationAmplitude ModulationFrequency ModulationPhase Modulation

    CSE/IT*/338

    CSE/IT

  • Frequency Modulation (FM) In FM, the amplitude of the carrier remains fixedIn FM, frequency changes according to the signal: when the signal is stronger, the carrier frequency increases slightly, and when the signal is weaker, the carrier frequency decreases slightlyFigure 10.3 illustrates an example of FM for an info signalFM is more difficult to visualize because slight changes in frequency are not as clearly visibleHowever, one can notice that the modulated wave has higher frequencies when the signal used for modulation is stronger

    CSE/IT*/338

    CSE/IT

  • Frequency Modulation CSE/IT*/338

    CSE/IT

  • Phase Modulation (PM) One of the property of a sine wave is its phase, the offset from a reference time at which the sine wave beginsIt is possible to use changes in phase to represent a signalWe use the term phase shift to characterize such changesIf phase changes after cycle k, the next sine wave will start slightly later than the time at which cycle k completesA slight delay resembles a change in frequencyPM can be thought of as a special form of frequency modulationHowever, phase shifts are important when a digital signal is used to modulate a carrier

    CSE/IT*/338

    CSE/IT

  • Amplitude Modulation And Shannon's Theorem shows the amplitude varying from a maximum to almost zeroThe figure is slightly misleading: in practice, modulation only changes the amplitude of a carrier slightly, depending on a constant known as the modulation indexPractical systems do not allow for a modulated signal to approach zeroConsider Shannon's Theoremassuming the amount of noise is constantthe signal-to-noise ratio will approach zero as the signal approaches zeroKeeping the carrier wave near maximum insures that the signal-to-noise ratio remains as large as possible. This permits the transfer of more bits per secondCSE/IT*/338

    CSE/IT

  • Networking Devices

    Networking hardware or networking equipment typically refers to devices facilitating the use of a computer network. Typically, this includes gateways, routers, network bridges, switches, hubs, and repeaters.Devices are-RepeaterHubBridgeRouterGateway

    CSE/IT*/338

    CSE/IT

  • Cont CSE/IT*/338

    CSE/IT

  • Cont CSE/IT*/338

    CSE/IT

  • ROUTER: a specialized network device that determines the next network point to which it can forward a data packet towards the destination of the packet. Unlike a gateway, it cannot interface different protocols. Works on OSI layer 3.

    Router CSE/IT*/338

    CSE/IT

  • BRIDGE : a device that connects multiple network segments along the data link layer Works on OSI layer 2.

    Bridge CSE/IT*/338

    CSE/IT

  • HUB : connects multiple Ethernet segments together making them act as a single segment. When using a hub, every attached device shares the same broadcast domain and the same collision domain . Therefore, only one computer connected to the hub is able to transmit at a time. Depending on the network topology, the hub provides a basic level 1 OSI model connection among the network objects (workstations, servers, etc.). It provides bandwidth which is shared among all the objects, compared to switches, which provide a connection between individual nodes. Works on OSI layer 1.

    Hub CSE/IT*/338

    CSE/IT

  • REPEATER: device to amplify or regenerate digital signals received while sending them from one part of a network into another. Works on OSI layer 1.

    Repeater CSE/IT*/338

    CSE/IT

  • LAN (Local Area Networks)A LAN is a computer network that covers a small area (home, office, building, campus) a few kilometers LANs have higher data rates (10Mbps to 10Gbps) as compared to WANsLANs (usually) do not involve leased lines; cabling and equipments belong to the LAN owner. A LAN consists ofShared transmission mediumnow so valid today due to switched LANsregulations for orderly access to the mediumset of hardware and software for the interfacing devices

    CSE/IT*/338

    CSE/IT

  • LAN Protocol ArchitectureCorresponds to lower two layers of OSI modelBut mostly LANs do not follow OSI modelCurrent LANs are most likely to be based on Ethernet protocols developed by IEEE 802 committeeIEEE 802 reference modelLogical link control (LLC)Media access control (MAC)Physical

    CSE/IT*/338

    CSE/IT

  • LAN TopologiesBusRingStar

    CSE/IT*/338

    CSE/IT

  • Bus Topology - 1Stations attach to linear medium (bus)Via a tap - allows for transmission and receptionTransmission propagates in medium in both directions Received by all other stationsNot addressed stations ignoreNeed to identify target stationEach station has unique address Destination address included in frame headerTerminator absorbs frames at the end of medium CSE/IT*/338

    CSE/IT

  • Bus Topology - 2Need to regulate transmissionTo avoid collisionsIf two stations attempt to transmit at same time, signals will overlap and become garbageTo avoid continuous transmission from a single station. If one station transmits continuously, access is blocked for othersSolution: Transmit Data in small blocks frames

    CSE/IT*/338

    CSE/IT

  • Ring TopologyRepeaters joined by point- to-point links in closed loopLinks unidirectionalReceive data on one link and retransmit on anotherStations attach to repeatersData transmitted in framesFrame passes all stations in a circular mannerDestination recognizes address and copies frameFrame circulates back to source where it is removedMedium access control is needed to determine when station can insert frame

    CSE/IT*/338

    CSE/IT

  • Frame Transmission Ring LANCSE/IT*/338

    CSE/IT

  • Star TopologyEach station connected directly to central nodeusing a full-duplex (bi-directional) linkCentral node can broadcast (hub)Physical star, but logically like bus since broadcastOnly one station can transmit at a timeCentral node can act as frame switchretransmits only to destinationtodays technologyHub or SwitchCSE/IT*/338

    CSE/IT

  • Wide Area Network (WAN)A Wide Area Network (WAN) is a telecommunication network that covers a broad area (i.e., any network that links across metropolitan, regional, or national boundaries). Business and government entities utilize WANs to relay data among employees, clients, buyers, and suppliers from various geographical locations. In essence this mode of telecommunication allows a business to effectively carry out its daily function regardless of location.

    CSE/IT*/338

    CSE/IT

  • Normally WANs are justphysicalextensions of LANs. They are built using private leased lines. Their huge coverage area makes the cost go higher and transmission speeds to drop down. CSE/IT*/338

    CSE/IT

  • There are two main components when the Wide Area Networks are considered.Switching elementsTransmission linesLet us start with what transmission lines are. Simply put transmission lines is a a medium to transfers bits of information betweenthemachines in the network.To connect thesetransmissionlines, we usespecializedcomputers called switching elements. It performs intelligent switching function. When it receives an input packet, it decides which output line to forward it to. Youshouldnote that that subnet mentioned here is a little ambiguous. Subnet here andsubnetting for network address is not the same. Here, the term subnet is used as a generic term for computer components intheWAN.CSE/IT*/338

    CSE/IT

  • Leased line a pre-established WAN communications path from the CPE, through the DCE switch, to the CPE of the remote site, allowing DTE networks to communicate at any time with no setup procedures before transmitting data.

    Circuit switching uses dial-up modems or ISDN and is used for low-bandwidth data transfers. Think phone call.

    Packet switching allows you to share bandwidth with other companies to save money. Can be thought of as a network thats designed to look like a leased line, yet costs more like circuit switching. WAN Connection TypesCSE/IT*/338

    CSE/IT

  • Frame Relay ISDN Integrated Services Digital Network LAPB Link Access Procedure, Balanced HDLC High-Level Data-Link Control PPP Point-to-Point Protocol ATM Asynchronous Transfer ModeWAN protocols used today:CSE/IT*/338

    CSE/IT

  • The OSI Reference ModelThe OSI models is shown on Fig. 1. (minus the physical medium). This model is based on a proposal developed by the International Standards Organization (ISO) as a first step toward international standardization of the protocols used in the various layers. The model is called the ISO OSI (Open Systems Interconnection) Reference Model because it deals with connecting open systems that is, systems that are open for communication with other systems. We will usually just call it the OSI model for short. CSE/IT*/338

    CSE/IT

  • The OSI reference modelCSE/IT*/338

    CSE/IT

  • The OSI Reference Model - PrinciplesThe OSI model has seven layers.The principles that were applied to arrive at the seven layers are as follows:A layer should be created where a different level of abstraction is needed.Each layer should perform a well defined function.The function of each layer should be chosen with an eye toward defining internationally standardized protocols.The layer boundaries should be chosen to minimize the information flow across the interfaces.The number of layers should be large enough that distinct functions need not be thrown together in the same layer out of necessity, and small enough that the architecture dose not become unwieldy.CSE/IT*/338

    CSE/IT

  • The OSI Reference ModelNote that the OSI model itself is not a network architecture, because it does not specify the exact services and protocols to be used in each layer. It just tells what each layer should do. However, ISO has also produced standards for all the layers, although these are not part of the reference model itself. Each one has been published as a separate international standard. Next, we will discuss each layer of the model in turn, starting at the bottom layer.CSE/IT*/338

    CSE/IT

  • OSI The Physical LayerThe physical layer is concerned with transmitting raw bits over a communication channel. The design issues have to with making sure that when one side send a 1 bit, it is received by the other side as a 1 bit, not as a 0 bit.Typical questions here are:how many volts should be used to represent a 1 and how may for a 0how many microseconds a bit lasts whether transmission may proceed simultaneously in both directionshow the initial connection is established and how it is torn down when both sides are finishedAnd how many pins the network connector has and what each pin is used for.The design issues here largely deal with mechanical, electrical, and procedural interfaces, and the physical transmission medium, which lies below the physical layer.CSE/IT*/338

    CSE/IT

  • OSI The Data Link LayerThe main task of the data link layer is to take a raw transmission facility and transform it into a line that appears free of undetected transmission errors to the network layer.It accomplishes this task by having the sender break the input data up into data frames (typically a few hundred or a few thousand bytes), transmit the frames sequentially, and process the acknowledgment frames sent back by the receiver.Since the physical layer merely accepts and transmits a stream of bits without any regard to meaning or structure, it is up to the data link layer to create and recognize frame boundaries.This can be accomplished by attaching special bit patterns to the beginning and end of the frame. (if these bit patterns accidentally occur in the data, special care must be taken to make sure these patterns are not incorrectly interpreted as frame delimiters.)CSE/IT*/338

    CSE/IT

  • OSI The Data Link LayerA noise burst on the line can destroy a frame completely. In this case, the data link layer software on the source machine can retransmit the frame.However, multiple transmissions of the same frame introduce the possibility of duplicate frames. (if the acknowledgment frame from the receiver back to the sender was lost)It is up to this layer to solve the problems caused by damaged, lost and duplicate frames.Another issue that arises in the data link layer (and most higher layers as well) is how to keep a fast transmitter from drowning a slow receiver in data. Some traffic regulation mechanism must be employed to let the transmitter know how much buffer space the receiver has at the moment. Frequently, this flow regulation and error handling are integrated.

    CSE/IT*/338

    CSE/IT

  • OSI The Network LayerA key design issue with the network layer is determining how packets are routed from source to destination. Routes can be based on static tables that are wired into the network and rarely changed.They can also be determined at the start of each conversation, for example a terminal session.Finally, the can be highly dynamic, being determined anew for each packet, to reflect the current network load.If too many packets are present in the communication line at the same time, they will get in each others way, forming bottlenecks. The control of such congestion also belongs to the network layer.There is often some accounting function built into the network layer. At the very least, the software must count how many packets or characters or bits are sent by each customer, to produce billing information. When a packet crosses a national border, with different rates on each side, the accounting can become complicated.

    CSE/IT*/338

    CSE/IT

  • ContWhen a packet has to travel from one network to another to get to its destination, many problems can arise:The addressing used by the second network may be different from the first oneThe second one may not accept the packet at all because it is too largeThe protocols may differ, and so on

    It is up to the network layer to overcome all these problems to allow heterogeneous networks to be interconnected.

    In broadcast networks, the routing problem is simple, so the network layer is often thin or even nonexistent.

    CSE/IT*/338

    CSE/IT

  • OSI The Transport LayerThe basic function of the transport layer is to accept data from the session layer, split it up into smaller units if need be, pass these to the network layer, and ensure that the pieces all arrive correctly at the other end. Furthermore, all this must be done efficiently, and in a way that isolates the upper layers from the inevitable changes in the hardware technology.

    Under normal conditions, the transport layer creates a distinct network connection for each transport connection required by the session layer. If the transport connection requires a high throughput, however the transport layer might create multiple network connections, dividing the data among the network connections to improve throughput.

    CSE/IT*/338

    CSE/IT

  • ContThe transport layer also determines what type of service to provide the session layer, and ultimately, the users of the network: The most popular type of transport connection is an error-free point-to-point channel that delivers messages or bytes in the order in which they were sent.However, other possible kinds of transport service are transport of isolated messages with no guarantee about the order of delivery, andbroadcasting of messages to multiple destinations.

    The type of service is determined when the connection is established.

    CSE/IT*/338

    CSE/IT

  • OSI The Transport LayerThe transport layer is a true end-to-end layer, from source to destination. In other words, a program on the source machine carries on a conversation with a similar program on the destination machine, using the message headers and control messages. In the lower layers, the protocols are between each machine and its immediate neighbors, and not by the ultimate source and destination machines (which may be separated by many routers). The difference between layers 1 through 3, which are chained, and 4 through 7, which are end-to-end, is illustrated in Fig. 4.In addition to multiplexing several message streams onto one channel, the transport layer must take care of establishing and deleting connections across the network. This requires some kind of naming mechanism, so that a process on one machine has a way of describing with whom it wishes to converse.There must also be a mechanism to regulate the flow of information, so that a fast host cannot overrun a slow one flow control.CSE/IT*/338

    CSE/IT

  • OSI The Session LayerThe session layer allows users on different machines to establish sessions between them. A session allows ordinary data transport, as does the transport layer, but it also provides enhanced services useful in some applications. A session might be used to allow a user to log into a remote timesharing system or to transfer a file between two machines. One of the services of the session layer is to manage dialogue control. Session can allow traffic to go in both directions at the same time, or in only one direction at a time. If traffic goes one way only, the session layer can help keep track of whose turn it is.A related session service is token management. For some protocols, it is essential that both sides do not attempt the same operation at the same time. To manage these activities tokens are exchanged. Only one side, holding the token, can perform the critical operation.

    CSE/IT*/338

    CSE/IT

  • OSI The Session LayerAnother session service is synchronization. Consider the problems that might occur when trying to do a 2-hour file transfer between two machines with 1-hour mean time between crashes. After each transfer was aborted, the whole transfer would have to start over again and would probably fail again the next time as well.

    To eliminate this problem, the session layer provides a way to insert checkpoints into the data stream so that after a crash, only the data transferred after the last checkpoint have to be repeated.

    CSE/IT*/338

    CSE/IT

  • OSI The Presentation LayerThe presentation layer performs certain functions that are requested sufficiently often to warrant finding a general solution for them, rather than letting each user solve the problems.In particular, unlike all the lower layers, which are just interested in moving bits reliably from here to there, the presentation layer is concerned with the syntax and semantics of the information transmitted.A typical example of a presentation service is encoding data in a standard agreed upon way. Most user programs do not exchange random binary bit srings. They exchange thins such as peoples names, dates, amounts of money, and invoices. These items are represented as character strings, integers, floating-point numbers, and data structures composed of several simpler items.

    CSE/IT*/338

    CSE/IT

  • OSI The Presentation LayerIn order to make it possible for computers with different representations to communicate, the data structures to be exchanged can be defined in an abstract way, along with a standard encoding to be used on the wire.

    The presentation layer manages these abstract data structures and converts from the representation used inside the computer to the network standard representation and back.

    CSE/IT*/338

    CSE/IT

  • OSI The Application LayerThe application layer contains a variety of protocols that are commonly needed. For example, there are hundreds of incompatible terminal types in the world. Consider a full screen editor that is supposed to work over a network with many different terminal types (each may have different screen layouts, keys for inserting ad deleting text, moving the cursor, etc.)To handle each terminal type, a network virtual terminal can be written. Next, a piece of software must be written to map the functions of the virtual network terminal onto the functions of the real terminal.Another application layer function is file transfer. If two machines have different files systems for example, the files may have incompatible naming conventions, ways to represent text lines, etc. Handling these incompatibilities belongs to the application layer.CSE/IT*/338

    CSE/IT

  • OSI The Application LayerIn summary: the application layer makes network services available to applications (i.e. programs)

    It also hides all other layers from programmers, and makes using a network application transparent to the userCSE/IT*/338

    CSE/IT

  • Data Transmission in the OSI ModelCSE/IT*/338

    CSE/IT

  • Data Transmission in the OSI ModelThe sending process has some data it wants to send to the receiving process. It gives the data to the application layers, which then attaches the application header AH to the front of it and gives the resulting item to the presentation layer.The presentation layer may transform this item in various ways, and possibly add a header to the front, giving the result to the session layer. It is important to note that the presentation layer is not aware which portion of the item is AH and which is user data.This process is repeated until the data reach the physical layer, where they are actually transmitted to the receiving machine.

    CSE/IT*/338

    CSE/IT

  • Data Transmission in the OSI ModelThe key idea throughout is that although actual data transmission is vertical in Fig. 2., each layer is programmed as though it were horizontal. (each layer thinks it is communicating directly (horizontally) with its peer on the other machine)

    For example, when the sending transport layer gets a message from the session layer, it attaches a transport header (with information to be used by the receiving transport layer) and sends it to the receiving transport layer. From its point of view, the fact that it must actually hand the message to the network layer on its own machine is an unimportant technicality.

    CSE/IT*/338

    CSE/IT

  • The TCP/IP Reference ModelLet us now turn from the OSI reference model to the reference model used in the grandparent of all computer networks, the ARPANET, and its successor, the worldwide Internet. Although TCP/IP was originally intended for the ARPANET, and currently used in the Internet, it has become so popular that many local networks (LANs) are using it as their protocols as well. Thus, we would like to review this model as well.The ARPANET was a research network sponsored by the DoD (U.S. Department of Defense). It eventually connected hundreds of universities and government installations using leased telephone lines. When satellite and radio networks were added later, the existing protocols had trouble internetworking with them, so a new reference architecture was needed.

    CSE/IT*/338

    CSE/IT

  • The TCP/IP Reference ModelThis architecture later became known as the TCP/IP Reference model, after its two primary protocols. It was first defined in 1974, and updated in 1985 and 1988.Given the DoDs worry that some of its precious hosts, routers, and internetworking gateways might get blown to pieces at a moments notice, another major goal was that the network be able to survive loss of subnet hardware, with existing conversations not being broken off. In other words, DoD wanted connections to remain intact as long as the source and destination machines were functioning even if some of the machines or transmission lines in between were suddenly put out of operation. Furthermore, a flexible architecture was needed, since applications with divergent requirements were envisioned, ranging from transferring files to real-time speech transmission.

    CSE/IT*/338

    CSE/IT

  • TCP/IP The Internet LayerAll these requirements lead to the choice of a packet-switching network based on a connectionless internetwork layer. This layer, called the internet layer, is the glue that holds the whole architecture together.Its job is to permit hosts to inject packets into any network and have them travel independently to the destination (potentially on a different network). They may even arrive in a different order than they were sent, in which case it is the job of higher layers to rearrange them, if in-order delivery is desired. Note that internet is used here in a generic sense, even though this layer is present in the Internet.

    CSE/IT*/338

    CSE/IT

  • TCP/IP The Internet LayerThe analogy here is with the mail system. A person can drop a sequence of international letters into a mail box in one country, and most of them will be delivered to the correct address in the destination country. Probably the letters will travel through one or more international mail gateways along the way, but this is transparent to the users. Furthermore, the letters may arrive out of order, and each country (i.e. network) has its own stamps, preferred envelope sizes, and delivery rules, which is also hidden from the users.The internet layer defines an official packet format and protocol called IP (Internet Protocol). The job of the internet layer is to deliver IP packets where they are supposed to go. Packet routing is clearly the major issue here, as is avoiding congestion. For these reasons, we can say that the TCP/IP internet layer is very similar to the OSI network layer. Fig. 3. shows the correspondence.

    CSE/IT*/338

    CSE/IT

  • TCP/IP The Internet LayerThe TCP/IP reference modelCSE/IT*/338

    OSI7Application6Presentation5Session4Transport3Network2Data Link1Physical

    TCP/IPApplication

    TransportInternetHost-to-network

    CSE/IT

  • TCP/IP The Transport LayerThe layer above the internet layer in the TCP/IP model is now usually called the transport layer. It is designed to allow peer entities on the source and destination hosts to carry on a conversation, the same as the OSI transport layer. Two end-to-end protocols have been defined here:TCP (Transmission Control Protocol) is a reliable connection-oriented protocol that allows a byte stream originating on one machine to be delivered without errors on any other machine in the internet. It fragments the incoming byte stream into discrete messages and passes each one onto the internet layer. At the destination, the receiving TCP process reassembles the received messages into the output stream. TCP also handles flow control to make sure a fast sender cannot swamp a slow receiver with more messages than it can handle.

    CSE/IT*/338

    CSE/IT

  • TCP/IP The Transport LayerUDP (User Datagram Protocol) is an unreliable, connectionless protocol for applications that do not want TCPs sequencing or flow control and wish to provide their own. It is also widely used for one-shot, client-server type request-reply queries and applications in which fast delivery is more important than accurate delivery, such as transmitting speech or video. The relation of IP, TCP and UDP is shown on Fig. 4. Since this model was developed, IP has been implemented on many other networks.

    Protocols and networks in the TCP/IP model initially.CSE/IT*/338

    CSE/IT

  • TCP/IP The Application LayerThe TCP/IP model does not have session or presentation layers. No need for them was perceived, so they were not included. Experience with the OSI model has proven this view correct: they are of little use to most applications. On top of the transport layer is the application layer. It contains all the higher-level protocols. The early ones , included:virtual terminal (TELNET) allows a user on one machine to log into a distant machine and work therefile transfer (FTP) and provides a way to move data efficiently from one machine to anotherelectronic mail (SMTP)

    CSE/IT*/338

    CSE/IT

  • TCP/IP The Application LayerMany other protocols have been added to these over the years, such as: the DNS (Domain Name Service) for mapping host names onto their network addressesNNTP (Network News Transfer Protocol) for moving news articles aroundHTTP (Hypertext Transfer Protocol) used for fetching pages on the World Wide Web, and many others

    CSE/IT*/338

    CSE/IT

  • A comparison of OSI and TCP/IPThe OSI and TCP/IP reference models have much in common. Both are based on the concept of a stack of independent protocols. Also, the functionality of the layers is roughly similar.Despite the fundamental similarities, the two models also have many differences. Probably the biggest contribution of the OSI model is to make the distinction between the Services, Interfaces, and Protocols explicit.These ideas fit very nicely with modern ideas about object-oriented programming. An object, like a layer, has a set of methods (operations) that can be invoked outside the object. The semantics of these methods define the set of services that the object offers.

    CSE/IT*/338

    CSE/IT

  • A comparison of OSI and TCP/IPThe OSI reference model was devised before the protocols were invented.

    With the TCP/IP the reverse is true: the protocols came first, and the model was really just a description of the existing protocols. There was no problem with the protocols fitting the model: they fit perfectly. The only trouble was that the model did not fit any other protocol stacks.

    CSE/IT*/338

    CSE/IT

  • A comparison of OSI and TCP/IPIn summary: despite its problems, the OSI model (minus the session and presentation layers) has proven to be exceptionally useful for discussing computer networks. In contrast, the OSI protocols have not become popular.The opposite is true for TCP/IP: the model is practically nonexistent, but the protocols are widely used. Therefore, we would like to think of a modified OSI model and concentrate on the TCP/IP and related protocols and use a hybrid model, shown on Fig, as a framework.CSE/IT*/338

    CSE/IT

  • HTTP vs HTMLHTML: hypertext markup languageDefinitions of tags that are added to Web documents to control their appearanceHTTP: hypertext transfer protocolThe rules governing the conversation between a Web client and a Web server

    CSE/IT*/338

    CSE/IT

  • What is a protocol?In diplomatic circles, a protocol is the set of rules governing a conversation between people

    We have seen that the client and server carry on a machine-to-machine conversation

    A network protocol is the set of rules governing a conversation between a client and a server

    There are many protocols, HTTP is just oneCSE/IT*/338

    CSE/IT

  • I would like to open a connection

    GET

    Display responseClose connection

    OK

    Send page or error message

    OKClientServerAn HTTP conversationCSE/IT*/338

    CSE/IT

  • An HTTP ExampleThe message requesting a Web page must begin with the work GET and be followed by a space and the location of a file on the server, like this:GET /fac/lpress/shortbio.htm The protocol spells out the exact message format, so any Web client can retrieve pages from any Web server.CSE/IT*/338

    CSE/IT

  • Network protocolsThe details are only important to developers.The rules are defined by the inventor of the protocol may be a group or a single person.The rules must be precise and complete so programmers can write programs that work with other programs.The rules are often published as an RFC along with running client and server programs.The HTTP protocol used for Web applications was invented by Tim Berners Lee.CSE/IT*/338

    CSE/IT

  • Concept: DNS Names 1

    The namespace needs to be made hierarchical to be able to scale.The idea is to name objects based on location (within country, set of organizations, set of companies, etc)unit within that location (company within set of company, etc)object within unit (name of person in company)CSE/IT*/338

    CSE/IT

  • How names appear in the DNSFully Qualified Domain Name (FQDN)WWW.RIPE.NET.labels separated by dots

    DNS provides a mapping from FQDNs to resources of several types

    Names are used as a key when fetching data in the DNS

    CSE/IT*/338

    CSE/IT

  • Concept: Resource Records The DNS maps names into data using Resource Records.

    More detail laterwww.ripe.net. A 10.10.10.2Address ResourceResource RecordCSE/IT*/338

    CSE/IT

  • Concept: DNS Names 3

    Domain names can be mapped to a tree.

    New branches at the dots

    No restriction to the amount of branches.

    CSE/IT*/338

    CSE/IT

  • Concept: DomainsDomains are namespacesEverything below .com is in the com domain.Everything below ripe.net is in the ripe.net domain and in the net domain.CSE/IT*/338

    CSE/IT

  • What is SecurityDictionary.com says:1. Freedom from risk or danger; safety.2. Freedom from doubt, anxiety, or fear; confidence.3. Something that gives or assures safety, as:1. A group or department of private guards: Call building security if a visitor acts suspicious.2. Measures adopted by a government to prevent espionage, sabotage, or attack.3. Measures adopted, as by a business or homeowner, to prevent a crime such as burglary or assault: Security was lax at the firm's smaller plant.etc.CSE/IT*/338

    CSE/IT

  • Why do we need security?Protect vital information while still allowing access to those who need itTrade secrets, medical records, etc.Provide authentication and access control for resourcesEx: AFSGuarantee availability of resourcesEx: 5 9s (99.999% reliability)CSE/IT*/338

    CSE/IT

  • ContFinancial institutions and banksInternet service providersPharmaceutical companiesGovernment and defense agenciesContractors to various government agenciesMultinational corporationsCSE/IT*/338

    CSE/IT

  • Common security attacksFinding a way into the networkFirewallsExploiting software bugs, buffer overflowsIntrusion Detection SystemsDenial of ServiceIngress filtering, IDSTCP hijackingIPSecPacket sniffingEncryption (SSH, SSL, HTTPS)Social problemsEducationCSE/IT*/338

    CSE/IT

  • Section -CCSE/IT*/338

    CSE/IT

  • Overview of CC is developed by Dennis RitchieC is a structured programming languageC supports functions that enables easy maintainability of code, by breaking large file into smaller modulesComments in C provides easy readabilityC is a powerful language

    CSE/IT*/338

    CSE/IT

  • Program structureA sample C Program

    #includeint main(){--other statements}CSE/IT*/338

    CSE/IT

  • Header filesThe files that are specified in the include section is called as header fileThese are precompiled files that has some functions defined in themWe can call those functions in our program by supplying parametersHeader file is given an extension .hC Source file is given an extension .cCSE/IT*/338

    CSE/IT

  • Main functionThis is the entry point of a programWhen a file is executed, the start point is the main functionFrom main function the flow goes as per the programmers choice.There may or may not be other functions written by user in a programMain function is compulsory for any c programCSE/IT*/338

    CSE/IT

  • Writing the first program#includeint main(){printf(Hello);return 0;}

    This program prints Hello on the screen when we execute itCSE/IT*/338

    CSE/IT

  • Running a C ProgramType a programSave itCompile the program This will generate an exe file (executable)Run the program (Actually the exe created out of compilation will run and not the .c file)In different compiler we have different option for compiling and running. We give only the concepts.CSE/IT*/338

    CSE/IT

  • Comments in CSingle line comment// (double slash)Termination of comment is by pressing enter keyMulti line comment/*. .*/This can span over to multiple linesCSE/IT*/338

    CSE/IT

  • Data types in CPrimitive data typesint, float, double, charAggregate data typesArrays come under this categoryArrays can contain collection of int or float or char or double dataUser defined data typesStructures and enum fall under this category.CSE/IT*/338

    CSE/IT

  • VariablesVariables are data that will keep on changingDeclaration ;int a;Definition=;a=10;Usage

    a=a+1;//increments the value of a by 1CSE/IT*/338

    CSE/IT

  • Variable names- RulesShould not be a reserved word like int etc..Should start with a letter or an underscore(_)Can contain letters, numbers or underscore. No other special characters are allowed including spaceVariable names are case sensitiveA and a are different.CSE/IT*/338

    CSE/IT

  • Input and OutputInputscanf(%d,&a);Gets an integer value from the user and stores it under the name aOutputprintf(%d,a)Prints the value present in variable a on the screen

    CSE/IT*/338

    CSE/IT

  • For loopsThe syntax of for loop isfor(initialisation;condition checking;increment){set of statements}Eg: Program to print Hello 10 timesfor(I=0;I
  • While loopThe syntax for while loopwhile(condn){statements;}Eg:a=10;while(a != 0)Output: 10987654321{printf(%d,a);a--;}CSE/IT*/338

    CSE/IT

  • Do While loopThe syntax of do while loopdo{set of statements}while(condn);

    Eg:i=10;Output:do10987654321{printf(%d,i);i--;}while(i!=0)CSE/IT*/338

    CSE/IT

  • Conditional statementsif (condition) {stmt 1;//Executes if Condition is true}else{stmt 2;//Executes if condition is false}CSE/IT*/338