Showing posts with label Regulation 2013. Show all posts
Showing posts with label Regulation 2013. Show all posts

Thursday, February 25, 2016

Implementation of Stop and Wait Protocol and Sliding Window Protocol

AIM: To write a java program to perform sliding window.

ALGORITHM:
1.Start the program.
2.Get the frame size from the user
3.To create the frame based on the user request.
 4.To send frames to server from the client side.
5.If your frames reach the server it will send ACK signal to client otherwise it will send NACK signal to client.
6.Stop the program

Program :
import java.net.*; import java.io.*; import java.rmi.*;

public class slidsender

{

public static void main(String a[])throws Exception

{

ServerSocket ser=new ServerSocket(10); Socket s=ser.accept();

DataInputStream in=new DataInputStream(System.in); DataInputStream in1=new DataInputStream(s.getInputStream()); String sbuff[]=new String[8];

PrintStream p;

int sptr=0,sws=8,nf,ano,i; String ch;

do

{

p=new PrintStream(s.getOutputStream()); System.out.print("Enter the no. of frames : "); nf=Integer.parseInt(in.readLine()); p.println(nf);

if(nf<=sws-1)

{

System.out.println("Enter "+nf+" Messages to be send\n"); for(i=1;i<=nf;i++)

{

sbuff[sptr]=in.readLine();
p.println(sbuff[sptr]);

sptr=++sptr%8;

}

sws-=nf;

System.out.print("Acknowledgment received"); ano=Integer.parseInt(in1.readLine()); System.out.println(" for "+ano+" frames"); sws+=nf;

}

else

{

System.out.println("The no. of frames exceeds window size"); break;

}

System.out.print("\nDo you wants to send some more frames : "); ch=in.readLine(); p.println(ch);

}

while(ch.equals("yes"));

s.close();

}

}


RECEIVER PROGRAM


import java.net.*; import java.io.*; class slidreceiver

{

public static void main(String a[])throws Exception

{

Socket s=new Socket(InetAddress.getLocalHost(),10); DataInputStream in=new DataInputStream(s.getInputStream()); PrintStream p=new PrintStream(s.getOutputStream());

int i=0,rptr=-1,nf,rws=8; String rbuf[]=new String[8]; String ch; System.out.println(); do

{

nf=Integer.parseInt(in.readLine()); if(nf<=rws-1)

{



for(i=1;i<=nf;i++)

{

rptr=++rptr%8;

rbuf[rptr]=in.readLine();

System.out.println("The received Frame " +rptr+" is : "+rbuf[rptr]);

}

rws-=nf; System.out.println("\nAcknowledgment sent\n"); p.println(rptr+1); rws+=nf; }

else break;

ch=in.readLine();

}

while(ch.equals("yes"));

}

}


OUTPUT:


//SENDER OUTPUT

Enter the no. of frames : 4 Enter 4 Messages to be send


hiii how r u

i am fine

how is evryone

Acknowledgment received for 4 frames


Do you wants to send some more frames : no


//RECEIVER OUTPUT


The received Frame 0 is : hiii

The received Frame 1 is : how r u

The received Frame 2 is : i am fine


The received Frame 3 is : how is everyone

Sunday, December 6, 2015

THEORY OF COMPUTATION



  1. What is a : (a) String (b) Regular language
A string x is accepted by a Finite Automaton M=(Q, Σ, δ.q0,F) if δ (q0,x)=p, for some p in F.FA accepts a string x if the sequence of transitions corresponding to the symbols of x leads from the start state to accepting state.
The language accepted by M is L(M) is the set {x | _(q0,x) is in F}. A language is regular if it is accepted by some finite automaton.

  1. Define: (i) Finite Automaton(FA) (ii)Transition diagram             (Univ)
            FA consists of a finite set of states and a set of transitions from state to state that occur on input symbols chosen from an alphabet. Finite Automaton is denoted by a 5- tuple(Q,Σ, δ,q0,F),
where Q is the finite set of states ,
Σ is a finite input alphabet,
q0 in Q is the initial state,
F is the set of final states and
δ is the transition mapping function Q * Σ to Q.

Transition diagram is a directed graph in which the vertices of the graph correspond to the states of FA. If there is a transition from state q to state p on input a, then there is an arc labeled ‘ a ‘ from q to p in the transition diagram.

  1. What are the applications of automata theory?  (Univ) 
_ In compiler construction.
_ In switching theory and design of digital circuits.
_ To verify the correctness of a program.
_ Design and analysis of complex software and hardware systems.
_ To design finite state machines such as Moore and mealy machines.

  1. What are the components of Finite automaton model?
The components of FA model are Input tape, Read control and finite control.
(a)The input tape is divided into number of cells. Each cell can hold one i/p symbol
(b)The read head reads one symbol at a time and moves ahead.
(c)Finite control acts like a CPU. Depending on the current state and input symbol read from the input tape it changes state.

  1. Differentiate NFA and DFA. (Univ)
NFA or Non Deterministic Finite Automaton is the one in which there exists many paths for a specific input from current state to next state. NFA can be used in theory of computation because they are more flexible and easier to use than DFA .
Deterministic Finite Automaton is a FA in which there is only one path for a specific input from current state to next state. There is a unique transition on each input symbol.(Write examples with diagrams).

  1. Give the examples/applications designed as finite state system.
               Text editors and lexical analyzers are designed as finite state systems. A  lexical analyzer scans the symbols of a program to locate strings corresponding to identifiers, constants etc, and it has to remember limited amount of information.

  1.  Define automaton. (Univ)
Automaton is a abstact computing device. It is a mathematical model of a system,with discrete inputs,outputs,states and set of tranitions from state to state that occurs on input symbols from alphabet  Σ.

  1. what is the principle of  mathematical induction. (Univ)
Let P(n) be a ststement about a non negative integer n. Then the principle of  mathematical induction is that P(n) follows from
(i)                 P(1) and
(ii)               P(n-1) implies P(n) for all n>1.
Condition(i) is called the basis step and condition (ii) is called the inductive step. P(n-1) is called the induction hypothesis.

  1.  List any four ways of theorem proving  (Univ)
(i)                 Deductive
(ii)               If and only if
(iii)             Induction
(iv)             Proof by contradiction.
  1.  Define TOC
                  TOC describes the basic ideas and models underlying computing. TOC suggests various abstract models of computation, represented mathematically.
 

Wednesday, November 4, 2015

Disadvantages in the File System

·         Data Redundancy
·         Data Inconsistency
·         Difficulty in Accessing Data
·         Data Isolation
·         Integrity Problems
·         Atomicity Problem
·         Concurrent Access anomalies
·         Security Problems
Data Redundancy
Data Redundancy is same information’s are duplicated in several files. This makes data redundancy.
Data Inconsistency
Data Inconsistency means different copies of the same data are not matching. This  occurs as the result of  update operations that are not updating the same data stored at different places.
Example: Address Information of a customer is recorded differently in  different files.
Difficulty in Accessing Data
It is not easy to retrieve information using a conventional file processing system. Convenient and efficient information retrieval is almost impossible using conventional file processing system. 
Data Isolation
Data are scattered in various files, and the files may be in different format, writing new application program to retrieve data is difficult.
Integrity Problems
The data values may need to satisfy some integrity constraints.
 For example  the balance field Value must be greater than 5000. We have to handle this through program code in file processing systems. But in database we can declare the integrity constraints along with definition itself.

Tuesday, November 3, 2015

Purpose and functions of Database Management Systems

·         Data redundancy is found- the presence of duplicate data in multiple data files
e.g. Customer Name, NI number, Address is present in several different files on several different systems. Errors are generated, time entering data is wasted.
·         Data inconsistency will become a problem
 e.g. information is duplicated in each system and may be updated in most systems but not necessarily in all – the savings account and loan account may have different addresses for a particular customer.
·         Lack of data independence.
In the bank imagine cases where any change in data format or structure requires a change in all the programs that access the data.
e.g. effort required to change from 3-digit STD to 4-digit STD may be very difficult.
·         Data lacks integrity
This is the quality by which information from the system can be trusted.
·         Lack of flexibility
Creating reports
e.g. in this system a summary of account balances in each separate account would require separate reports for each open account or cutting and pasting into a word processor file – not a satisfactory state of affairs.
·          Data not shareable. Similarly if different departments want to access data this would be very awkward.

Monday, November 2, 2015

DBMS

11. What are a block and a block number?
A block is a contiguous sequence of sectors from a single track of one platter. Each request
specifies the address on
the disk to be referenced. That address is in the form of a block number.
12. What are called journaling file systems?
File systems that support log disks are called journaling file systems.
13. What is the use of RAID?
A variety of disk-organization techniques, collectively called redundant arrays of independent
disks are used to improve the performance and reliability.
14. Explain how reliability can be improved through redundancy?
The simplest approach to introducing redundancy is to duplicate every disk. This technique is called mirroring or shadowing. A logical disk then consists of two physical disks, and write is
carried out on both the disk. If one of the disks fails the data can be read from the other. Data will be lost if the second disk fails before the first fail ed disk is repaired.
15. What is called mirroring?
The simplest approach to introducing redundancy is to duplicate every disk. This technique is called mirroring or shadowing.

Sunday, November 1, 2015

TRENDS IN DATABASE TECHNOLOGY

1. What are the advantages and disadvantages of indexed sequential file? APRIL/MAY-
2011
The advantage of ordering records in a sequential file according to a key is that you can then
search the file more quickly. If you know the key value that you want, you can use one of the relatively fast searches. The disadvantage is that when you insert, you need to rewrite at least everything after the insertion point, which makes inserts very expensive unless they are done at the end of the file. An indexed file approach keeps a (hopefully) small part of each row, and some kind of "pointer" to the row's location within the data file. This allows a search to use the index, which is ordered by the index and (again hopefully) much smaller and therefore much faster than scanning the entire data file for the indexed data.
2. What is database tuning? APRIL/MAY-2011
Database tuning describes a group of activities used to optimize and homogenize the
performance of a database. It usually overlaps with query tuning, but refers to design of the database files, selection of the database management system (DBMS), operating system and CPU the DBMS runs on.
3. Give the measures of quality of a disk.
Capacity
Access time
Seek time
Data transfer rate
Reliability
Rotational latency time.
Cheaper than disk Expensive when compared with disk
5. What are the types of storage devices?
Ø Primary storage
Ø Secondary storage
Ø Tertiary storage

Saturday, October 31, 2015

DBMS

31. Define page.
The database is partitioned into some number of fixed-length blocks, which are referred to as
pages.
32. Explain current page table and shadow page table.
The key idea behind the shadow paging technique is to maintain two page tables during the life
of the transaction: the current page table and the shadow p age table. Both the page tables are identical when the transaction starts. The current page table may b e changed when a transaction performs a write operation.
33. What are the drawbacks of shadow-paging technique?
Ø Commit Overhead
Ø Data fragmentation
Ø Garbage collection
34. Define garbage collection.
Garbage may be created also as a side effect of crashes. Periodically, it is necessary to find all the garbage pages and to add them to the list of free pages. This process is called garbage
collection.
35. Differentiate strict two phase locking protocol and rigorous two phase locking protocol.
In strict two phase locking protocol all exclusive mode locks taken by a transaction is held