III-it Cnuml Manual

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 86

Shri Vishnu Engineering College for Women

Vishnupur, Bhimavaram - 534202

LABORATORY MANUAL
III B.Tech II Sem

Computer Networks & CASE Tools Lab

DEPARTMENT OF

INFORMATION TECHNOLOGY

OUR MISSION TO PLAY A KEY ROLE IN THE DEVELOPMENT OF A DISCIPLINED KNOWLEDGE SOCIETY

Regd. No: ____________________

SUMMARY OF WORK-DONE Exercise No. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Marks Date


Lab (5) Record (5) Viva (5) Total (15)

Signature

Total Marks Awarded : ___________

Signature of the Teacher

Signature of HOD

Computer Networks
INDEX
S.No 1 2 3 4 5 6 7 8 Topic Data Link Layer Framing Methods CRC Polynominals Dijikstrs Algorithm Distance Vector Routing Algorithm Broadcast Tree from Subnet of Host SDES Encryption Break the DES Coding RSA Encryption and Decryption Page No 1 7 12 17 20 24 31 32

CASE Tools
INDEX
S.No 1 2 3 4 5 6 7 8 9 10 11 UML Introduction UML Architecture Primary Elements of UML Identifying Classes Relationship among classes Using Rational Rose to create diagrams Use case & Class Diagrams State Chart, Activity & Sequence Diagrams Deployment & Package Diagrams Object Diagram Solution for Online Book Store Analysis and Design Topic Page No 37 40 43 45 47 51 54 55,56 57 58 60

Computer Networks

Computer Networks Lab Manual Ex. No: 01

DATA LINK LAYER FRAMING METHODS


AIM To write a program for implementing the Data Link Layer framing methods such as character, character stuffing and bit stuffing DESCRIPTION

Data Link Layer Functions


Concerned with reliable, error-free and efficient communication between adjacent machines in the network through the following functions: 1 Data Framing: The term frame refers to a small block of data used in a specific network. The data link layer groups raw data bits to/from the physical layer into discrete frames with error detection/correction code bits added. Framing methods: Character count. Starting and ending characters, with character stuffing. Starting and ending flags with bit stuffing. Physical layer coding violations. 2 Error Detection/Correction: Error Detection: Include enough redundant information in each frame to allow the receiver to deduce that an error has occurred, but not which error and to request a retransmission. Uses error-detecting codes. Error Correction: Include redundant information in the transmitted frame to enable the receiver not only to deduce that an error has occurred but also correct the error. Uses error-correcting codes. 3 Services to the network layer: Unacknowledged connectionless service: Independent frames sent without having the destination acknowledge them. Suitable for real-time data such as speech and video where transmission speed is more important than absolute reliability. Utilized in most LANS. Acknowledged connectionless service: Each frame sent is acknowledged by the receiver. Acknowledgment at the layer level is not essential but provides more efficiency than acknowledgment at higher layers (transport) which is done only for the whole message.

Department Information Technology

-1-

Computer Networks Lab Manual A lost acknowledgment may cause a frame to be sent and received several times.

Acknowledged connection-oriented service: The sender and receiver establish a connection before any data transmission. The message is broken into numbered frames. The data link guarantees that each frame sent is received exactly once and in the right order. 4 Flow control Protocols to control the rate the sender transmits frames at a rate acceptable to the receiver, and the ability to retransmit lost or damaged frames. This insures that slow receivers are not swamped by fast senders and further aids error detection/correction. Several flow control protocols exist, but all essentially require a form of feedback to make the sender aware of whether the receiver can keep up. Stop-and-wait Protocols: A positive acknowledgment frame is send by the receiver to indicate that the frame has been received and to indicate being ready for the next frame. Positive Acknowledgment with Retransmission (PAR); uses timeouts Sliding Window Protocols: Data frames and acknowledgement frames are mixed in both directions. Frames sent contain sequence numbers Timeouts used to initiate retransmission of lost frames.

Placement of The Data Link Protocol

Data Link Layer: Framing Data Link Layer: Framing 1. The character count method:
The frame header includes the count of characters in the frame A transmission error can cause an incorrect count causing the source and destination to get out of synchronization Rarely used in actual data link protocols

Department Information Technology

-2-

Computer Networks Lab Manual

A character stream with no errors

A character stream with errors

Using Starting and ending characters, with character stuffing:


Each frame starts with the ASCII character sequence DLE (Data Link Escape) and STX (Start of TeXt) and ends with DLE ETX (End of TeXt) When binary data is transmitted where (DLE STX or DLE ETX) can occur in data, character stuffing is used (additional DLE is inserted in the data). Limited to 8-bit characters and ASCII.
Network Layer Data at the sender

Data after character stuffing by the Data Link Layer at the sender

Network Layer Data at the Receiver

2. Bit-Oriented Using Start/End Flags:


a. Each frame begins and ends with 01111110 b. Bit stuffing: After each five consecutive ones in a data a zero is stuffed c. Stuffed zero bits are removed by the data link layer at receiving end.

The Original Data Data appearing on the line after bit stuffing

Data received after de stuffing


Department Information Technology -3-

Computer Networks Lab Manual PROCEDURES Step-1: Print the menu as follows Character count -1 Character stuffing 2 Bit stuffing 3 Exit -4 Step-2: Read the Choice Step-3: If the choice is 1, do the following Read the Character sequence Use random( ) function for frame length If random() function returns 5 then Take the first 4 characters from the character stream and print the frame (for example: if first 4 characters are a,b,c,d then the frame is 5 a b c d) Repeat the above 2 steps until the character sequence ends

Step-4: If the choice is 2, do the following Read the data units with delimiters DLE STX and DLE ETX Scan the data for any occurrences of delimiters like DLE If DLE found in the sequence, then stuff the another DLE Repeat the above 2 step until data stream ends.

Step-5: If the choice is 3, do the following Read the bit stream Scan the bit stream for continuous 6 1s If it is found then insert 0 after 5th 1 Finally print the bit stream with delimiter 0 1 1 1 1 1 1 0 (i.e. 0 1 1 1 1 1 1 1 0 bit stream 0 1 1 1 1 1 1 0 ) Step-6: If the choice is 4 , then call exit() function.

Implementation using C PROGRAM FOR CHARACTER STUFFING


#include<stdio.h> #include<conio.h> #include<string.h> #include<process.h> void main() { int i=0,j=0,n,pos; char a[20],b[50],ch; clrscr(); printf("enter string\n"); scanf("%s",&a); n=strlen(a); printf("enter position\n"); scanf("%d",&pos);

Department Information Technology

-4-

Computer Networks Lab Manual


if(pos>n) { printf("invalid position, Enter again :"); scanf("%d",&pos); } printf("enter the character\n"); ch=getche(); b[0]='d'; b[1]='l'; b[2]='e'; b[3]='s'; b[4]='t'; b[5]='x'; j=6; while(i<n) { if(i==pos-1) { b[j]='d'; b[j+1]='l'; b[j+2]='e'; b[j+3]=ch; b[j+4]='d'; b[j+5]='l'; b[j+6]='e'; j=j+7; } if(a[i]=='d' && a[i+1]=='l' && a[i+2]=='e') { b[j]='d'; b[j+1]='l'; b[j+2]='e'; j=j+3; } b[j]=a[i]; i++; j++; } b[j]='d'; b[j+1]='l'; b[j+2]='e'; b[j+3]='e'; b[j+4]='t'; b[j+5]='x'; b[j+6]='\0'; printf("\nframe after stuffing:\n"); printf("%s",b); getch(); } INPUT: enter string: asdlefgh enter position: 8 invalid position,enter again: 3 enter the character: k OUTPUT: frame after stuffing: dlestx as dle k dle dle dlefgh dleetx

Department Information Technology

-5-

Computer Networks Lab Manual PROGRAM FOR BIT STUFFING


#include<stdio.h> #include<conio.h> #include<string.h> void main() { int a[20],b[30],i,j,k,count,n; clrscr(); printf("Enter frame length:"); scanf("%d",&n); printf("Enter input frame (0's & 1's only):"); for(i=0;i<n;i++) scanf("%d",&a[i]); i=0; count=1; j=0; while(i<n) { if(a[i]==1) { b[j]=a[i]; for(k=i+1;a[k]==1 && k<n && count<5;k++) { j++; b[j]=a[k]; count++; if(count==5) { j++; b[j]=0; } i=k; }} else { b[j]=a[i]; } i++; j++; } printf("After stuffing the frame is:"); for(i=0;i<j;i++) printf("%d",b[i]); getch(); } INPUT: Enter frame length: 10 Enter input frame (0's & 1's only): 1 0 1 0 1 1 1 1 1 1 OUTPUT: After stuffing the frame is: 1 0 1 0 1 1 1 1 1 0 1

Department Information Technology

-6-

Computer Networks Lab Manual

Ex. No: 02

CRC POLYNOMIALS
AIM To write a program for implementing on a data set characters the three CRC polynomials CSR12, CRC16 and CRC CCIP DESCRIPTION

Data Link Layer: Error Detection/Correction


. Simplest error detection : Parity bits and checksum (sum of 1s in Data). . Error-detecting and -correcting codes: m data bits + r redundant bits added. n = m + r transmitted in frame. Only 2m code words out of possible 2m+r words are legal. The Hamming distance --minimum number of positions any two legal code words differ-- of a code defines its error detection/correction ability. To detect d errors code Hamming distance = d + 1 To correct d errors code Hamming distance = 2d + 1 Some codes are more suitable to correct burst errors rather than isolated errors. Polynomial codes: Cyclic Redundancy Check (CRC) Codes, are characterized by a generating polynomial G(X)

Cyclic Redundancy Check (CRC)


Based on polynomial arithmetic over finite field. View m-bit string a m-1a m-2 . . . a0 as a polynomial of degree m-1: M(x) = a m-1 x m-1 + a m-2 x m-2 + . + a0 Select a generating polynomial G(x) of degree r. Let R(x) be the remainder of xr M(x) / G(x) The code word T(x) of length m + r bit generated is then given by: T(x) = xr M(x) - R(x) Assume code word T(x) is transmitted, but T(x) + E(x) arrives at the receiver: If E(x) = 0 then no transmission errors and T(x)/G(x) = 0 If E(x) 0 then transmission error(s) occurred and: [T(x) + E(x)] / G(x) 0

Calculation of Polynomial Code (CRC) Checksum


1. For degree of generating polynomial G(x) = r , append r zero bits to low-order of frame. The frame now has m+r bits. 2. Divide the bit string corresponding to G(X) into the bit string xrM(x) mod(2) 3. Subtract the remainder R(x) from the bit string xrM(x) mod(2)

Department Information Technology

-7-

Computer Networks Lab Manual

Frame: 1 1 0 1 0 1 1 0 1 1 Generator: 1 0 0 1 1 G(X) = X4 + X + 1 Message after appending four 0s: 1101011011 000 0 Remainder: 1110 Transmitted Frame: 11010110111110

Hardware Computation of CRC


For G(x) = x16 + x12 + x5 + 1

An Example Frame Format with CRC bits

Department Information Technology

-8-

Computer Networks Lab Manual

Common CRC Generator Polynomials


CRC-32: x32 + x 26 + x 23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 Used in FDDI, Ethernet. CRC-CCITT: x16 + X12 + x5 + 1 Used in HDLC. CRC-8: x8 + x2 + x + 1 Used in ATM.

PROCEDURES

Step-1: Read the frame Step-2: Read the generator polynomial Step-3: find out the degree of the generator polynomial Step-4: Append the number of the zeros to the frame that number is equal to the degree of the polynomial Step-5: Find out number of digits in the generator polynomial Step-6: Repeat the following until the number of digits are exhausted Step-7: If the frame is starting with 1 , then exclusive-or the frame with generator Step-8: Check whether the result obtained in step 7 is starting with 1, If so exclusive-or the remainder with the generator Step-9: If the result obtained in step7 is starting with 0, then exclusive or the remainder(result) with zeros. The number of zeroes must be equal to the length of the generator.

Department Information Technology

-9-

Computer Networks Lab Manual

Implementation using C PROGRAM FOR CYCLIC REDUNDENCY CHECK


#include<stdio.h> #include<conio.h> int gen[4],genl,frl,rem[4]; void main() { int i,j,fr[8],dupfr[11],recfr[11],tlen,flag; clrscr(); frl=8; genl=4; printf("enter frame:"); for(i=0;i<frl;i++) { scanf("%d",&fr[i]); dupfr[i]=fr[i]; } printf("enter generator:"); for(i=0;i<genl;i++) scanf("%d",&gen[i]); tlen=frl+genl-1; for(i=frl;i<tlen;i++) { dupfr[i]=0; } remainder(dupfr); for(i=0;i<frl;i++) { recfr[i]=fr[i]; } for(i=frl,j=1;j<genl;i++,j++) { recfr[i]=rem[j]; } remainder(recfr); flag=0; for(i=0;i<4;i++) { if(rem[i]!=0) flag++; } if(flag==0) { printf("frame received correctly"); } else { printf("the received frame is wrong"); } getch(); } remainder(int fr[]) { int k,k1,i,j; for(k=0;k<frl;k++) { if(fr[k]==1)

Department Information Technology

- 10 -

Computer Networks Lab Manual


{ k1=k; for(i=0,j=k;i<genl;i++,j++) { rem[i]=fr[j]^gen[i]; } for(i=0;i<genl;i++) { fr[k1]=rem[i]; k1++; } } } } INPUT: enter frame : 1 1 1 1 1 1 1 1 enter generator : 1 1 0 1 OUTPUT: frame received correctly

Department Information Technology

- 11 -

Computer Networks Lab Manual

Ex. No: 03

DIJIKSTRS ALGORITHM

AIM To write a program for implementation of Dijkstra's Algorithm to compute the shortest path through a graph

DESCRIPTION Dijkstra's algorithm solves the single-source shortest-path problem when all edges have non-negative weights. It is a greedy algorithm and similar to Prim's algorithm. Algorithm starts at the source vertex, s, it grows a tree, T, that ultimately spans all vertices reachable from S. Vertices are added to T in order of distance i.e., first S, then the vertex closest to S, then the next closest, and so on. Following implementation assumes that graph G is represented by adjacency lists.

DIJKSTRA (G, w, s)
1. 2. 3. 4. 5. 6. INITIALIZE SINGLE-SOURCE (G, s) S { } // S will ultimately contains vertices of final shortest-path weights from s Initialize priority queue Q i.e., Q V[G] while priority queue Q is not empty do u EXTRACT_MIN(Q) // Pull out new vertex S S {u} // Perform relaxation for each vertex v adjacent to u 7. for each vertex v in Adj[u] do 8. Relax (u, v, w)

Department Information Technology

- 12 -

Computer Networks Lab Manual

PROCEDURES Step1. Given initial graph G=(V, E). All nodes have infinite cost except the source node, s, which has 0 cost.

Step 2. First we choose the node, which is closest to the source node, s. We initialize d[s] to 0. Add it to S. Relax all nodes adjacent to source, s. Update predecessor (see red arrow in diagram below) for all nodes updated.

Step 3. Choose the closest node, x. Relax all nodes adjacent to node x. Update predecessors for nodes u, v and y (again notice red arrows in diagram below).

Department Information Technology

- 13 -

Computer Networks Lab Manual

Step 4. Now, node y is the closest node, so add it to S. Relax node v and adjust its predecessor (red arrows remember!).

Step 5. Now we have node u that is closest. Choose this node and adjust its neighbor node v.

Step 6. Finally, add node v. The predecessor list now defines the shortest path from each node to the source node, s.

Department Information Technology

- 14 -

Computer Networks Lab Manual Implementation Using C PROGRAM FOR FINDING SHORTEST PATH FOR A GIVEN GRAPH
#include<stdio.h> #include<conio.h> void main() { int path[5][5],i,j,min,a[5][5],p,st=1,ed=5,stp,edp,t[5],index; clrscr(); printf("enter the cost matrix\n"); for(i=1;i<=5;i++) for(j=1;j<=5;j++) scanf("%d",&a[i][j]); printf("enter number of paths\n"); scanf("%d",&p); printf("enter possible paths\n"); for(i=1;i<=p;i++) for(j=1;j<=5;j++) scanf("%d",&path[i][j]); for(i=1;i<=p;i++) { t[i]=0; stp=st; for(j=1;j<=5;j++) { edp=path[i][j+1]; t[i]=t[i]+a[stp][edp]; if(edp==ed) break; else stp=edp; } } min=t[st];index=st; for(i=1;i<=p;i++) { if(min>t[i]) { min=t[i]; index=i; } } printf("minimum cost %d",min); printf("\n minimum cost path "); for(i=1;i<=5;i++) { printf("--> %d",path[index][i]); if(path[index][i]==ed) break; } getch(); } INPUT: enter the cost matrix : 0 1 4 2 0 0 0 0 2 3 0 0 0 3 0 0 0 0 0 5 0 0 0 0 0 enter number of paths : 4

Department Information Technology

- 15 -

Computer Networks Lab Manual


enter 1 2 4 1 2 5 1 4 5 1 3 4 possible paths : 5 0 0 0 0 0 5 0

OUTPUT: minimum cost : 4 minimum cost path : 1-->2-->5

Department Information Technology

- 16 -

Computer Networks Lab Manual Ex. No : 4

DISTANCE VECTOR ROUTING ALGORITHM


AIM To write a program for implementation of distance vector routing algorithm. DESCRIPTION Routing algorithms are a part of the network layer software whose responsibility is to decide what destination output line should be selected for successful journey completion of the packet from the source machine to destination machine. The network layer of ISO-OSI reference model is responsible for getting packets from the source to the destination. It uses routing algorithms to effectively use all communication lines and routers present in the communication subnet and decide which lines to use for forwarding incoming packets.

Classification of Routing Algorithms


Routing algorithms are of classified on the basis of routing decisions made by them. They are either non adaptive or adaptive. Non adaptive algorithms do not change routing decisions on the basis of measurements of current traffic and topology, where as adaptive routing algorithms do change routing decisions on basis of measurements of current traffic and topology. Non adaptive algorithms are also called static algorithms and adaptive algorithms are also called dynamic algorithms.

Types of Routing Algorithms Shortest Path Routing


Shortest path routing is a static (non adaptive) routing algorithm. In this algorithm a graph of the communication subnet is created with each node representing a router and each edge representing a communication line (link). Finding the shortest path between two nodes is done on the basis of some type of measurements. These measurements are called metrics. Some of the metrics used are number of hops, physical distance, mean queuing and transmission delays. Metrics like transmission delays and queue length are measured hourly for standard test packets sent out on each line of the communication subnet. Shortest path can be calculated on the basis of any one of the criteria or a combination of criteria. The most simple and widely used algorithm for finding the shortest path is the Dijkstras algorithm.

Distance Vector Routing


Most computer networks in operation today use dynamic routing algorithms rather than static routing algorithms. One of the widely used dynamic algorithms is Distance Vector routing, which is also known as Bellman Ford algorithm. A table maintained by a router is called a vector. Vectors contain information on how to get to the destination using the best possible path to get to it. It also contains an entry for each router in the subnet. Each of the routing tables is updated continuously. This can be done by exchanging information with the neighboring routers. For measuring the optimal distance between each node, metrics are used, similar to ones described above in the classification section of the article. The optimal path is followed till the packet reaches the destination machine.

Department Information Technology

- 17 -

Computer Networks Lab Manual Distance vector algorithms use the Bellman-Ford algorithm. This approach assigns a number, the cost, to each of the links between each node in the network. Nodes will send information from point A to point B via the path that results in the lowest total cost (i.e. the sum of the costs of the links between the nodes used). The algorithm operates in a very simple manner. When a node first starts, it only knows of its immediate neighbours, and the direct cost involved in reaching them. (This information, the list of destinations, the total cost to each, and the next hop to send data to get there, makes up the routing table, or distance table.) Each node, on a regular basis, sends to each neighbour its own current idea of the total cost to get to all the destinations it knows of. The neighbouring node(s) examine this information, and compare it to what they already 'know'; anything which represents an improvement on what they already have, they insert in their own routing table(s). Over time, all the nodes in the network will discover the best next hop for all destinations, and the best total cost. When one of the nodes involved goes down, those nodes which used it as their next hop for certain destinations discard those entries, and create new routing-table information. They then pass this information to all adjacent nodes, which then repeat the process. Eventually all the nodes in the network receive the updated information, and will then discover new paths to all the destinations which they can still "reach". Implementation Using C PROGRAM FOR DISTANCE VECTOR ROUTING ALGORITHM
#include<ctype.h> #include<stdio.h> #include<conio.h> #include<string.h> int dest,ja,ji,jk,j,jh,min,delay; char dnode,line; struct newj { int delay; char line; }s[12]; int a[12]={0,12,25,40,14,23,18,17,21,9,24,29}; int i[12]={24,36,18,27,7,20,31,20,0,11,22,33}; int h[12]={20,31,19,8,30,19,6,0,14,7,22,9}; int k[12]={21,28,36,24,22,40,31,19,22,10,0,9}; main() { ja=8; ji=10; jh=12; jk=6; clrscr(); printf("\n The source node is j"); printf("\n The adjacent nodes from j are a,i,h,k"); printf("\n Enter the destination node"); scanf("%c",&dnode); dest=toupper(dnode)-'A'; for(j=0;j<12;j++) { min=a[j]+ja; line='a'; if(min>i[j]+ji) { line='i'; min=i[j]+ji; }

Department Information Technology

- 18 -

Computer Networks Lab Manual


if(min>h[j]+jh) { line='h'; min=h[j]+jh; } if(min>k[j]+jk) { line='k'; min=k[j]+jk; } s[j].delay=min; s[j].line=line; } printf("The routing table is "); printf("\n Dest \t Distance \t via node"); for(j=0;j<12;j++) if(j==9) printf("\n j \t 0 \t \t j"); else printf("\n %c \t %d \t \t %c", j+'a', s[j].delay, s[j].line); if(dest==9) printf("\n Delay from source j to destination j is 0 via j"); else printf("\n Delay from source j to %c is %d via %c", dnode,s[dest]. delay, s[dest]. line); getch(); } OUTPUT The source node is j The adjacent nodes from j are a,i,h,k Enter the destination nodea The routing table is Dest Distance via node a 8 a b 20 a c 28 i d 20 h e 17 i f 30 i g 18 h h 12 h i 10 i j 0 j k 6 k l 15 k Delay from source j to a is 8 via a

Department Information Technology

- 19 -

Computer Networks Lab Manual


Ex.No : 5

BROADCAST TREE FROM SUBNET OF HOST


AIM To write a program for route a packet from source to all nodes. DESCRIPTION Minimum Spanning Trees: Given a connected, undirected graph G = <N,E> where each edge has an associated 'length' (or 'weight'). For example :

We want a subset, T, of edges, E, such that the graph remains connected if only the edges in T are used, and the sum of the lengths of edges in T is as small as possible. Such a subgraph must be a tree, and is called a Minimum Spanning Tree. For the above graph, the following are both minimum spanning trees (cost 7).

Department Information Technology

- 20 -

Computer Networks Lab Manual PROBLEM : Devise an algorithm to find a minimum spanning tree. Kruskal's Algorithm: Greedy algorithm to find minimum spanning tree. Want to find set of edges T.

Start with T = EMPTY SET Keep track of connected components of graph with edges T Initially components are single nodes At each stage, add the cheapest edge that connects two nodes not already connected

PROCEDURES Kruskal's Algorithm


Step 1 : Find the cheapest edge in the graph (if there is more than one, pick one at random). Mark it with any given colour, say red. Step 2 : Find the cheapest unmarked (uncoloured) edge in the graph that doesn't close a coloured or red circuit. Mark this edge red. Step 3 : Repeat Step 2 until you reach out to every vertex of the graph (or you have N ; 1 coloured edges, where N is the number of Vertices.) The red edges form the desired minimum spanning tree.

Prim's Algorithm

Step 0 Pick any vertex as a starting vertex. (Call it S). Mark it with any given colour, say red.

Step 1 Find the nearest neighbour of S (call it P1). Mark both P1 and the edge SP1 red. cheapest unmarked (uncoloured) edge in the graph that doesn't close a coloured circuit. Mark this edge with same colour of Step 1.

Step 2 Find the nearest uncoloured neighbour to the red subgraph (i.e., the closest vertex to any red vertex). Mark it and the edge connecting the vertex to the red subgraph in red.

Step 3 Repeat Step 2 until all vertices are marked red. The red subgraph is a minimum spanning tree.

Interactive Prim's Algorithm

Department Information Technology

- 21 -

Computer Networks Lab Manual

Implementation Using C PROGRAM TO FIND MINIMUM SPANNING TREE


#include<stdio.h> int p,q,u,v,n; int min=99,mincost=0; int t[50][2],i,j; int parent[50],edge[50][50]; main() { clrscr(); printf("\n Enter the number of nodes"); scanf("%d",&n); for(i=0;i<n;i++) { printf("%c\t",65+i); parent[i]=-1; } printf("\n"); for(i=0;i<n;i++) { printf("%c",65+i); for(j=0;j<n;j++) scanf("%d",&edge[i][j]); } for(i=0;i<n;i++) { for(j=0;j<n;j++) if(edge[i][j]!=99) if(min>edge[i][j]) { min=edge[i][j]; u=i; v=j; } p=find(u); q=find(v); if(p!=q) { t[i][0]=u; t[i][1]=v; mincost=mincost+edge[u][v]; sunion(p,q); } else { t[i][0]=-1; t[i][1]=-1; } min=99; } printf("Minimum cost is %d\n Minimum spanning tree is\n" ,mincost); for(i=0;i<n;i++) if(t[i][0]!=-1 && t[i][1]!=-1) { printf("%c %c %d", 65+t[i][0], 65+t[i][1], edge[t[i][0]][t[i][1]]); printf("\n"); }

Department Information Technology

- 22 -

Computer Networks Lab Manual


getch(); } sunion(int l,int m) { parent[l]=m; } find(int l) { if(parent[l]>0) l=parent[l]; return l; }

INPUT: Enter the number of nodes6 A B C A 99 1 1 B 1 99 99 C 1 99 99 D 2 1 99 E 2 99 2 F 99 99 99 OUTPUT: Minimum cost is 7 Minimum spanning tree is A B 1 C A 1 D B 1 E A 2 F D 2

D 2 1 99 99 2 2

E 2 99 2 2 99 3

F 99 99 99 2 3 99

Department Information Technology

- 23 -

Computer Networks Lab Manual Ex. No: 06

SDES ENCRYPTION
AIM To Write a Program for implementing DES Algorithm. Take 64 bit plaintext as an input. DESCRIPTION 2.a) SDES - Simplified DES Similar properties and structure but with much smaller parameters than DES.

As in DES, the initial and final permutations, which are fixed and independent of the key, provide no real security benefit, but make the algorithm slow if implemented in software.

Department Information Technology

- 24 -

Computer Networks Lab Manual SDES Key Schedule

The 10-bit key is transformed into two 8-bit sub-keys K1 and K2. Example: P10 = { 3, 5, 2, 7, 4, 10, 1, 9, 8, 6} P8 = { 6, 3, 7, 4, 8, 5, 10, 9} K = P10 LS-1 LS-2 10100 00010 10000 01100 00001 11000 00100 00011 -> -> P8 P8 -> -> K1 = 1010 0100 K2 = 0100 0011

Department Information Technology

- 25 -

Computer Networks Lab Manual

SDES Function

In fK the rightmost 4 bits are passed through unchanged, and the leftmost 4 bits are "mangled" by the non-invertible function F: fK(L,R) = L XOR F(R,Ki), R -- encrypt or decrypt

E/P = { 4, 1, 2, 3, 2, 3, 4, 1} P4 = { 2, 4, 3, 1} S0 = 1 3 0 3 0 2 2 1 3 1 1 3 2 0 3 2 S1 = 0 2 3 2 1 0 0 1 2 1 1 0 3 3 0 3

n1n2n3n4

->

Si[n1n4][n2n3]

Example: R = 1010 E/P 0101 0101

K1 = 1010 0100 Department Information Technology - 26 -

Computer Networks Lab Manual XOR 1111 0001 S1[01][00] -> 10

S0[11][11] -> 10 1010 P4 0011

Properties of XOR and bitwise complement

A 0 0 1 1

B 0 1 0 1

A XOR B 0 1 1 0

A' XOR B 1 0 0 1

A' XOR B' 0 1 1 0

(A XOR B)' 1 0 0 1

From the truth-table: A' XOR B == (A XOR B)' A XOR B

A' XOR B' ==

(S)DES input/key complement property

Department Information Technology

- 27 -

Computer Networks Lab Manual P3.10 (a) Using input X' and key K', both inputs to the first XOR are complemented, therefore the XOR output, and the result of F, will be the same as using uncomplemented X and K The second XOR has inputs L' and F, therefore its output is complemented. P3.10 (b) Due to the (S)DES complement property, we can get two encryptions for the price of one, since after computing Y = K{X} we know that Y' = K'{X'}. But this does not seem to reduce the work needed for a brute-force attack on a particular key K, since K' is a different key. If (S)DES had the property Y'=K'{X} then the search space would be reduced by 1/2; you'd compute Z=K{X} and if Z==Y then K is the key, and if Z==Y' then K' is the key.

Implementation Using C PROGRAM FOR SDES ALGORITHM


#include<stdio.h> #include<conio.h> #include<string.h> int p10[]={3,5,2,7,4,10,1,9,8,6}, p8[]={6,3,7,4,8,5,10,9}, p4[]={2,4,3,1}; int ip[]={2,6,3,1,4,8,5,7}, ipinv[]={4,1,3,5,7,2,8,6}, ep[]={4,1,2,3,2,3,4,1}; int s0[][4]={{1,0,3,2,},{3,2,1,0},{0,2,1,3,},{3,1,3,2}}; int s1[][4]={{0,1,2,3},{2,0,1,3},{3,0,1,0},{2,1,0,3}}; void permute(char op[],char ip[],int p[], int n) { int i; for(i=0;i<n;i++) op[i]=ip[p[i]-1]; op[i]='\0'; } void circularls(char pr[],int n) { int i; char ch=pr[0]; for(i=0;i<n-1;i++) pr[i]=pr[i+1]; pr[i]=ch; } void keygen(char k1[],char k2[],char key[]) { char keytemp[11]; permute(keytemp,key,p10,10); circularls(keytemp,5); circularls(keytemp+5,5); permute(k1,keytemp,p8,8); circularls(keytemp,5); circularls(keytemp,5); circularls(keytemp+5,5); circularls(keytemp+5,5);

Department Information Technology

- 28 -

Computer Networks Lab Manual


permute(k2,keytemp,p8,8); } void xor(char op[],char ip[]) { int i; for(i=0;i<strlen(op)&&i<strlen(ip);i++) op[i]=(op[i]-'0')^(ip[i]-'0')+'0'; } void sbox(char op[],char ip[],int s[][4]) { int value; value=s[(ip[0]-'0')*2+(ip[3]-'0')][(ip[1]-'0')*2+(ip[2]-'0')]; op[0]=value/2+'0'; op[1]=value%2+'0'; op[2]='\0'; } void fk(char op[],char ip[],char k[]) { char l[5],r[5],tmp[9],tmp1[9],tmp2[9]; strncpy(l,ip,4); l[4]='\0'; strncpy(r,ip+4,4); r[4]='\0'; permute(tmp,r,ep,8); xor(tmp,k); sbox(tmp1,tmp,s0); sbox(tmp2,tmp+4,s1); strcat(tmp1,tmp2); permute(tmp,tmp1,p4,4); xor(tmp,l); strcat(tmp,r); strcpy(op,tmp); } void sw(char pr[]) { char tmp[9]; strncpy(tmp,pr+4,4); strncpy(tmp+4,pr,4); tmp[8]='\0'; strcpy(pr,tmp); } void main() { char key[11],k1[9],k2[9],plain[9],cipher[9],tmp[9]; clrscr(); printf("enter 10 bit key:"); gets(key); if(strlen(key)!=10) printf("invalid key length !!"); else { keygen(k1,k2,key); printf("sub key k1::"); puts(k1); printf("subkey k2::"); puts(k2); printf("enter 8 bit plain text:"); gets(plain); if(strlen(plain)!=8) printf("invalid length plain text !!"); permute(tmp,plain,ip,8); fk(cipher,tmp,k1);

Department Information Technology

- 29 -

Computer Networks Lab Manual


sw(cipher); fk(tmp,cipher,k2); permute(cipher,tmp,ipinv,8); printf("cipher teaxt is::"); puts(cipher); /* decryption process*/ permute(tmp,cipher,ip,8); fk(plain,tmp,k2); sw(plain); fk(tmp,plain,k1); permute(plain,tmp,ipinv,8); printf("decrypted text is::"); puts(plain); } getch(); }

Department Information Technology

- 30 -

Computer Networks Lab Manual Ex. No: 07

BREAK THE DES CODING


AIM : To write a program for break the DES coding DESCRIPTION: Cracking DES Before DES was adopted as a national standard, during the period NBS was soliciting comments on the proposed algorithm, the creators of public key cryptography, Martin Hellman and Whitfield Diffie, registered some objections to the use of DES as an encryption algorithm. Hellman wrote: "Whit Diffie and I have become concerned that the proposed data encryption standard, while probably secure against commercial assault, may be extremely vulnerable to attack by an intelligence organization" (letter to NBS, October 22, 1975). Diffie and Hellman then outlined a "brute force" attack on DES. (By "brute force" is meant that you try as many of the 2^56 possible keys as you have to before decrypting the ciphertext into a sensible plaintext message.) They proposed a special purpose "parallel computer using one million chips to try one million keys each" per second, and estimated the cost of such a machine at $20 million. Fast forward to 1998. Under the direction of John Gilmore of the EFF, a team spent $220,000 and built a machine that can go through the entire 56-bit DES key space in an average of 4.5 days. On July 17, 1998, they announced they had cracked a 56-bit key in 56 hours. The computer, called Deep Crack, uses 27 boards each containing 64 chips, and is capable of testing 90 billion keys a second. Despite this, as recently as June 8, 1998, Robert Litt, principal associate deputy attorney general at the Department of Justice, denied it was possible for the FBI to crack DES: "Let me put the technical problem in context: It took 14,000 Pentium computers working for four months to decrypt a single message . . . . We are not just talking FBI and NSA [needing massive computing power], we are talking about every police department." Responded cryptograpy expert Bruce Schneier: " . . . the FBI is either incompetent or lying, or both." Schneier went on to say: "The only solution here is to pick an algorithm with a longer key; there isn't enough silicon in the galaxy or enough time before the sun burns out to brute- force triple-DES" (Crypto-Gram, Counterpane Systems, August 15, 1998).

Department Information Technology

- 31 -

Computer Networks Lab Manual Ex. No: 08

RSA ENCRYPTION AND DECRYPTION


AIM To write a program for implementing RSA Algorithm for Encryption and Decryption DESCRIPTION RSA Algorithm The RSA algorithm is named after Ron Rivest, Adi Shamir and Len Adleman, who invented it in 1977 [RIVE78]. The basic technique was first discovered in 1973 by Clifford Cocks [COCK73] of CESG (part of the British GCHQ) but this was a secret until 1997 - see The History of ID-PKC. The RSA algorithm can be used for both public key encryption and digital signatures. Its security is based on the difficulty of factoring large integers. Key Generation Algorithm 1. Generate two large random primes, p and q, of approximately equal size such that their product n = pq is of the required bit length, e.g. 1024 bits. [See note 1]. 2. Compute n = pq and () phi = (p-1)(q-1). 3. Choose an integer e, 1 < e < phi, such that gcd(e, phi) = 1. [See note 2]. 4. Compute the secret exponent d, 1 < d < phi, such that ed 1 (mod phi). [See note 3]. 5. The public key is (n, e) and the private key is (n, d). The values of p, q, and phi should also be kept secret.

n is known as the modulus. e is known as the public exponent or encryption exponent. d is known as the secret exponent or decryption exponent.

Encryption Sender A does the following:1. 2. 3. 4. Obtains the recipient B's public key (n, e). Represents the plaintext message as a positive integer m [see note 4]. Computes the ciphertext c = m^e mod n. Sends the ciphertext c to B.

Decryption Recipient B does the following:1. Uses his private key (n, d) to compute m = c^d mod n. 2. Extracts the plaintext from the integer representative m. Digital signing Sender A does the following:Department Information Technology - 32 -

Computer Networks Lab Manual 1. 2. 3. 4. Creates a message digest of the information to be sent. Represents this digest as an integer m between 0 and n-1. [See note 5]. Uses her private key (n, d) to compute the signature s = m^d mod n. Sends this signature s to the recipient, B.

Signature verification Recipient B does the following:1. 2. 3. 4. Uses sender A's public key (n, e) to compute integer v = s^e mod n. Extracts the message digest from this integer. Independently computes the message digest of the information that has been signed. If both message digests are identical, the signature is valid.

Notes on practical applications 1. To generate the primes p and q, generate a random number of bit length b/2 where b is the required bit length of n; set the low bit (this ensures the number is odd) and set the two highest bits (this ensures that the high bit of n is also set); check if prime (use the RabinMiller test); if not, increment the number by two and check again. This is p. Repeat for q starting with an integer of length b-b/2. If p<q, swop p and q (this only matters if you intend using the CRT form of the private key). In the extremely unlikely event that p = q, check your random number generator. For greater security, instead of incrementing by 2, generate another random number each time. 2. In practice, common choices for e are 3, 17 and 65537 (2^16+1). These are Fermat primes and are chosen because they make the modular exponentiation operation faster. Also, having chosen e, it is simpler to test whether gcd(e, p-1)=1 and gcd(e, q-1)=1 while generating and testing the primes in step 1. Values of p or q that fail this test can be rejected there and then. (Even better: if e is prime and greater than 2 then you can do the less-expensive test (p mod e)!=1 instead of gcd(p-1,e)==1.) 3. To compute the value for d, use the Extended Euclidean Algorithm to calculate d = e^-1 mod phi (this is known as modular inversion). 4. When representing the plaintext octets as the representative integer m, it is usual to add random padding characters to make the size of the integer m large and less susceptible to certain types of attack. If m = 0 or 1 there is no security as the ciphertext has the same value. For more details on how to represent the plaintext octets as a suitable representative integer m, see [PKCS1]. It is important to make sure that m < n otherwise the algorithm will fail. This is usually done by making sure the first octet of m is equal to 0x00.

5. Decryption and signing are identical as far as the mathematics is concerned as both use the private key. Similarly, encryption and verification both use the same mathematical operation with the public key. That is, mathematically, m = (m^e mod n)^d mod n = (m^d mod n)^e mod n, m < n However, note these important differences in implementation:o

The signature is derived from a message digest of the original information. The recipient will need to follow exactly the same process to derive the message digest, using an identical set of data. - 33 -

Department Information Technology

Computer Networks Lab Manual


o

The recommended methods for deriving the representative integers are different for encryption and signing (encryption involves random padding, but signing uses the same padding each time). Summary of RSA

n = pq where p and q are distinct primes. phi, = (p-1)(q-1) e < n such that gcd(e, phi)=1 d = e^-1 mod phi. c = m^e mod n, 1<m<n. m = c^d mod n.

A very simple example of RSA encryption This is an extremely simple example using numbers you can work out on a pocket calculator (those of you over the age of 35 can probably even do it by hand on paper). 1. Select primes p=11, q=3. 2. n = pq = 11.3 = 33 phi = (p-1)(q-1) = 10.2 = 20 3. Choose e=3 Check gcd(e, p-1) = gcd(3, 10) = 1 (i.e. 3 and 10 have no common factors except 1), and check gcd(e, q-1) = gcd(3, 2) = 1 therefore gcd(e, phi) = gcd(e, (p-1)(q-1)) = gcd(3, 20) = 1 4. Compute d such that ed 1 (mod phi) i.e. compute d = e^-1 mod phi = 3^-1 mod 20 i.e. find a value for d such that phi divides (ed-1) i.e. find d such that 20 divides 3d-1. Simple testing (d = 1, 2, ...) gives d = 7 Check: ed-1 = 3.7 - 1 = 20, which is divisible by phi. 5. Public key = (n, e) = (33, 3) Private key = (n, d) = (33, 7). This is actually the smallest possible value for the modulus n for which the RSA algorithm works. Now say we want to encrypt the message m = 7, c = m^e mod n = 7^3 mod 33 = 343 mod 33 = 13. Hence the ciphertext c = 13. To check decryption we compute m' = c^d mod n = 13^7 mod 33 = 7. Note that we don't have to calculate the full value of 13 to the power 7 here. We can make use of the fact that a = bc mod n = (b mod n).(c mod n) mod n so we can break down a potentially large number into its components and combine the results of easier, smaller calculations to calculate the final value. One way of calculating m' is as follows:m' = 13^7 mod 33 = 13^(3+3+1) mod 33 = 13^3.13^3.13 mod 33 = (13^3 mod 33).(13^3 mod 33).(13 mod 33) mod 33 Department Information Technology - 34 -

Computer Networks Lab Manual = (2197 mod 33).(2197 mod 33).(13 mod 33) mod 33 = 19.19.13 mod 33 = 4693 mod 33 = 7. Now if we calculate the ciphertext c for all the possible values of m (0 to 32), we get m c 0 0 1 1 2 3 4 5 6 7 8 8 27 31 26 18 13 17 9 10 11 12 13 14 15 16 3 10 11 12 19 5 9 4

m 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 c 29 24 28 14 21 22 23 30 16 20 15 7 2 6 25 32 Note that all 33 values of m (0 to 32) map to a unique code c in the same range in a sort of random manner. In this case we have nine values of m that map to the same value of c - these are known as unconcealed messages. m = 0 and 1 will always do this for any N, no matter how large. But in practice, higher values shouldn't be a problem when we use large values for N. If we wanted to use this system to keep secrets, we could let A=2, B=3, ..., Z=27. (We specifically avoid 0 and 1 here for the reason given above). Thus the plaintext message "HELLOWORLD" would be represented by the set of integers m1, m2, ... {9,6,13,13,16,24,16,19,13,5} Using our table above, we obtain ciphertext integers c1, c2, ... {3,18,19,19,4,30,4,28,19,26} Note that this example is no more secure than using a simple Caesar substitution cipher, but it serves to illustrate a simple example of the mechanics of RSA encryption. Remember that calculating m^e mod n is easy, but calculating the inverse c^-e mod n is very difficult, well, for large n's anyway. However, if we can factor n into its prime factors p and q, the solution becomes easy again, even for large n's. Obviously, if we can get hold of the secret exponent d, the solution is easy, too.
#include<conio.h> #include<stdio.h> #include<iostream.h> #include<stdlib.h> #include<math.h> int p,q,r,i,d,e,n; long double plain,cipher,temp=0; int gcd(int,int); void main() { clrscr(); cout<<"Enter the values of p and q :"; cin>>p; cin>>q; for(i=2;i<p;i++) if(p%i==0) temp++; for(i=2;i<q;i++) if(q%i==0) temp++; if(temp>0) { cout<<"The entered values are not primes \nplease try again"; getch();

Department Information Technology

- 35 -

Computer Networks Lab Manual


exit(0); } n=p*q; r=(p-1)*(q-1); cout<<"Enter the value of e :"; cin>>e; if(gcd(r,e)!=1) { cout<<"The entered e value is not valid"; getch(); exit(0); } for(d=0;d<n;d++) if((d*e)%r==1) break; clrscr(); cout<<"The final values are:\n"; cout<<"p="<<p<<"\n"; cout<<"q="<<q<<"\t"<<"P and Q are prime, p!=q\n"; cout<<"n="<<n<<"\t"<<"n=p*q\n"; cout<<"r="<<r<<"\t"<<"r=(p-1)*(q-1) \n"; cout<<"e="<<e<<"\t"<<"gcd(r,e)=1;1<e<r\n"; cout<<"d="<<d<<"\t"<<"demod(r)=1\n"; getch(); cout<<"Encryption process....\t(m^e)modn\n"; cout<<"Enter the plain text (<n):"; cin>>plain; temp=pow(plain,e); cipher=fmod(temp,n); cout<<"The cipher text is :"<<cipher; cout<<"\nDecryption process....\t(c^d)modn\n"; temp=pow(cipher,d); plain=fmod(temp,n); cout<<"The plain text is :"<<plain; getch(); } int gcd(int a,int b) { int c; c=a%b; if(c==0) return(b); else gcd(b,c); }

Department Information Technology

- 36 -

Object Oriented Analysis and Design CASE Tool (Rational Rose) for UML

UML Manual

Object Oriented Analysis and Design CASE Tool (Rational Rose) for UML
INTRODUCTION IBM Rational Rose Enterprise provides a common modeling language for enabling faster creation of quality software Includes Unified Modeling Language (UML) support and is one of the most comprehensive products in the Rational Rose family Operating systems supported: Windows James Rumbaugh, Ivar Jacobson, Grady Booch developed UML. The Unified Modeling Language (UML) is a standardized visual specification language for object modeling. UML is a generalpurpose modeling language that includes a graphical notation used to create an abstract model of a system, referred to as a UML model. The Unified Modeling Language is an international standard: ISO/IEC 19501:2005 Information technology Open Distributed Processing Unified Modeling Language (UML) Version 1.4.2. UML has matured significantly since UML 1.1. Several minor revisions (UML 1.3, 1.4, and 1.5) fixed shortcomings and bugs with the first version of UML, followed by the UML 2.0 major revision. There are four parts to the UML 2.x specification: the Superstructure, which defines the notation and semantics for diagrams and their model elements; the Infrastructure, which defines the core metamodel on which the Superstructure is based; the Object Constraint Language (OCL) for defining rules for model elements; and the UML Diagram Interchange, which defines how UML 2 diagram layouts are exchanged. The current versions of these standards follow: UML Superstructure v. 2.1.2, UML Infrastructure v. 2.1.2, OCL v. 2.0, and UML Diagram Interchange v. 1.0. Although many UML tools support some of the new features of UML 2.x, the OMG provides no test suite to objectively test compliance with its specifications. Modeling It is very important to distinguish between the UML model and the set of diagrams of a system. A diagram is a partial graphical representation of a system's model. The model also contains a "semantic backplane" documentation such as written use cases that drive the model elements and diagrams. UML diagrams represent three different views of a system model: Functional requirements view Emphasizes the functional requirements of the system from the user's point of view. Includes use case diagrams.

Dept. of Information Technology SVECW

37

UML Manual

Static structural view Emphasizes the static structure of the system using objects, attributes, operations, and relationships. Includes class diagrams and composite structure diagrams. Dynamic behavior view Emphasizes the dynamic behavior of the system by showing collaborations among objects and changes to the internal states of objects. Includes sequence diagrams, activity diagrams and state machine diagrams. UML models can be exchanged among UML tools by using the XMI interchange format. DIAGRAMS UML has 9 types of diagrams, which can be categorized hierarchically as follows: Structure diagrams emphasize what things must be in the system being modeled: Class diagram ,Component diagram, Deployment diagram, Object diagram, Package diagram Behavior diagrams emphasize what must happen in the system being modeled: Activity diagram, State Machine diagram, Use case diagram Interaction diagrams, a subset of behavior diagrams, emphasize the flow of control and data among the things in the system being modeled: Interaction diagram, Sequence diagram UML does not restrict UML element types to a certain diagram type. In general, every UML element may appear on almost all types of diagrams. In keeping with the tradition of engineering drawings, a comment or note explaining usage, constraint, or intent is always allowed in a UML diagram. Concepts: UML uses many concepts from many sources. For a definitive list, consult the glossary of Unified Modeling Language terms. Notable concepts are listed here. For structure

Actor, attribute, class, component, interface, object, package. For behavior

Activity, event, message, method, operation, state, use case. For relationships

Aggregation, association, composition, dependency, generalization (or inheritance). Other concepts Stereotype. It qualifies the symbol it is attached to. Dept. of Information Technology SVECW 38

UML Manual

Multiplicity notation which corresponds to database modeling cardinality, e.g., 1, 0..1, 1..* Role

DEFINTION: The Unified Modeling Language (UML) is a graphical language for visualizing, specifying, constructing and documenting the artifacts-intensive system. UML is a graphical language and it gives a standard functions as well as concrete things such as classes written in a specific programming language, database schemas and reusable software components. The UML combines the best of the best from Data Modeling concepts (E-R diagrams) Business Modeling (work flow) Object Modeling Component Modeling

Features of UML A Modeling language: UML provides the vocabulary and the rules for communication and focus on conceptual and physical representations of the system. So it is a modeling language. UML Visualizes: UML includes both graphical and textual representation and makes easy to visualize the system and for better understanding. UML specifies: UML addresses the specification of all the important analysis, design, implementation decisions, developing and deploying a software-intensive system. UML Constructs: UML models can be directly connected to a variety of programming languages. And it is sufficiently expressive and free from any ambiguity to permit the direct execution of models, simulation of systems, and the instrumentation of running systems. UML Documents: UML produces variety of documents, in addition to raw executable code, the aircrafts include Requirements, Architecture, Design, Source code, Project Plans, Test, Prototypes, Releases. UML Usage: UML has been effectively used in domains such as: EIS (Enterprise Information Systems), Banking and financial services, Telecommunications, Transportation, Defense/Aerospace, Retail, Medical, Electronics, Scientific and Distributed web-based services. It can be used with all processes, through out the development life cycle and across different implementation technologies. UML Users: Some of the known users of UML are Erison, MCI systems, Republic Bank, Oracle, HP, Microsoft etc.. Dept. of Information Technology SVECW 39

UML Manual

UML Architecture: Architecture is used to manage different view points and hence control the interactive and incremental development of systems through out its life cycle. Each of the above five views can be stand alone so that different stack holder can focus on the systems architecture that most concern them. The five views interact with one another. Vocabulary, functionality Design View System assembly, Configuration management Implementation View

Use Case View


Process view Deployment View System Topology, Distribution, Delivery and Installation

Performance, Scalability, throughput

Large enterprise applications - the ones that execute core business applications, and keep a company going - must be more than just a bunch of code modules. They must be structured in a way that enables scalability, security, and robust execution under stressful conditions, and their structure frequently referred to as their architecture - must be defined clearly enough that maintenance programmers can (quickly!) find and fix a bug that shows up long after the original authors have moved on to other projects. That is, these programs must be designed to work perfectly in many areas, and business functionality is not the only one (although it certainly is the essential core). Of course a well-designed architecture benefits any program, and not just the largest ones as we've singled out here. We mentioned large applications first because structure is a way of dealing with complexity, so the benefits of structure (and of modeling and design, as we'll demonstrate) compound as application size grows large. Another benefit of structure is that it enables code reuse: Design time is the easiest time to structure an application as a collection of self-contained modules or components. Eventually, enterprises build up a library of models of components, each one representing an implementation stored in a library of code modules. When another application needs the same functionality, the designer can quickly import its module from the library. At coding time, the developer can just as quickly import the code module into the application. Modeling is the designing of software applications before coding. Modeling is an Essential Part of large software projects, and helpful to medium and even small projects as well. A model plays the analogous role in software development that blueprints and other plans (site maps, elevations, physical models) play in the building of a skyscraper. Using a model, those responsible for a software development project's success can assure themselves that business functionality is complete and correct, end-user needs are met, and program design supports requirements for scalability, robustness, security, extendibility, and other characteristics, before implementation in code renders changes difficult and expensive to make. Surveys show that large software projects have a huge probability of failure - in fact, it's more likely that a large software application will fail to meet all of Dept. of Information Technology SVECW 40

UML Manual

its requirements on time and on budget than that it will succeed. If you're running one of these projects, you need to do all you can to increase the odds for success, and modeling is the only way to visualize your design and check it against requirements before your crew starts to code. Raising the Level of Abstraction: Models help us by letting us work at a higher level of abstraction. A model may do this by hiding or masking details, bringing out the big picture, or by focusing on different aspects of the prototype. In UML 2.0, you can zoom out from a detailed view of an application to the environment where it executes, visualizing connections to other applications or, zoomed even further, to other sites. Alternatively, you can focus on different aspects of the application, such as the business process that it automates, or a business rules view. The new ability to nest model elements, added in UML 2.0, supports this concept directly. The Unified Modeling Language (UML) helps you specify, visualize, and document models of software systems, including their structure and design, in a way that meets all of these requirements. (You can use UML for business modeling and modeling of other non-software systems too.) Using any one of the large number of UML-based tools on the market, you can analyze your future application's requirements and design a solution that meets them, representing the results using UML 2.0's thirteen standard diagram types. You can model just about any type of application, running on any type and combination of hardware, operating system, programming language, and network, in UML. Its flexibility lets you model distributed applications that use just about any middleware on the market. Built upon fundamental OO concepts including class and operation, it's a natural fit for object-oriented languages and environments such as C++, Java, and the recent C#, but you can use it to model non-OO applications as well in, for example, Fortran, VB, or COBOL. UML Profiles (that is, subsets of UML tailored for specific purposes) help you model Transactional, Real-time, and Fault-Tolerant systems in a natural way. You can do other useful things with UML too: For example, some tools analyze existing source code (or, some claim, object code!) and reverse-engineer it into a set of UML diagrams. Another example: Some tools on the market execute UML models, typically in one of two ways: Some tools execute your model interpretively in a way that lets you confirm that it really does what you want, but without the scalability and speed that you'll need in your deployed application. Other tools (typically designed to work only within a restricted application domain such as telecommunications or finance) generate program language code from UML, producing most of a bug-free, deployable application that runs quickly if the code generator incorporates best-practice scalable patterns for, e.g., transactional database operations or other common program tasks. (OMG members are working on a specification for Executable UML now.) Our final entry in this category: A number of tools on the market generate Test and Verification Suites from UML models. UML Primary Goals : The primary goals in the design of the UML are: 1. Provide users a ready-to-use, expressive visual modeling language so that they can develop and exchange meaningful models. 2. Provide extensibility and specialization mechanisms to extend the core concepts. 3. Be independent of particular programming languages and development processes. 4. Provide the required formal basics for understanding the modeling language. 5. Encourage the growth of OO tools market. 6. Support development concepts at higher level. 7. Integrate the best practices and methodologies.

Dept. of Information Technology SVECW

41

UML Manual

UML Foundations: The vocabulary of the UML encompasses three kinds of building blocks Things, Relationships, Diagrams 1. Things: Things are the abstractions: Relationships tie things together: Diagrams group interesting collection of things. There are four things in UML. They are Structural things, Behavioral things, grouping things, and Annotational things. a) Structural Things:They are Nouns and Static parts of Model. The seven structural things are Class, Interface, Collaboration, Use Case, Active Class, Component, and Node. b) Behavioral Things:They are Verbs and Dynamic parts of UML, representing behavior over time and space. The two behavior things are Interaction and State Machine. c) Grouping Things:They are the organizational parts of UML. A Package is a grouping thing where structural, behavioral things are grouped in a package. d) Annotational Things:They are explanatory parts of models. These are the comments applied to describe, illuminate and remark about any element in a model. A Note is an example for it. 2.Relationships:Relationship is a semantic connection among elements. The different kinds of relationships in the UML, are Dependency, Association,(Aggregation), Generalization and Realization. Diagrams:Every complex system is best approach through a small set of nearly independent views of a model: no single view is sufficient. The Nine graphical diagrams of UML are classified into static and dynamic diagrams. Static/Structural Diagrams 1. Class Diagram 2. Object Diagram Dynamic/Behavioral Diagrams 1. Use Case Diagram 2. Sequence Diagram 3. Collaboration Diagram 4. State chart Diagram 5. Activity Diagram

3. Component Diagram 4. Deployment Diagram

Dept. of Information Technology SVECW

42

UML Manual

Rules Of The UML:The UML has the following semantic rules to become a well-formed

Names : What you can call things, relationships and diagrams Scope : The context that gives specific meaning to a name Visibility : How those names can be seen and used by others Integrity : How things properly and consistently relate to one another Execution : What it means to run or simulate a dynamic model? Sometimes it is required to build models which are Elided (certain elements are hidden), Incomplete,(when not identified), and Inconsistent(missing integrity in certain parts). These types of models are unavoidable in certain specific cases. Primary Elements Of UML:-

Class: A template for a set of objects that share a common structure and a common behavior.

Use Case: A named behavior involving collaboration have a society of Objects

State: The condition of an object.

Interface: The public part of an object.

Active Class: Capable of concurrent activity with their active classes

Node: A hardware device upon which software may reside and/or execute.

Note: A comment, explanation or annotation.

Package: A container of elements.

Dept. of Information Technology SVECW

43

UML Manual

CLASS DIAGRAMS Class:- A class is a description of a set of objects. They share the same attributes, operations, relationships and semantics. The class name is simple one or it may prefix by the package in which that class lives. Class Name Visibility operation: type= initial value CLASS NAME Visibility operation(argue list): return type

Responsibilities An attribute is a named property of a class. Default values can be assigned to attributes. An operation is done implementation of service that can be requested from any object of a class to affect behavior. A responsibility is a contract or an obligation of a class. Visibility specifies whether other classifiers can use attributes, operations.

There are 3 types of visibility modes: Public: +(Visible to outside classifier) Private : -(only the classifier itself) Protected : #(Any descendent of the classifier)

Dept. of Information Technology SVECW

44

UML Manual

Object Analysis: Classification Theory:Classification is a process of checking to see if an object belongs to a category or a class.

Identifying Classes
1. 2. 3. 4. Noun Phrase approach Common Class patterns approach The use case driven approach CRC approach

1.Noun Phrase approach:- It is a three stage process to extract candidate classes and then to refine the solution. Concise problem definition:- Define the product as briefly and concisely as possible preferably in a single sentence. Informal Strategy:- In order to come up with an informal strategy for solving the problem the constraints must be taken into account. Formalize the strategy:- Identify the nouns in the informal strategy and then use these nouns as candidate classes.

Guidelines for selecting the nouns:1. 2. 3. 4. 5. Redundant classes Adjective classes Attribute classes Irrelevant classes Vague classes

2. Common class pattern approach:The pattern for finding the candidate classes and object are listed below: Concept class:- Concept is a particular idea or understanding of the domain. They are not tangible but to organized business activities or communications. Event class:- They are points in time that must be recorded. They represent that the things that happen at the given date and time. Events such as writing, request, interrupt are examples for this type. Organizational class:- An organization class is a collection of people, resources, facilities or groups to which the users belong: their capabilities have a defined machine, whose existence is largely independent of the individuals. People class:- People class represent the different roles users play while interacting with the application. Places class:- Places class is a physical location where the system keeps information. Tangible things and device classes:- The class includes physical classes or group of classes that are tangible and devices with which the application interacts.

Dept. of Information Technology SVECW

45

UML Manual

3. Use case driven approach:The use cases are considered as a problem driven approach. These objects are found in use case modeling. Once the system is defined in terms of its scenarios, the textual descriptions are examined to determine what objects are required for the scenarios to occur. The process of creating the sequence and collaboration diagrams is a systematic way to think about how a use case can take place. The sequence and collaboration diagram are used for low level view of a system. The Use case diagram offers a high-level view of a system.

4.CRC Approach: (Classes, Responsibilities and Collaborations) Two main questions have to be answered when designing classes in these approaches. 1. What are the objects used in this system? 2. Which objects are responsibilities for which functions? Identify classes and responsibilities

Identifying Collaborators Relationship among classes:-

Assign responsibilities

Dept. of Information Technology SVECW

46

UML Manual

Relationship among classes


Relationship provides pathway for communication between objects. There are four kinds of relationships. 1. 2. 3. 4. Dependency (Uses) Generalization (Inheritance, is-a) Aggregation (whole-part) Association (defined relations)

1. Dependency:- Dependency describes a using relationship. Therefore change in specification of one class may effect other. 2. Generalization:- Generalization is described as an is-a-kind-of relationship. Classes are ordered with in a hierarchy: a super class is an abstraction of its subclass 3. Association:- Association represents the structural relationships between classes. They are bi-directional: there are several kinds of associations like cardinality, qualified association, OR association, N-ary association.

Association Class:- An association may be represented by a class to add attributes and operations to that association. The class of this type is a class like any other and as such it can participate in other relationship with in the model. The notation uses the dashed line to attach a class to an association. An association that contains attributes but does not participate in relationship with other class is called attribute association. In these case the class does nit carry a specific name. Performs Student Examination

Grade

4. Aggregation:- Aggregation represents the whole-part relationship. The hollow diamond is attached at the end of the path. The following criteria imply on aggregation: A class is a part of another class. The attributes of one class propagate to attributes of another class. An action on one class implies an action on other class. The objects of one class are subordinates of objects of another class.

Dept. of Information Technology SVECW

47

UML Manual

The Object-Oriented Approach: The fundamental idea behind object-oriented languages is to combine into a single unit both data and the functions that operate on that data. Such a unit is called an object. An objects functions, called member functions in C++, typically provide the only way to access its data. If you want to read a data item in an object, you call a member function in the object. It will read the item and return the value to you. You cant access the data directly. The data is hidden, so it is safe from accidental alteration. Data and its functions are said to be encapsulated into a single entity.

Object: An object is the basic runtime entity in an object-oriented system. An entity can store data and, send and receive messages. An instance of a class, the object contains data and the instructions to manipulate that data. An object takes up same space in the memory. It is used to store the object in the real world such as a bank account a person details etc.. Classes: A group of objects that share common properties and relationships in C++, a class is a new data type that contains member variables and member functions that operate on the variables. A class is defined with the keyword Class. The entire set of data and code of an object can be made a user-defined data type with the help of a class. In fact objects are variables of type class. A class serves as a plain, or template. It specifies what data and what functions will be included in objects of that class. Defining the class doesnt create any objects, just as the mere existence of a type int doesnt create any variables. A class is thus a collection of similar objects. Features In C++ Data Encapsulation: In OOP the data and the function are wrapped as a single unit. So closing the data as such is called data encapsulation. So that data is accessible only in that function. Data Abstraction: Representing the essential features without including the back ground details or explanations refer to data abstraction. The classes used the concept of abstraction and are defined as a list of abstract attributes.

Inheritance: The process of an object of one class acquiring the properties of the objects of another class is called inheritance. In OOP concept of inheritance provides the idea of reusability. The new classes can be derived from the existing classes having the combined features of both classes. An OOP class can be divided into subclasses. In C++ the original class is called the base class; other classes can be defined that share its characteristics, but add their own as well. These are called Dept. of Information Technology SVECW 48

UML Manual

derived classes. Derived classes inherit some characteristics from their base class, but add new ones of their own. Reusability: Once a class has been written, created and debugged, it can be distributed to other programmers for use in their own programs this is called reusability. It is similar to the way a library of functions in a procedural language can be incorporated into different programs. The concept of inheritance provides an important extension to the idea of reusability. A programmer can take an existing class, and, without modifying it, add additional features and capabilities to it. This is done by deriving a new class from the existing one. The new class will inherit the capabilities of the old one, but is free to add new features of its own. Polymorphism: Polymorphism is another important OOP concept. It means the ability to take more than one form. In OOP the functions and objects shows polymorphism. A single function name can be used to handle different number of arguments and different types of arguments. The polymorphism allows the object having different internal structure to share the same external interface. Polymorphism is extensively used in implementing inheritance. A property by which we can send the same message to objects of several different classes, and each object can respond in a different way depending on its class. We can send such a message without knowing to which of the classes the object belongs. In C++, polymorphism is implemented by means of virtual functions and dynamic binding. The overloaded member functions are selected for invoking by matching arguments, both type and member. This information is known to the compiler at the compile time and, therefore, compiler is to select the appropriate function for a particular call at the compile time itself. This is called early binding or static binding or static linking. Also known as compile time polymorphism. If the appropriate member function selected while the program is running this is known as runtime polymorphism. C++ supports a mechanism known as runtime polymorphism. Since the function is linked with a particular class much later after the compilation. This process is termed as late binding or dynamic binding. Dynamic Binding: The dynamic binding means the set of instructions associated with a given procedure call is not known until the time of call at run-time. The instructions in a function dependent on its reference.

Message Communication: The OOP consists of a set of objects that communicate each other. The objects communicate with one another by sending received information in the same way as people pass message to one another. The concept of message pass is useful in building in direct model or their simulation system.

Dept. of Information Technology SVECW

49

UML Manual

Exception Handling: Exception handling is one of the advanced features of C++. It provides a mechanism to identify and manage certain error conditions during the execution of program. The purpose of the exception handling mechanism is to provide means to detect and report an exceptional circumstance so that appropriate action can be taken. The mechanism suggests a separate error handling code that performs the following tasks: 1. Find the problem (Hit the exception). 2. Inform that an error has occurred (Throw the exception). 3. Receive the error information (catch the exception). 4. Take corrective actions (Handle the exception). The error handling code basically consists of two segments, one to detect errors and to throw exceptions and the other to catch the exceptions and to take appropriate actions. Advantages of OOPs: There are several benefits with OOPs 1. The programmers can design better quality software with lesser maintenance cost. 2. With inheritance, the reusability of the code can be implemented. So redundant programming is avoided. 3. Data can be hidden so there is less possibility for another data access and wrong results. 4. It is easy to partition the work in a project based on objects. Software complexity can easily be managed.

Dept. of Information Technology SVECW

50

UML Manual

Using Rational Rose to Create Object-Oriented Diagrams


This is a brief overview to get students started in using Rational Rose to quickly create objectoriented models and diagrams. It is not by any means a complete introduction to Rational Rose, but it should get you started. A. GETTING STARTED: Click on Start, Programs, Rational Suite Development Studio 1.5, and then on Rational Rose 2000 Enterprise Edition. You will now see a window appearing that says Create New Model. This is for working with Java, Oracle, and VB. Just press Cancel. Next, you see the main window called Rational Rose- [untitled] and a smaller window within it called Class Diagram: Logical View / Main. There is also a browser on the left side of the page that has the diagrams that you are working on in the project. If you ever want to see the specifics on any diagram that you are working on, go to the browser, click on the + , and youll be able to see what is in that view. To close the view, click on the . B. USE-CASE DIAGRAM: 1. The first diagram youll be working on is a use-case diagram. Go to Browse and click on Use Case Diagram. You will get a window saying Select Use Case Diagram. Click on OK. You now will see a new window called Use Case Diagram: Use Case View / Main. You will see a set of tools to the left of this window. These tools are specific to the Use Case diagram and will be used to create it. To make a Use Case, go to the tools and click on the one that looks like an oval. This is the Use Case button. 2. Once you have clicked on the Use Case button, position the new mouse pointer wherever you want on the page and click again. The oval will now appear on the page. Now, type in a name for your Use Case. To reposition the Use Case, just click once on the Use Case. To change its property (name etc.) double click on the Use. 3. Now, we need to add some actors, which are actually the classes in this project. Click on the stick figure in the toolbox. Now, click anywhere on the Use Case Diagram to place the actor. Once again, name your actor. As with the use cases, to reposition the actor click once or change its name, double click on the actor. 4. Finally, we want to connect the use cases with the actors. In order to do this, click in the toolbox on the box that has the curved arrow that says Unidirectional Association. This will allow you accomplish this task. You are now finished with the Use Case Diagram portion of the project. Dont forget to save!!! C. CLASS DIAGRAM: 1. Now that we have defined our use-cases and actors, we need to create the class diagram. The first step is to go into the correct screen that is used for producing class diagrams. In order to do this, go to Browse and click on Class Diagram. Make sure to click on Class Diagram: Logical View / Main. You now will see a new window. Once again, you will see a set of tools to the left of this window. These tools are specific to the Class diagram and will be used to create it. 2. To create the classes, you need to click on the class icon. (Note: If you ever want to know if its the right button, just hold the mouse arrow over the button for two seconds, and it will tell you what the button is.) 3. Once you have clicked on the class button, position the new mouse pointer wherever you want on the page and click again. A rectangle representing the class will now appear on the page. Dept. of Information Technology SVECW 51

UML Manual

Now, type in a name for your class. To reposition the class, just click once on the class. To change its property like name, click twice. 4. Now we need to add some attributes to the class. Lets insert an attribute. To do this, right click on the class. Select new attribute. Now, type in the name of the attribute of the class. The icon that appears beside the attribute specifies whether it is public, private, or protected. 5. Now, we want to give the attributes their types, initialize the types, and distinguish the attributes as public, private, or protected. To do this, double click on the class anywhere that is blank. A new window called Class Specification will pop up. Click on attributes. Double click on the attribute that you want to select. Another new window called Class Attribute Specification pops up. In this window, you can initialize your attribute to any value, specify if its public, private, or protected, and give it the type. 6. Next, we add some methods to our class. To insert a method of the class, right click on the class and this time select new operation. Now, type in the name of the method of the class. We also want to add arguments for the new operation. To do this, once again, double click on the class anywhere that is blank. The Class Specification window will again pop up. Click on operations. Double click on the method that you want to select. Another new window called Operation Specification pops up. In this window, the General tab is already selected. (If not, select it). Here you can decide if the methods will be public, private, or protected. After doing this, select the Detail tab. Right click in the space below Name. Select insert. Now, type in the name of the argument. Hit tab to insert the arguments type. Hit tab again if you want to set the argument to default. Press OK and youre back to Operations. Press OK again. 7. Now that we have all the classes created, we can create an UNIDIRECTIONAL ASSOCIATION connection between classes. Click on the UNIDIRECTIONAL ASSOCIATION icon. Now, click on the first class, hold the mouse button down, drag the mouse to the other class, and release the mouse button. To name the association, double click on the association connection line. The Association Specification window pops up. Type the Association name in the space provided. Press OK. Now, we need to insert the cardinality of the class association. To do this, right click on the association connection line, next to the first class. Select multiplicity and finally select the correct cardinality. Do the same for the second class ** If you nave more than 1 association between 2 classes, be careful. If you select association between the 2 classes again, it will overlap the first one. Click on the line, drag the other association, and release it. You can change the association properties (name, cardinality by double clicking on them). 8. Its time for AGGREGATION. Its basically done the same way that Association is done. First create the UNIDIRECTIONAL ASSOCIATION connection as above. ** Create the aggregation by starting off on the class that you want the diamond attached to, then right click on the association line and press AGGREGATE. Dont forget to save!!! D. STATE DIAGRAMS 1.Up until now, we dealt with the entire system, all the classes and use cases. Now, were going to pick one of the classes and create a state diagram for it, specifically the book class. You need to let Rational Rose know which class youre going to use for the State Diagram. Select the book class by clicking on it once. Now, in the Browse menu, select State Machine Diagram. Click OK. Now a window New State Machine Diagram pops up. In the diagram type click on STATECHART. Click OK. The state chart diagram pops up with a tool bar besides it. 2. The first thing to do is get the Start State of the diagram. To do this, click on the black dot icon. This is the Start State. Position the new mouse pointer wherever you want on the page and click again. You can double click on the start state and change its property (name etc.). 3. Next, click on the State icon (which is a rectangular icon). Once you have clicked on the state button, position the new mouse pointer wherever you want on the page and click again. A Dept. of Information Technology SVECW 52

UML Manual

rounded rectangle representing the state will now appear on the page. Now, type in a name for your class by first double clicking on the state. To reposition the class, just click once on the class. To change its name, click twice. 4. Lets now give the transition between the states. To do this, click on the State Transition icon (which is an inclined arrow icon)on the tool bar. Click first on the state that the transition is coming from, and drag it to the state that the transition is going towards. To name the transition, double click on the transition and type in the name. 5. Continue this with all states. Finally, you should have an End State. The end state is reached when the item in the state diagram is thrown out. Connect the transition to this state in the same manner as you did with the other states. You can draw the End State by first clicking on the end state icon (a black dot with a circle around it), and then positioning it wherever you want it in the page. Dont forget to save!!!

E. SEQUENCE DIAGRAMS 1. The last diagram in this exercise is the Sequence Diagram. Once again, this is a dynamic diagram, like the state diagram. Go to the Browse menu and select Interaction Diagram. In the Select Interaction Diagram window that pops up, choose Logical View and click on OK. When the window New Interaction Diagram pops up, choose sequence as the diagram type and type the title. The tool bar comes beside the diagram. (Note: A Collaboration Diagram is almost the same as a Sequence Diagram. In this exercise, we will use the Sequence Diagram). 2. First, we need to choose the class objects that will be interacting in the diagram. To do this, choose the object icon (which is a rectangular icon). Position the new mouse pointer wherever you want on the page and click again. To name the class object, double click on the object (or click inside the rectangle and type). 3. To show a transition in the Sequence Diagram, click the right arrow icon, the Object Message icon. This is the Object Message icon used for transitions. Click on the vertical dotted line that extends from the bottom of the class object and drag it to the vertical dotted line of the second class object. 4. To make a self-transition, click on the U-turn arrow, the Message To Self icon. This is the Message to Self icon. No dragging is necessary. 5. To name either transition, double click on the transition and type in the name. ** Note: You can move the transitions slightly up or down as needed by clicking on them and dragging them. 5. Once you make a transition, the vertical dotted line of the class objects extend.

Dept. of Information Technology SVECW

53

UML Manual

UML Use case Diagram: An interaction between a user and a computer system (Use cases are about externally required functionality) A use case captures some user-visible function A usecase diagram is a diagram that shows a set of use cases and actors and their relationships. It is used to model the context of a system and to model the requirements of a system

UML Class diagram: The UML diagram was added to illustrate a sample e-commerce transaction in this case online shopping from a high level, in the form of a storyboard. This was shown to provide an overview of how such a transaction would play out in the context of e-business.

Dept. of Information Technology SVECW

54

UML Manual

UML Statechart Diagram:


Statechart diagrams are one of the five diagram in the UML for modeling the dynamic aspects of systems. A statechart diagram shows a state machine. A statechart diagram shows flow of control from state to state.

UML Activity Diagram:


Activity diagram are one of the five diagrams in the UML for modeling the dynamic aspects of systems. An activity diagram is essentially a flowchart, showing flow of control from activity to activity. UML Collaboration Diagram: A collaboration diagram is an interaction diagram that emphasizes the structural organization of the objects that send and receive messages. It shows a set of objects, links among those objects, and messages sent and received by those objects. Collaboration diagrams are use to illustrate the dynamic view of a system.

Dept. of Information Technology SVECW

55

UML Manual

UML Sequence Diagram: A sequence diagram emphasizes the time ordering of messages. It has 2 features that distinguish it from a collaboration diagram. First there is the object lifeline that is vertical dashed line in the diagram. Second, there is the focus of control. The focus of control is a tall, thin rectangle that shows the period of time during which an object is performing an action.

Dept. of Information Technology SVECW

56

UML Manual

UML Deployment Diagram: Deployment diagrams are one of the 2 kinds of diagrams used in modeling the physical aspects of an object-oriented system. A deployment diagram shows the configuration of run time processing nodes and the components that live on them.

UML Package Diagram: Packages diagrams are one of the 2 kinds of diagrams found in modeling the physical aspects of object-oriented systems. A package diagram shows the organization and dependencies among a set of packages.

Dept. of Information Technology SVECW

57

UML Manual

UML Object Diagram: An object diagram shows a set of of objects and their relationships at a point in time. Object diagrams address the static design view or static process view of a system.

Improvements: Modified the frame rate to 9 fps from the default 12 fps Introduced the concept of overcoming barriers Barriers shown time, location, and money Cleared the concept of Anytime, Anywhere, and Anything Animated the interaction of these three with the concept of overcome Added fading effects to the above when they entered and left their respective scenes Synchronized the motion of the three in a rotating pattern Elaborated into the concept of time by showing four examples of how industry is affected when we overcome it Added images and animation to the time example Elaborated into the concept of location by showing four examples of how industry is affected when we overcome it Animated images and animation to the location example Elaborated into the concept of money by showing three examples of how industry is affected when we overcome it Displayed the relationship that an e-company has when doing business with both customers and other businesses Named these relationships in an easier to follow and easier to understand method by keeping the customer, e-company, and businesses always in their respective side of the screen Animated the naming of these relationships as business to customer and business to business Dept. of Information Technology SVECW 58

UML Manual

Expanded into the idea of business to customer by citing a central idea to it which is the customer relationship management Expanded into the idea of business to business by citing a central idea to it which is eprocurement Summarized all the concepts by bringing them back together in another scene, with the emphasis being e-business, and the influence that it has over the concepts in a summarized form Brought back the globe, only that made it rotate, as to show the extent of the range e-business may reach Added a scene describing a sample e-commerce transaction through the use of a UML diagram following an e-commerce storyboard Changed the theme background music to one that follows the eclipsing momentum of the animation Added a few sound effects to some of the scenes to emphasize their appearance Reduced the number of layers by reusing those layers not active during certain scenes Reduced the clutter of images and motion tweens in the library by deleting duplicated entries reduced the number of objects shown on most given scenes, due to the human factor issue o

Dept. of Information Technology SVECW

59

UML Manual

Online Book Store


*Abstract: Online book shop is a computerized application that provides a better platform for supplying and purchasing books. This system provides a way for customers all over the world to purchase books by a simple click. This also provides a better way for supplier in the promotion of his sales. The web manager here plays an important role for promotion of sales. *Manual system: If customer wants a particular book, he/she has to approach a bookshop and ask the book seller, the particulars of the required book. The book seller searches for the book in the shop. If the book is present then it is handed to the customer otherwise the book seller intimates to the customer that the book is not present in his book store. If the customers need that book then customer places an order if he satisfies with the cost of the book and the delivery date. The customer has to pay some advance to the book seller. Then book seller places an order to the supplier. After the availability of the book that has been ordered, book seller has to inform the customer. Customer approaches the shop again and collects the book by paying the amount either in the form of cash or some remote services like credit /debit cards. *Problems in the manual system: 1. The customer is not guarantee about the availability of the books which he/she wants. 2. Customer has to go to the shop and knows about the available books. If the required book is not available then he/she has to place the order and wait for the book. All this is time taking process. 3. If the book shop is small then no matters otherwise the customer or the seller need to search for the book at differed places in the store. 4. Difficulty in maintaining sales records, purchase records and the details of customer by the book seller.

*Proposed systems: Every system has some drawbacks to overcome the problems in the manual system we must go for another system. Now a day every thing is done by the computerized applications. The knowledge of computers to develop different types of applications is developed vastly. So, the proposed systems must overcome the problems in the manual system. The proposed system is online bookshop. This system provides the facility of purchasing the book by using an internet connection. Not only providing facility but also the publicity of books.

The books available for the sale are placed in a particular website. Firstly, the new customer must register the name and enter into the web site. If the customer is already registered then the customer has to enter into the website through the login id. After the login, the page will be displayed. The details about the category of books are displayed in the page.

Dept. of Information Technology SVECW

60

UML Manual

These categories include subject, author, publication etc, and the customer selects the particular category and then he/she go through his/her work. If the books are available based on the category they are listed. The customer selects the required books, if the customer wants a particular book; he/she simply places its details and search for the availability of the book. The book will be searched & its details are opened in another window. If the book is not found, it will be reported to the customer. Modifications are also included in this online book shopping. These modifications include addition, deletion or updating. If the customer wants to select same more books he/she has to select additional books. After calculating the total amount if customer needed to reduce the total amount if customer needed to reduce the total cost incurred then the customer may delete some books. For addition of books, the customer searches for the page for other books. For deletion of books, he/she has to search all the books which are selected by him/her. Customer then confirms the order. After the confirmation, the web manager asks the user or customer the delivery address. The customer must initiate the web manager if he/she would like to send books to their friends and their address. The web manager should be aware of transport charges as the transport of the books which are selected by the customer may be done either by road ways, railways or airways. The web manager must be in a position to maintain all the details of the customers and their orders. The bills are paid either in the form of DD, cheque or by some remote services like credit cards & debit cards. *Dependent users: Customer: Here the customer is the person who utilizes the on-line book shop for his need the customer sits in front of the system and if the customer confirmed the order then the customer receives the order. Web manager: The web manager acts as an interface in promoting the sales between the customer and the supplier. The web manager maintains the list of stock supplied by the supplier and he is also responsible for the maintainance of the supplier details. The web manager make the publicity of the books by placed their details in the internet. The web manager receives the order of customer. He maintains the details of the customer. After the confirmation of the order from the customer, web manager supplies the order after receiving payments. Supplier: The supplier is the person who wants to make the sale of books. The supplier takes the membership in this process and the supplier gives the details of the book which are available for the sale. The web manager then places the book details within the web.

Dept. of Information Technology SVECW

61

UML Manual

Third party authorizer: The customer may pay the bill by using the remote services like credit cards and debit cards. For the receiving of payments by using these services the web manager go for the third party authorizer. He is responsible for checking the validity of the remote services. Recipient: The customer place the order and the order is to sent for himself/herself or to his/her friend or some one else , then that person becomes the recipient. The recipient is the customer itself or some one else. So, when the customer enters the shipping details the customer must enter the recipient address to make sure the delivery of books to the correct recipient. *Requirements: Requirements are capabilities and conditions to which the system and more broadly, the project must conform. A prime challenge of requirements work is to find, communicate and remember what is really needed, in a form that clearly speaks to the client and development team members. There are three types of requirements. Functional requirements Non-functional requirements Software requirements *Functional requirements: Functional requirements include important roles (a) (b) (c) Customer: Customer Supplier Web manager

The functions of customer includes 1) Registration/login: The new user or customer has to register and then login in to the site. already registered then he/she directly login into the site.

If the customer is

2) Browse & select the books: The customer has to browse the site and select the required books. The selected books are placed in a shopping cart. 3) Modifications in the shopping cart: The selected books are placed in the shopping cart and before placing the order the customer may modify them. The modifications include Adding books: The y add the books if he/she wants.

Dept. of Information Technology SVECW

62

UML Manual

Delete the books: If the customer doesnt satisfied with the bill he/she can delete some books from the cart and then places the order. Updating of books: The customer can also change the no of books in the cart.

4) Place the order: The customer places the order after he/she fully satisfied with the selection and also the modifications. 5) Shipment details: The customer gives the shipment details if he/she wants to forward the order to his/her friends. 6) View the payment details: After the shipment details the customer view the payment details. If the customer satisfied with the payment details, then confirms the order or else logout from the site. 7) Confirmation of order: The next step is confirmation of order. The placed order should be confirmed by the customer. After confirmation of order, order details are stored in the database by the web manager. 8) Payments: After the customers confirm the order the web manager go for payment mode. The way in which the payment is done is also selected by the customer. Payment may be done in one of the forms as DD, cheque, credit cards, debit cards etc. If the customer wants to pay by credit/debit card the customer has to enter the card no and details of card. The web manager checks the validity of the card by using payment authorizer. a) Supplier: 1) Registration: The supplier should register himself in to the website. By paying, he becomes the member of it. He get the membership and by using the membership he can advertise his books in the website 2)place the books: The supplier supplies the books. The supplier gives the details of the books and these are placed in the website. The details of the books are maintained in the database by the web manager. b) Web manager: The web manager maintains the entire database used for the online book shop. 1) Check the validity of the user: The web manager must check the validity of the users i.e., who wants to use the webpage. The customer while entering the website he/she has to login by using their ids. If the id is invalid then the request must be rejected for checking the validity of the user the web manager has to maintain the customer list as well as the supplier list.

Dept. of Information Technology SVECW

63

UML Manual

2) Check the order status: The customer places the order and after confirmation of order it is placed in the database for the processing of the order. This is maintained by the web manager. He checks the order and maintained temporarily in the database before confirmation. 3) Maintaining the reports: The web manager is responsible for storage of all the data for lateral retrieval and also for maintaining the reports *Non-functional requirements: To design the online bookshop non-functional requirements include software professionals, system tools etc. *Software requirements: To implement this project we use different softwares like html, JavaScript, java, visual studio etc. The database is maintained using oracle, ms-access etc. security will be ensured to the customers who make their payment by using credit/debit cards using third party software.

Dept. of Information Technology SVECW

64

UML Manual

Online Book Shopping

Class Diagrams

ShoppingCar t Ca rtId : i nteger BookId : integer Qty : i nteger AddToShop ping Ca rt() updateCart() dele teCar t() Books BookId : integer BookNam e : String BookDes c : String CategoryId : char Publis herId : char AuthorId : char BookPrice : float QOh : integer BookWeight : float ISBNno : integer Im gpath : String SearchBook() SelectBooks () AddBooks () UpdateBooks ()

Category CategoryId : char CategoryNam e : String CatDes c : Str ing

ShippingMode ShippingMode Id : i nteger Mo de : Str ing Ma xDelDays : integer

Orders OrderNo : integer Ord erDate : date CartId : integer Shoppe rId : integer ShippingModeId : integer WrapCharges : float OrderProces s ed : char TotalCos t : float Exp Del Date : date CheckCreditForPaym ent() Confir mOr der () Shi pm ent Or derNo : i nteger ShipDate : date De li ver yStatu s : char ActualDel Date : date SendConfir mTo Cu s tom er () Country CountryId : i nteger Country : Str ing

Publis her PubId : char PubNam e : String PubAddres s : String pubDes c : String Wrapper Wr apper Id : i nteger De s cription : Str ing Wr apper Ra te : flo at Im gPath : Str ing

Author AuthorId : char AuthorNam e : String Des cription : String OrderDetai ls Or derNo : i nteger Boo kId : i nteger Qty : i nteg er Wra pperId : i nteg er Mes s age : Str in g Boo kCos t : fl oat enterPackageDetails () calcualteAm ount() Enter Re cip ientDetails () R eci pien t OrderNo : integer Fi rs tName : String Las tName : String Addres s : Str ing City : String State : String CountryId : i nte ger ZipCode : integer PhoneNo : i nte ger ShippingRate CountryId : integer ShippingModeId : integer RatePerPound : float

Shopper Sh opperId : i nte ger Firs tNam e : String Las tNam e : String Addres s : Str ing Ci ty : Str in g State : Str in g CountryId : integer Z ipCode : i nteger PhoneNo : integer CreditCardNo : integer CC Type : Str in g ExpiryDate : date e nter Regis tr ationDetai ls ()

Dept. of Information Technology SVECW

65

UML Manual

Online Book Shopping

Use Case Diagrams

Dept. of Information Technology SVECW

66

UML Manual

Online Book Shopping :: State Diagrams

Dept. of Information Technology SVECW

67

UML Manual

Online Book Shopping

Sequence Diagrams

Dept. of Information Technology SVECW

68

UML Manual

Online Book Shopping :: Sequence Diagrams

Dept. of Information Technology SVECW

69

UML Manual

Online Book Shopping :: Collaboration Diagrams

Dept. of Information Technology SVECW

70

UML Manual

Online Book Shopping :: Data Base Design Table Name: Shopping Cart (Transaction Table) Field CartId BookId Qty Data Type Number Number Number Width 8 8 6,2 Validation Primary Key Foreign Key Not null

Table Name: Books (Transaction Table) Field BookId BookName BookDescription CategoryId PublisherId AuthorId BookPrice Qoh BookWeight ISBNno Imgpath Data Type Number Varchar2 Varchar2 Char Char Char Number Number Number Varchar2 Varchar2 Width 8 20 150 3 3 3 6,2 4 4,2 15 20 Validation Primary Key Not null null Foreign Key Foreign Key Foreign Key Not null Not null

Table Name: Category (Master Table) Field Data Type CategoryId Char CategoryName Varchar2 CatDesc Varchar2 Table Name: Author (Master Table) Field AuthorId AuthorName Description Data Type Char Varchar2 Varchar2

Width 3 20 50

Validation Primary Key Not null

Width 3 20 100

Validation Primary Key Not null

Table Name: Publisher (Master Table) Field Data Type PublisherId Char PubName Varchar2 PubAddress Varchar2 PubDesc Varchar2

Width 3 20 75 100

Validation Primary Key Not null

Table Name: ShippingMode (Master Table) Field ShippingModeId Mode MaxDelDays Data Type Number Varchar2 Number Width 2 15 4 Validation Primary Key Not null Not null 71

Dept. of Information Technology SVECW

UML Manual

Table Name: Country (Master Table) Field Data Type CountryId Number Country Varchar2 Table Name: Shopper (Master Table) Field Data Type ShopperId Number FirstName Varchar2 LastName Varchar2 Email Varchar2 Address Varchar2` City Varchar2 State Varchar2 CountryId Number ZipCode Number PhoneNo Number CreditCardNo Number CCType Varchar2 ExpiryDate Date

Width 3 20

Validation Primary Key Not null

Width 10 20 20 20 75 15 15 3 10 15 20 10

Validation Primary Key Not null

Foreign Key

Table Name: Recipient (Transaction Table) Field Data Type Width OrderNo Number 8 FirstName Varchar2 20 LastName Varchar2 20 Email Varchar2 20 Address Varchar2` 75 City Varchar2 15 State Varchar2 15 CountryId Number 3 ZipCode Number 10 PhoneNo Number 15 Table Name: Orders (Transaction Table) Field Data Type OrderNo Number OrderDate Date CartId Number ShopperId Number ShippingModeId Number WrapCharges Number OrderProcessed Char TotalCost Number ExpDelDate Date

Validation Foreign Key Not null

Foreign Key

Width 8 8 10 2 6,2 1 6,2

Validation Foreign Key Not null Foreign Key Foreign Key Foreign Key Not null Not null Not null Not null

Dept. of Information Technology SVECW

72

UML Manual

Table Name: OrderDetails (Transaction Table) Field Data Type Width OrderNo Number 8 BookId Number 8 Qty Number 3 WrapperId Number 3 Message Varchar2 100 BookCost Number 6,2 Table Name: Wrapper (Master Table) Field Data Type WrapperId Number Description Varchar2 WrapperRate Number Imgpath Varchar2

Validation Primary Key Foreign Key Not null Foreign Key Not null

Width 3 50 6,2 20

Validation Primary Key Not null

Table Name: ShippingRate (Transaction Table) Field Data Type Width CountryId Number 3 ShippingModeId Number 2 RatePerPound Number 6,2

Validation Foreign Key Foreign Key Not null

Table Name: Shipment (Transaction Table) Field Data Type OrderNo Number ShipDate Date DeliveryStatus Varchar2 ActualDelDate Date

Width 8 15

Validation Foreign Key Not null Not null

Dept. of Information Technology SVECW

73

You might also like