diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 1/README.md b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 1/Experiment 1A/README.md similarity index 100% rename from Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 1/README.md rename to Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 1/Experiment 1A/README.md diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 1/Experiment 1A/Solution.java b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 1/Experiment 1A/Solution.java new file mode 100644 index 0000000..5f0a47d --- /dev/null +++ b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 1/Experiment 1A/Solution.java @@ -0,0 +1,336 @@ +/** +* Created with ComputerEngineeringLabs. +* User: mohan08p +* Date: 2016-10-08 +* Time: 08:52 PM +* To change this template use Tools | Templates. + */ +import java.io.*; + +class Solution +{ + public static void main(String[] args) throws Exception + { + int choice=0; + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + while(choice !=3) + { + System.out.println("\nEnter Choice:"); + System.out.println("1. Substitution Cipher"); + System.out.println("2. Transposition Cipher"); + System.out.println("3. Exit"); + System.out.println(); + System.out.print("Choice: "); + choice = Integer.parseInt(br.readLine()); + switch(choice) + { + case 1: System.out.println("SUBSTITUTION CIPHER"); substitution(); + break; + case 2: System.out.println("TRANSPOSITION CIPHER"); transposition(); + break; + case 3: System.out.println("CHAL NIKAL LE"); break; + default: System.out.println("Wrong Choice Entered"); break; + } + } + } + + public static void substitution() throws Exception + { + char[]og={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}; + char[]og1={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y',' Z'}; + char[] cp = new char[26]; + char[] cp1= new char[26]; + char[] ip = new char[99]; + char[] op ; + char[] dop; + char[] dop1 = new char[99]; + String acc=""; + String dacc = ""; + int key=0; + int opkey=0; + int len1=0; + int len2=0; + int temp=0; + int pos=0; + + BufferedReader br = new BufferedReader (new InputStreamReader(System.in)); + /*Ciphering*/ + + /*Accept The Key*/ + System.out.println("Please Enter the Key:"); + key = Integer.parseInt(br.readLine()); + /*Logic for Shift Array*/ + temp = 26-key; + for(int i=0;i<26;i++) + { + if(i=temp) + { + for(int j=0;j 1 coprime to 3120, e = 17 +Figure 2 -6. Choose d to satify de ~= 1 , i.e. d = e^-1 (mod(phi(n))) - d = 2753 +3. Do not click on links, download files or open attachments in emails from unknown senders. It is best to open attachments only when you are expecting them and know what they contain, even if you know the sender. -7. 17 * 2753 = 46801 = 1 + 15 * 3120. +###![Figure 3](https://github.com/mohan08p/ComputerEngineeringLabs/blob/master/Academics/B.E./SEM%20I/Cryptography%20and%20System%20Security(CSS)/Experiment%202/Untitled2.png) - The public key is (n = 3233, e = 17). For a padded message the encryption function is: +Figure 3 - m = c^d mod n = m^17 mod 3233 +4. Never email personal or financial information, even if you are close with the recipient. - The private key is (n = 3233, d = 2753). The decryption function is: + You never know who may gain access to your email account, or to the person’s account to whom you are + emailing. +###![Figure 4](https://github.com/mohan08p/ComputerEngineeringLabs/blob/master/Academics/B.E./SEM%20I/Cryptography%20and%20System%20Security(CSS)/Experiment%202/Untitled3.png) - m = c^d mod n = c^2753 mod 3233 +Figure 4 -For e.g. to encrypt m = 123, we calculate, +5. Beware of links in emails that ask for personal information, even if the email appears to come from an enterprise you do business with. Phishing web sites often copy the entire look of a legitimate web site, making it appear authentic. To be safe, call the legitimate enterprise first to see if they really sent that email to you. After all, businesses should not request personal information to be sent via email. - c = 123^17 mod 32 = 85 +6. Beware of pop-ups and follow these tips: -To decrypt c = 855, we calculate, + Never enter personal information in a pop-up screen. - m = 855^2753 mod 3233 = 123 + Do not click on links in a pop-up screen. -Both of these calculations can be computed efficiently using the square-and-multiply algorithm for modular exponentiation. + Do not copy web addresses into your browser from pop-ups. -**Conclusion:** + Legitimate enterprises should never ask you to submit personal information in pop-up screens, so don’t do it. +###![Figure 5](https://github.com/mohan08p/ComputerEngineeringLabs/blob/master/Academics/B.E./SEM%20I/Cryptography%20and%20System%20Security(CSS)/Experiment%202/Untitled4.png) -Thus we have studies RSA algorithm for encryption and decryption, using asymmetric key’s, i.e. using two different keys’ for encryption and decryption. We have successfully implemented a program to demonstrate the working of a RSA algorithm. +Figure 5 + +7. Protect your computer with a firewall, spam filters, anti-virus and anti-spyware software. Do some research to ensure you are getting the most up-to-date software, and update them all regularly to ensure that you are blocking from new viruses and spyware. + + Check your online accounts and bank statements regularly to ensure that no unauthorized transactions have + been made. + +**Conclusion:** Thus we have studied guidelines for identifying phishing techniques. diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled.png b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled.png new file mode 100644 index 0000000..c369ff9 Binary files /dev/null and b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled.png differ diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled1.png b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled1.png new file mode 100644 index 0000000..eabcd26 Binary files /dev/null and b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled1.png differ diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled2.png b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled2.png new file mode 100644 index 0000000..fbe98e7 Binary files /dev/null and b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled2.png differ diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled3.png b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled3.png new file mode 100644 index 0000000..8cbed6c Binary files /dev/null and b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled3.png differ diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled4.png b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled4.png new file mode 100644 index 0000000..fb31196 Binary files /dev/null and b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/Untitled4.png differ diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 3/README.md b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 3/README.md new file mode 100644 index 0000000..58fff82 --- /dev/null +++ b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 3/README.md @@ -0,0 +1,90 @@ +**Aim:** Write a program to demonstrate strength of RSA. + +**Theory:** + +RSA is an algorithm used by modern computers to encrypt and decrypt messages. It is an asymmetric cryptographic algorithm. Asymmetric means that there are two different keys. This is also called public key cryptography, because one of them can be given to everyone. The other key must be kept private. It is based on the fact that finding the factors of an integer is hard (the factoring problem). RSA stands for Ron Rivest, Adi Shamir and Leonard Adleman, who first publicly described it in 1978. A user of RSA creates and then publishes the product of two large prime numbers, along with an auxiliary value, as their public key. The prime factors must be kept secret. Anyone can use the public key to encrypt a message, but with currently published methods, if the public key is large enough, only someone with knowledge of the prime factors can feasibly decode the message. + +**Operation:** + +RSA involves a public key and private key. The public key can be known to everyone; it is used to encrypt messages. Messages encrypted using the public key can only be decrypted with the private key. The keys for the RSA algorithm are generated the following way: + + Choose two different large random prime numbers p and q. + + Calculate n = p * q. + + n is the modulus for the public key and the private keys. + + Calculate the totient:phi(n) = (p-1)(q-1). + + Choose an integer e such that 1 < e < phi(n), and e is coprime to phi(n) ie: e and phi(n) share no factors + other than 1; gcd(e, phi(n)) = 1. + + e is released as the public key exponent. + + Compute d to satisfy the congruence relation de ~= 1 mod(phi(n)) ie: de = 1 + k * phi(n) for some integer k. + + d is kept as the private key exponent. + +The public key is made of the modulus n and the public (or encryption) exponent e. + +The private key is made of the modulus n and the private (or decryption) exponent d which + +must be kept secret. + +Encrypting messages: + +Alice gives her public key ( & ) to Bob and keeps her private key secret. Bob wants to send message M to Alice. + +First he turns M into a number smaller than by using an agreed-upon reversible protocol known as a padding scheme. He then computes the ciphertext corresponding to: + +This can be done quickly using the method of exponentiation by squaring. Bob then sends to Alice. + +Decrypting messages: + +Alice can recover from by using her private key in the following procedure: + +Given , she can recover the original message M. + +The decryption procedure works. + +Example: + +Here is an example of RSA encryption and decryption. The parameters used here are artificially small, but you can also use OpenSSL to generate and examine a real key pair. + +1. Choose two random prime numbers + +2. p = 61 and q = 53 + +3. Compute n = p * q In this case, n = 61 * 53 = 3233 + +4. Compute the totient phi(n) = (p-1) * (q-1) + phi(n) = 3120 + +5. Choose e > 1 coprime to 3120, e = 17 + +6. Choose d to satify de ~= 1 , i.e. d = e^-1 (mod(phi(n))) + d = 2753 + +7. 17 * 2753 = 46801 = 1 + 15 * 3120. + + The public key is (n = 3233, e = 17). For a padded message the encryption function is: + + m = c^d mod n = m^17 mod 3233 + + The private key is (n = 3233, d = 2753). The decryption function is: + + m = c^d mod n = c^2753 mod 3233 + +For e.g. to encrypt m = 123, we calculate, + + c = 123^17 mod 32 = 85 + +To decrypt c = 855, we calculate, + + m = 855^2753 mod 3233 = 123 + +Both of these calculations can be computed efficiently using the square-and-multiply algorithm for modular exponentiation. + +**Conclusion:** + +Thus we have studies RSA algorithm for encryption and decryption, using asymmetric key’s, i.e. using two different keys’ for encryption and decryption. We have successfully implemented a program to demonstrate the working of a RSA algorithm. diff --git a/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/RSA.java b/Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 3/RSA.java similarity index 100% rename from Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 2/RSA.java rename to Academics/B.E./SEM I/Cryptography and System Security(CSS)/Experiment 3/RSA.java diff --git a/Academics/B.E./SEM I/NTAL/Experiment-No-1/README.md b/Academics/B.E./SEM I/NTAL/Experiment-No-1/README.md new file mode 100644 index 0000000..f5f0241 --- /dev/null +++ b/Academics/B.E./SEM I/NTAL/Experiment-No-1/README.md @@ -0,0 +1,88 @@ +**Aim:** Study the use of network reconnaissance tools like WHOIS, dig, traceroute, nslookup to gather information about networks and domain registers. + +**Theory:** + +**1. Whois** - whois searches for an object in a WHOIS database. WHOIS is a query and response protocol that is widely used for querying databases that store the registered users of an Internet resource, such as a domain name or an IP HYPERLINK "http://www.computerhope.com/jargon/a/address.htm" address block, but is also used for a wider range of other information. Most modern versions of whois try to guess the right server to ask for the specified object. If no guess can be made, whois will connect to whois.networksolutions.com for NIC handles or whois.arin.net for IPv4 addresses and network names. +Examples: Obtaining the domain WHOIS record for computersolutions.com + + WHOIS record by IP querying + +**2. Dig** - Dig is a networking tool that can query DNS servers for information. It can be very helpful for diagnosing problems with domain pointing and is a good way to verify that yourconfigurationbis working. +The most basic way to use dig is to specify the domain we wish to query: + + dig example.com + + dig duckduckgo.com + ; <<>> DiG 9.8.1-P1 <<>> duckduckgo.co m ;; global options: +cmd + %1 Got answer: + %1 ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64399 + %1 flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0 + %1 QUESTION SECTION: + ;duckduckgo.com. IN A + ;; ANSWER SECTION: + + duckduckgo.com. 99 I N + A 107.21.1.61 + duckduckgo.com. 99 I N + A 184.72.106.2 53 + duckduckgo.com. 99 I N + A 184.72.106.5 2 + duckduckgo.com. 99 I N + A 184.72.115.8 6 + %1 Query time: 33 msec + %1 SERVER: 8.8.8.8#53(8.8.8.8) + %1 WHEN: Fri Aug 23 14:26:17 2013 + %1 MSG SIZE rcvd: 96 + The lines above act as a header for the query performed. It is possible to run dig in batch mode, so proper labeling of the output is essential to allow for correct analysis. + %1 Got answer: + %1 ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 64399 + %1 flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0 + + The next section gives us a technical summary of our query results. We can see that the query was successful, certain flags were used, and that 4 "answers" were received. + ;; QUESTION SECTION: + ;duckduckgo.com. IN A + ;; ANSWER SECTION: + + duckduckgo.com. 99 I N + A 107.21.1.61 + duckduckgo.com. 99 I N + A 184.72.106.2 53 + duckduckgo.com. 99 I N + A 184.72.106.5 2 + duckduckgo.com. 99 I N + A 184.72.115.8 6 + The above section of the output contains the actual results we were looking for. It restates the query and then returns the matching DNS records for that domain name. + Here, we can see that there are four "A" records for "duckduckgo.com". By default, "A" records are returned. This gives us the IP addresses that the domain name resolves to. + The "99" is the TTL (time to live) before the DNS server rechecks the association between the domain name and the IP address. The "IN" means the class of the record is a standard internet class. + %1 Query time: 33 msec + %1 SERVER: 8.8.8.8#53(8.8.8.8) + %1 WHEN: Fri Aug 23 14:26:17 2013 + %1 MSG SIZE rcvd: 96 + These lines simply provide some statistics about the actual query results. The query time can be indicative of problems with the DNS servers. + +**3. Traceroute** - traceroute prints the route that packets take to a network host. Traceroute utility uses the TTL field in the IP header to achieve its operation. For users who are new to TTL field, this field describes how much hops a particular packet will take while traveling on network. So, this effectively outlines the lifetime of the packet on network. This field is usually set to 32 or 64. Each time the packet is held on an intermediate router, it decreases the TTL value by 1. When a router finds the TTL value of 1 in a received packet then that packet is not forwarded but instead discarded. After discarding the packet, router sends an ICMP error message of Time exceeded back to the source from where packet generated. The ICMP packet that is sent back contains the IP address of the router. So now it can be easily understood that traceroute operates by sending packets with TTL value starting from 1 and then incrementing by one each time. Each time a router receives the packet, it checks the TTL field, if TTL field is 1 then it discardsthe packet and sends the ICMP error packet containing its IP address and this is what traceroute requires. So traceroute incrementally fetches the IP of all the routers between the source and the destination. + + Example: traceroute example.com + traceroute to example.com (64.13.192.208), 64 hops max, 40 byte packets + 1 72.10.62.1 (72.10.62.1) 1.000 ms 0.739 ms 0.702 ms + 2 10.101.248.1 (10.101.248.1) 0.683 ms 0.385 ms 0.315 ms + 3 10.104.65.161 (10.104.65.161) 0.791 ms 0.703 ms 0.686 ms + 4 10.104.65.161 (10.104.65.161) 0.791 ms 0.703 ms 0.686 ms + 5 10.0.10.33 (10.0.10.33) 2.652 ms 2.260 ms 5.353 ms + 6 acmkokeaig.gs01.gridserver.com (64.13.192.208) 3.384 ms 8.001 ms 2.439 ms + +**4.Nslookup** - The nslookup command is used to query internet name servers interactively for information. nslookup, which stands for "name server lookup", is a useful tool for finding out information about a named domain. By default, nslookup will translate a domain name to an IP address (or vice versa). For instance, to find out what the IP address of microsoft.com is, you could run the command: + + nslookup microsoft.com + Server: 8.8.8.8 + Address: 8.8.8.8#53 + Non-authoritative answer: + Name: + microsoft.com + Address: 134.170.185.46 + Name: + microsoft.com + Address: 134.170.188.221 + Here, 8.8.8.8 is the address of our system's Domain Name Server. + + This is the server our system is configured to use to translate domain names into IP addresses. "#53" indicates that we are communicating with it on port 53, which is the standard port number domain name servers use to accept queries. Below this, we have our lookup information for microsoft.com. Our name server returned two entries, 134.170.185.46 and 134.170.188.221. This indicates that microsoft.com uses a round robin setup to distribute server load. When you access micrsoft.com, you may be directed to either of these servers and your packets will be routed to the correct destination. You can see that we have received a "Non-authoritative answer" to our query. Ananswer is "authoritative" only if our DNS has the complete zone file information for the domain in question. More often, our DNS will have a cache of information representing the last authoritative answer it received when it made a similar query, this information is passed on to you, but the server qualifies it as "non-authoritative": the information was recently received from an authoritative source, but the DNS server is not itself that authority. diff --git a/Academics/B.E./SEM I/NTAL/Experiment-No-2/README.md b/Academics/B.E./SEM I/NTAL/Experiment-No-2/README.md new file mode 100644 index 0000000..eecae7f --- /dev/null +++ b/Academics/B.E./SEM I/NTAL/Experiment-No-2/README.md @@ -0,0 +1,47 @@ +**Aim :** Study of packet sniffer tools like wireshark, ethereal, tcpdump etc. + +**Theory:** + +Wireshark, a network analysis tool formerly known as Ethereal, captures packets in real time and display them in human readable format. Wireshark includes filters, color-coding and other features that let you dig deep into network traffic and inspect individual packets. + +**Applications:** + Network administrators use it to troubleshoot network problems. + Network security engineers use it to examine security problems. + Developers use it to debug protocol implementations. + People use it to learn network protocol internals beside these examples can be helpful in many other situations too. + +**Features:** + +The following are some of the many features wireshark provides: + + Available for UNIX and Windows. Capture live packet data from a network interface. + Open files containing packet data captured with *tcpdump/WinDump*, Wireshark, and a number of other packet capture + programs. + Import packets from text files containing hex dumps of packet data. + Display packets with very detailed protocol information. + Export some or all packets in a number of capture file formats. + Filter packets on many criteria. Search for packets on many criteria. + Colorize packet display based on filters. + Create various statistics. + +**Capturing Packets** + +After downloading and installing wireshark, you can launch it and click the name of an interface under Interface List to start capturing packets on that interface. +For example, if you want to capture traffic on the wireless network, click your wireless interface. You can configure advanced features by clicking Capture Options. +As soon as you click the interface‘s name, you‘ll see the packets start to appear in real time. Wireshark captures each packet sent to or from your system. If you‘re capturing on a wireless interface and have *promiscuous mode* enabled in your capture options, you‘ll also see other packets on the network. + +Wireshark uses colors to help you identify the types of traffic at a glance. By default, green is TCP traffic, dark blue is DNS traffic, light blue is UDP traffic, and black identifies TCP packets with problems — for example, they could have been delivered out-of-order. + +**Filtering Packets** + +If you‘re trying to inspect something specific, such as the traffic program sends when phoning home, it helps to close down all other applications using the network so you can narrow down the traffic. Still, you‘ll likely have a large amount of packets to sift through. That‘s where Wireshark‘s filters come in. The most basic way to apply a filter is by typing it in to the filterbox at the top of the window and clicking Apply(orpressingEnter). For example, type ―dns‖ and you‘ll see only DNS packets. When you start typing, Wireshark will help you autocomplete your filter. + +**Inspecting Packets** + +Click a packet to select it and you can dig down to view its details. +You can also create filters from here — just right-click one of the packet and get details and use the Apply as Filter submenu to create a filter based on it. + +**Conclusion :** + + Wireshark is an extremely powerful tool, and this tutorial is just scratching the surface of what you can do with it. Professionals use it to debug network protocol implementations, examine security problems and inspect network protocol internals. + diff --git a/Academics/B.E./SEM I/NTAL/Experiment-No-3/README.md b/Academics/B.E./SEM I/NTAL/Experiment-No-3/README.md new file mode 100644 index 0000000..80d8b67 --- /dev/null +++ b/Academics/B.E./SEM I/NTAL/Experiment-No-3/README.md @@ -0,0 +1,32 @@ +**Aim :** Download and install nmap. Use it with different options to scan open ports, perform OS​ ​fingerprinting, do a ping scan, tcp port scan, udp port scan, etc. + +**Objective :** Objective of this module to learn nmap installation & use this to scan different ports. + +**Scope :** Used for ip spoofing and port scanning Technology​: Networking + +**Theory:** + +Nmap(Network Mapper) is a security scanner originally written by Gordon Lyon(also known by his pseudonym Fyodor Vaskovich) used to discover hosts and services on a computer network, thus creating a "map" of the network. To accomplish its goal, Nmap sends specially crafted packets to the target host and then analyzes the responses. Unlike many simple port scanners that just send packets at some predefined constant rate, Nmap accounts for the network conditions (latency fluctuations, network congestion, the target interference with the scan) during the run. Also, owing to the large and active user community providing feedback and contributing to its features, Nmap has been able to extend its discovery capabilities beyond simply figuring out whether a host is up or down and which ports are open and closed; it can determine the operating system of the target, names and versions of the listening services, estimated uptime, type of device, and presence of a firewall. + +*Nmap features include:* + + Host Discovery – Identifying hosts on a network. For example, listing the hosts which respond to pings or have a particular port open. + Port Scanning – Enumerating the open ports on one or more target hosts. + Version Detection – Interrogating listening network services listening on remote devices to determine the application name and version number. + OS Detection – Remotely determining the operating system and some hardware characteristics of network devices. + + +Basic commands working in Nmap + +For target specifications: + + nmap target‘s URL or IP with spaces between them + +For OS detection: + + nmap -O target-host's URL or IP + +For version detection: + + nmap -sV target-host's URL or IP + diff --git a/Academics/B.E./SEM II/AI/List.md b/Academics/B.E./SEM II/AI/List.md new file mode 100644 index 0000000..b531170 --- /dev/null +++ b/Academics/B.E./SEM II/AI/List.md @@ -0,0 +1,20 @@ +# Artificial Intelligence Labs + +| Sr No. | Experiment Name | +| --- | --- | +| 1. | Design any new intelligent product/service based on NLP/Expert system. Refer papers or patents published in IEEE/ACM/Springer or any prominent journal. | +| 2. | Give PEAS descriptor and identify properties of task environment and type of agent for given problems. | +| 3. | Identify any AI Problem (eg. River Crossing, water Jug, Brain Vita marbles etc) find its state space and find the solution for the same.| +| 4. | Program on any one uninformed search methods.| +| 5. | Program on any one informed search methods | +| 6. | Introduction to Prolog and any two programs on prolog | +| 7. | Program on adversarial search| +| 8. | Program on Wumpus world | +| 9. | Program on Local Search | +| 10. | Program on Decision Tree. | + + +## Assignemtns + +1. Introduction to AI and Intelligent Agent ,Problem Solving. +2. Knowledge Representation, Reasoning and Planning. \ No newline at end of file diff --git a/Academics/B.E./SEM II/PDS Labs/Exp 5 : Clock Synchronization algorithms/README.md b/Academics/B.E./SEM II/PDS Labs/Exp 5 : Clock Synchronization algorithms/README.md index b975f72..18d4edc 100644 --- a/Academics/B.E./SEM II/PDS Labs/Exp 5 : Clock Synchronization algorithms/README.md +++ b/Academics/B.E./SEM II/PDS Labs/Exp 5 : Clock Synchronization algorithms/README.md @@ -1,4 +1,4 @@ -Exp 8 : Clock Synchronization algorithms +## Exp 8 : Clock Synchronization algorithms Program to demonstrate Berkeley Clock Synchronization algorithm @@ -9,7 +9,7 @@ Clock synchronization deals with understanding the temporal ordering of events p In a Distributed System, the problem takes on more complexity because the global time is not easily known. Most of the Clock Synchronization Solutions on the internet is the Network Time Protocol(NTP) which is a layered client-server architecture based on UDP message passing. Lamport timestamps and Vector clocks are concepts of the logical clocks in a distributed system. -Berkeley's Algorithm +## Berkeley's Algorithm The Berkeley's Algorithm, does not assume that any machine has an accurate time source with which to synchronize. Instead, it opts for obtaining an average time from participating computers and synchronizing all machines to that average. @@ -24,4 +24,4 @@ three timestamps: the two it received and its own, computing (3:00+3:25+2:50)/3 Now it sends an offset to each machine so that the machine's time will be synchronized to the average once the offset is applied. The machine with a time of 3:25 gets sent an offset of ­0:20 and the machine with a time of 2:50 gets an offset of +0:15. The server has to adjust its -own time by +0:05. \ No newline at end of file +own time by +0:05. diff --git a/Academics/B.E./SEM II/PDS Labs/Exp 8 : CORBA Architecture/README.md b/Academics/B.E./SEM II/PDS Labs/Exp 8 : CORBA Architecture/README.md index 47ad81e..658a0bd 100644 --- a/Academics/B.E./SEM II/PDS Labs/Exp 8 : CORBA Architecture/README.md +++ b/Academics/B.E./SEM II/PDS Labs/Exp 8 : CORBA Architecture/README.md @@ -30,6 +30,7 @@ The Java IDL Development Process and the Hello World Application - Creating HelloClient.java - Understanding HelloClient.java - Compiling HelloClient.java + javac HelloClient.java HelloApp/*.java 5. Start the applications(To run this client-server application on your development machine): diff --git a/Academics/B.E./SEM II/PDS Labs/MPI/MPIinstallationGuide.md b/Academics/B.E./SEM II/PDS Labs/MPI/MPIinstallationGuide.md new file mode 100644 index 0000000..d92df35 --- /dev/null +++ b/Academics/B.E./SEM II/PDS Labs/MPI/MPIinstallationGuide.md @@ -0,0 +1,36 @@ +Steps to install & configure the MPI(For Stand-alone machine), + +1. Download **MPICH3.2 stable** from following link, + http://www.mpich.org/downloads/ + +2. **Extract** the tar with command, + **tar -xvf mpich-3.2.tar.gz** + And, go into the directory /mpich-3.2 + + +3. Then disable the** fortran** with command, + **./configure --disable-fortran** + + +4. Finally, last command, + **make; sudo make all** + +5. Before compiling the program you need to download some library into your workspace, as given in the steps, + + sudo apt-get install lam4-dev + + sudo apt-get install libmpich-dev + + sudo apt-get install libopenmpi-dev + + +Then we can start executing our **MPI program on gcc compiler**. + +For Running MPI cluster with-in a LAN, follow this tutorial guide link, +http://mpitutorial.com/tutorials/running-an-mpi-cluster-within-a-lan/ + +**GitHub Tutorials Link** : [MPI programming lessons in C and executable code examples ](https://github.com/wesleykendall/mpitutorial/) + + + + diff --git a/Academics/B.E./SEM II/PDS Labs/MPI/Matrix Multiplication/MPIMatrixMulWithTime.c b/Academics/B.E./SEM II/PDS Labs/MPI/Matrix Multiplication/MPIMatrixMulWithTime.c new file mode 100644 index 0000000..2dab6dd --- /dev/null +++ b/Academics/B.E./SEM II/PDS Labs/MPI/Matrix Multiplication/MPIMatrixMulWithTime.c @@ -0,0 +1,120 @@ +#include "mpi.h" +#include +#include +# include + +#define NRA 82 /* number of rows in matrix A */ +#define NCA 82 /* number of columns in matrix A */ +#define NCB 82 /* number of columns in matrix B */ +#define MASTER 0 /* taskid of first task */ +#define FROM_MASTER 1 /* setting a message type */ +#define FROM_WORKER 2 /* setting a message type */ + +int main (int argc, char *argv[]) +{ +int numtasks, /* number of tasks in partition */ + taskid, /* a task identifier */ + numworkers, /* number of worker tasks */ + source, /* task id of message source */ + dest, /* task id of message destination */ + mtype, /* message type */ + rows, /* rows of matrix A sent to each worker */ + averow, extra, offset, /* used to determine rows sent to each worker */ + i, j, k, rc; /* misc */ +double a[NRA][NCA], /* matrix A to be multiplied */ + b[NCA][NCB], /* matrix B to be multiplied */ + c[NRA][NCB], wtime; /* result matrix C */ +MPI_Status status; +clock_t start_t, end_t, total_t; + +MPI_Init(&argc,&argv); /* MPI starts here */ +MPI_Comm_rank(MPI_COMM_WORLD,&taskid); +MPI_Comm_size(MPI_COMM_WORLD,&numtasks); +if (numtasks < 2 ) { + printf("Need at least two MPI tasks. Quitting...\n"); + MPI_Abort(MPI_COMM_WORLD, rc); + exit(1); + } +numworkers = numtasks-1; + +start_t = clock(); + +/**************************** master task ************************************/ + if (taskid == MASTER) + { + printf("mpi_mm has started with %d tasks.\n",numtasks); + printf("Initializing arrays...\n"); + for (i=0; i MASTER) + { + mtype = FROM_MASTER; + MPI_Recv(&offset, 1, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status); + MPI_Recv(&rows, 1, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status); + MPI_Recv(&a, rows*NCA, MPI_DOUBLE, MASTER, mtype, MPI_COMM_WORLD, &status); + MPI_Recv(&b, NCA*NCB, MPI_DOUBLE, MASTER, mtype, MPI_COMM_WORLD, &status); + + for (k=0; k +#include + +#define NRA 62 /* number of rows in matrix A */ +#define NCA 15 /* number of columns in matrix A */ +#define NCB 7 /* number of columns in matrix B */ +#define MASTER 0 /* taskid of first task */ +#define FROM_MASTER 1 /* setting a message type */ +#define FROM_WORKER 2 /* setting a message type */ + +int main (int argc, char *argv[]) +{ +int numtasks, /* number of tasks in partition */ + taskid, /* a task identifier */ + numworkers, /* number of worker tasks */ + source, /* task id of message source */ + dest, /* task id of message destination */ + mtype, /* message type */ + rows, /* rows of matrix A sent to each worker */ + averow, extra, offset, /* used to determine rows sent to each worker */ + i, j, k, rc; /* misc */ +double a[NRA][NCA], /* matrix A to be multiplied */ + b[NCA][NCB], /* matrix B to be multiplied */ + c[NRA][NCB]; /* result matrix C */ +MPI_Status status; + +MPI_Init(&argc,&argv); +MPI_Comm_rank(MPI_COMM_WORLD,&taskid); +MPI_Comm_size(MPI_COMM_WORLD,&numtasks); +if (numtasks < 2 ) { + printf("Need at least two MPI tasks. Quitting...\n"); + MPI_Abort(MPI_COMM_WORLD, rc); + exit(1); + } +numworkers = numtasks-1; + + +/**************************** master task ************************************/ + if (taskid == MASTER) + { + printf("mpi_mm has started with %d tasks.\n",numtasks); + printf("Initializing arrays...\n"); + for (i=0; i MASTER) + { + mtype = FROM_MASTER; + MPI_Recv(&offset, 1, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status); + MPI_Recv(&rows, 1, MPI_INT, MASTER, mtype, MPI_COMM_WORLD, &status); + MPI_Recv(&a, rows*NCA, MPI_DOUBLE, MASTER, mtype, MPI_COMM_WORLD, &status); + MPI_Recv(&b, NCA*NCB, MPI_DOUBLE, MASTER, mtype, MPI_COMM_WORLD, &status); + + for (k=0; k +#include +# include + +#define NRA 82 /* number of rows in matrix A */ +#define NCA 82 /* number of columns in matrix A */ +#define NCB 82 /* number of columns in matrix B */ + +int main (int argc, char *argv[]) +{ +int i, j, k, rc; /* misc */ +double a[NRA][NCA], /* matrix A to be multiplied */ + b[NCA][NCB], /* matrix B to be multiplied */ + c[NRA][NCB], wtime; /* result matrix C */ + + + clock_t start_t, end_t, total_t; + start_t = clock(); + printf("Initializing arrays...\n"); + for (i=0; i // MPI C standard header file +#include + +int main(int argc, char** argv) { + // Initialize the MPI environment + MPI_Init(NULL, NULL); + + // Get the number of processes + int world_size; + MPI_Comm_size(MPI_COMM_WORLD, &world_size); + + // Get the rank of the process + int world_rank; + MPI_Comm_rank(MPI_COMM_WORLD, &world_rank); + + // Get the name of the processor + char processor_name[MPI_MAX_PROCESSOR_NAME]; + int name_len; + MPI_Get_processor_name(processor_name, &name_len); + + // Print off a hello world message + printf("Hello world from processor %s, rank %d" + " out of %d processors\n", + processor_name, world_rank, world_size); + + // Finalize the MPI environment. + MPI_Finalize(); +} diff --git a/Academics/B.E./SEM II/PDS Labs/OpenMP/Run.md b/Academics/B.E./SEM II/PDS Labs/OpenMP/Run.md new file mode 100644 index 0000000..4460b5d --- /dev/null +++ b/Academics/B.E./SEM II/PDS Labs/OpenMP/Run.md @@ -0,0 +1,9 @@ +# Compiling and running OpenMP + +### Compiling OpenMp Program + + $gcc -o hello_omp hello_omp.c –fopenmp + +### Running OpenMP program + + $./hello_omp \ No newline at end of file diff --git a/Academics/B.E./SEM II/PDS Labs/OpenMP/add.c b/Academics/B.E./SEM II/PDS Labs/OpenMP/add.c new file mode 100644 index 0000000..ac4b79b --- /dev/null +++ b/Academics/B.E./SEM II/PDS Labs/OpenMP/add.c @@ -0,0 +1,27 @@ +#include // OpenMP header file +#include +#include +# include +#define CHUNKSIZE 100 // Define the chunk which process at a time +#define N 200000 + +int main (int argc, char *argv[]) +{ +int nthreads, tid, i, chunk; +float a[N], b[N], c[N]; + +/* Some initializations */ +for (i=0; i < N; i++) + a[i] = b[i] = i * 1.0; +chunk = CHUNKSIZE; + + + double start = omp_get_wtime(); // Returns a value in seconds of the time elapsed from some arbitrary, but consistent point. + for (i=0; i // OpenMP header file +#include +#include +# include +#define CHUNKSIZE 100 +#define N 100000 + +int main (int argc, char *argv[]) +{ +int nthreads, tid, i, chunk; +float a[N], b[N], c[N]; + +/* Some initializations */ + for (i=0; i < N; i++) + a[i] = b[i] = i * 1.0; + chunk = CHUNKSIZE; + + clock_t start_t, end_t, total_t; + start_t = clock(); // C program clock starts + double start = omp_get_wtime(); // openMP clock starts + #pragma omp parallel shared(a,b,c,nthreads,chunk) private(i,tid) + // open MP code inside this block + { + tid = omp_get_thread_num(); // Returns the thread identification number, from 0 to n-1 where n are no of active thread + if (tid == 0) + { + nthreads = omp_get_num_threads(); // Returns the no of threads active in the current parallel region + printf("Number of threads = %d\n", nthreads); + } + printf("Thread %d starting...\n",tid); + + #pragma omp for schedule(dynamic,chunk) + for (i=0; i