chiwormjava 2.0.1 → 2.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/java.json +29 -52
  2. package/package.json +1 -1
  3. package/readme.md +197 -170
package/java.json CHANGED
@@ -1,62 +1,39 @@
1
1
  {
2
- "palindrome_user_input_java": {
3
- "title": "Java Palindrome Number with User Input",
4
- "code": "import java.util.Scanner;\\n\\npublic class Palindrome {\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\n\\t\\tSystem.out.print(\\\"Enter a number: \\\" );\\n\\t\\tint num = sc.nextInt();\\n\\n\\t\\tint original = num;\\n\\t\\tint reverse = 0;\\n\\n\\t\\twhile (num > 0) {\\n\\t\\t\\tint digit = num % 10;\\n\\t\\t\\treverse = reverse * 10 + digit;\\n\\t\\t\\tnum = num / 10;\\n\\t\\t}\\n\\n\\t\\tif (original == reverse) {\\n\\t\\t\\tSystem.out.println(\\\"Palindrome Number\\\");\\n\\t\\t} else {\\n\\t\\t\\tSystem.out.println(\\\"Not a Palindrome\\\");\\n\\t\\t}\\n\\n\\t\\tsc.close();\\n\\t}\\n}"
2
+ "classful_classless_routing_practical": {
3
+ "title": "Classful and Classless Routing Configuration using Packet Tracer",
4
+ "code": "Step 1: Place devices\\nAdd in Packet Tracer:\\n2 Routers (2621XM)\\n2 Switches (2960)\\n4 PCs\\n\\nArrange as:\\nPC1 PC2 PC3 PC4\\n | | | |\\nSwitch1 Switch2\\n | |\\n Router1 ---- WAN ---- Router2\\n\\nStep 2: Add Serial Ports\\nClick Router -> Physical tab\\nTurn Power OFF\\nInsert WIC-2T module\\nTurn Power ON\\nNow Serial0/0/0 and Serial0/0/1 will be available\\n\\nStep 3: Connect cables\\nLAN:\\nPC to Switch using Copper Straight-Through\\nSwitch to Router using Copper Straight-Through\\n\\nWAN:\\nUse Serial DCE cable\\nRouter1 Serial0/0/0 to Router2 Serial0/0/0\\n\\nStep 4: Configure Router1\\nenable\\nconfigure terminal\\n\\ninterface gigabitEthernet 0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\ninterface serial 0/0/0\\nip address 172.16.1.1 255.255.255.252\\nclock rate 64000\\nno shutdown\\nexit\\n\\nStep 5: Configure Router2\\nenable\\nconfigure terminal\\n\\ninterface gigabitEthernet 0/0\\nip address 10.0.0.1 255.255.255.248\\nno shutdown\\nexit\\n\\ninterface serial 0/0/0\\nip address 172.16.1.2 255.255.255.252\\nno shutdown\\nexit\\n\\nStep 6: Configure PCs\\nLeft network:\\nPC1 IP 192.168.1.2 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC2 IP 192.168.1.3 Gateway 192.168.1.1\\n\\nRight network:\\nPC3 IP 10.0.0.2 Mask 255.255.255.248 Gateway 10.0.0.1\\nPC4 IP 10.0.0.3 Gateway 10.0.0.1\\n\\nStep 7: Configure Routing\\nRouter1:\\nip route 10.0.0.0 255.255.255.248 172.16.1.2\\n\\nRouter2:\\nip route 192.168.1.0 255.255.255.0 172.16.1.1\\n\\nStep 8: Verify interfaces\\nRun:\\nshow ip interface brief\\n\\nStatus should be up up\\nIf not, use no shutdown\\n\\nStep 9: Test connectivity\\nFrom PC1:\\nping 10.0.0.2\\n\\nExpected reply from destination\\n\\nStep 10: Simulation Mode\\nClick Simulation\\nReset Simulation\\nEdit Filters and select ARP and ICMP\\n\\nSend packet using Add Simple PDU from PC1 to PC3\\nClick Play or Capture/Forward\\n\\nExpected packet flow:\\nPC1 -> Switch1 -> Router1 -> Router2 -> Switch2 -> PC3\\n\\nFirst ARP then ICMP communication successful"
5
5
  },
6
- "fibonacci_user_input_java": {
7
- "title": "Java Fibonacci Series with User Input",
8
- "code": "import java.util.Scanner;\\n\\npublic class Fibonacci {\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\n\\t\\tSystem.out.print(\\\"Enter number of terms: \\\" );\\n\\t\\tint n = sc.nextInt();\\n\\n\\t\\tint a = 0, b = 1;\\n\\n\\t\\tSystem.out.println(\\\"Fibonacci Series:\\\");\\n\\n\\t\\tfor (int i = 1; i <= n; i++) {\\n\\t\\t\\tSystem.out.print(a + \\\" \\\" );\\n\\n\\t\\t\\tint next = a + b;\\n\\t\\t\\ta = b;\\n\\t\\t\\tb = next;\\n\\t\\t}\\n\\n\\t\\tsc.close();\\n\\t}\\n}"
6
+ "nat_configuration_practical": {
7
+ "title": "NAT Configuration using Packet Tracer",
8
+ "code": "Step 1: Setting Up the Topology\\nAdd devices:\\n1 Router (2911 or similar)\\n1 Switch (2960)\\n3 PCs (PC0, PC1, PC2)\\n1 Cloud or Server\\n\\nStep 2: Assign IP Addresses\\nPrivate Network:\\nPC0 IP 192.168.1.2 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC1 IP 192.168.1.3 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC2 IP 192.168.1.4 Mask 255.255.255.0 Gateway 192.168.1.1\\n\\nStep 3: Configure Router Interfaces\\nRouter> enable\\nRouter# configure terminal\\n\\nInterface gig0/0\\nRouter(config)# interface gig0/0\\nRouter(config-if)# ip address 192.168.1.1 255.255.255.0\\nRouter(config-if)# no shutdown\\n\\nInterface gig0/1\\nRouter(config)# interface gig0/1\\nRouter(config-if)# ip address 203.0.113.1 255.255.255.0\\nRouter(config-if)# no shutdown\\n\\nAssign IP to Cloud/Server\\nIP 203.0.113.2\\nMask 255.255.255.0\\n\\nStep 4: Configure NAT\\nDefine inside and outside interfaces\\nRouter(config)# interface gig0/0\\nRouter(config-if)# ip nat inside\\nRouter(config-if)# exit\\n\\nRouter(config)# interface gig0/1\\nRouter(config-if)# ip nat outside\\nRouter(config-if)# exit\\n\\nConfigure PAT\\nRouter(config)# access-list 1 permit 192.168.1.0 0.0.0.255\\nRouter(config)# ip nat inside source list 1 interface gig0/1 overload\\n\\nStep 5: Configure Routing\\nRouter(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.2\\n\\nStep 6: Test Configuration\\nFrom PC command prompt:\\nping 203.0.113.2\\n\\nIf reply is received, NAT is working\\n\\nVerify NAT translations\\nRouter# show ip nat translations"
9
9
  },
10
- "armstrong_user_input_java": {
11
- "title": "Java Armstrong Number with User Input",
12
- "code": "import java.util.Scanner;\\n\\npublic class Armstrong {\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\n\\t\\tSystem.out.print(\\\"Enter a number: \\\" );\\n\\t\\tint num = sc.nextInt();\\n\\n\\t\\tint original = num;\\n\\t\\tint sum = 0;\\n\\t\\tint digits = 0;\\n\\n\\t\\tint temp = num;\\n\\t\\twhile (temp > 0) {\\n\\t\\t\\tdigits++;\\n\\t\\t\\ttemp = temp / 10;\\n\\t\\t}\\n\\n\\t\\ttemp = num;\\n\\t\\twhile (temp > 0) {\\n\\t\\t\\tint digit = temp % 10;\\n\\t\\t\\tsum += Math.pow(digit, digits);\\n\\t\\t\\ttemp = temp / 10;\\n\\t\\t}\\n\\n\\t\\tif (sum == original) {\\n\\t\\t\\tSystem.out.println(\\\"Armstrong Number\\\");\\n\\t\\t} else {\\n\\t\\t\\tSystem.out.println(\\\"Not an Armstrong Number\\\");\\n\\t\\t}\\n\\n\\t\\tsc.close();\\n\\t}\\n}"
10
+ "packet_fragmentation_analysis": {
11
+ "title": "Packet Fragmentation Analysis using Wireshark",
12
+ "code": "AIM:\\nTo analyze packet fragmentation by changing packet size and observing its effect using Wireshark.\\n\\nStep 1: Open Wireshark\\nLaunch Wireshark\\nSelect active interface (WiFi or Ethernet)\\nClick Start Capture\\n\\nStep 2: Check MTU size\\nOpen Command Prompt and run:\\nnetsh interface ipv4 show subinterfaces\\nNote MTU value (usually 1500 bytes)\\n\\nStep 3: Test without fragmentation\\nping 8.8.8.8 -f -l 1472\\n1472 + 28 header = 1500, fits MTU\\nOutput: Reply received, no fragmentation\\n\\nStep 4: Force fragmentation error\\nping 8.8.8.8 -f -l 2000\\nOutput: Packet needs to be fragmented but DF set\\nMeaning: Packet too large and fragmentation not allowed\\n\\nStep 5: Allow fragmentation\\nping 8.8.8.8 -l 2000\\nPacket is divided into fragments\\nMay observe delay or packet loss\\n\\nStep 6: Analyze in Wireshark\\nApply filter:\\nip.flags.mf == 1 or ip.frag_offset > 0\\n\\nObservation:\\nMultiple packets for single ping\\nFragmented packets visible\\n\\nObservations:\\nFragmented packets have same Identification ID\\nDifferent Fragment Offset values\\nMF flag indicates more fragments\\nLast packet has MF = 0\\n\\nPerformance Impact:\\nMore packets generated\\nIncreased delay\\nPossible packet loss\\n\\nFinal Observation:\\nSmall packet: No fragmentation\\nLarge packet with DF: Error\\nLarge packet without DF: Fragmentation occurs\\n\\nConclusion:\\nIf packet size exceeds MTU, it is divided into smaller fragments, affecting performance\\n\\nOutput:\\nPing command results showing success or error\\nWireshark showing fragmented packets using filter\\n\\nResult:\\nFragmentation observed and analyzed successfully"
13
13
  },
14
- "prime_user_input_java": {
15
- "title": "Java Prime Number with User Input",
16
- "code": "import java.util.Scanner;\\n\\npublic class Prime {\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\n\\t\\tSystem.out.print(\\\"Enter a number: \\\" );\\n\\t\\tint num = sc.nextInt();\\n\\n\\t\\tboolean isPrime = true;\\n\\n\\t\\tif (num <= 1) {\\n\\t\\t\\tisPrime = false;\\n\\t\\t} else {\\n\\t\\t\\tfor (int i = 2; i <= num / 2; i++) {\\n\\t\\t\\t\\tif (num % i == 0) {\\n\\t\\t\\t\\t\\tisPrime = false;\\n\\t\\t\\t\\t\\tbreak;\\n\\t\\t\\t\\t}\\n\\t\\t\\t}\\n\\t\\t}\\n\\n\\t\\tif (isPrime) {\\n\\t\\t\\tSystem.out.println(\\\"Prime Number\\\");\\n\\t\\t} else {\\n\\t\\t\\tSystem.out.println(\\\"Not a Prime Number\\\");\\n\\t\\t}\\n\\n\\t\\tsc.close();\\n\\t}\\n}"
14
+ "network_security_acl_port_security": {
15
+ "title": "Network Security using ACL and Port Security",
16
+ "code": "AIM:\\nTo identify vulnerabilities and secure the network using Access Control List (ACL) and Port Security.\\n\\nStep 1: Topology Setup\\nAdd devices:\\n1 Router (2911)\\n1 Switch (2960)\\n2 PCs\\n\\nStep 2: Connections\\nPC1 FastEthernet0 to Switch Fa0/1 using Copper Straight-Through\\nPC2 FastEthernet0 to Switch Fa0/2 using Copper Straight-Through\\nSwitch Fa0/24 to Router GigabitEthernet0/0\\n\\nStep 3: Configure PCs\\nPC1 IP 192.168.1.10 Mask 255.255.255.0 Gateway 192.168.1.1\\nPC2 IP 192.168.1.20 Mask 255.255.255.0 Gateway 192.168.1.1\\n\\nStep 4: Configure Router\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 5: Test Before Security\\nFrom PC2:\\nping 192.168.1.10\\nCommunication should be successful\\n\\nStep 6: Apply ACL\\naccess-list 1 deny 192.168.1.20\\naccess-list 1 permit any\\n\\nApply ACL:\\ninterface g0/0\\nip access-group 1 in\\nexit\\n\\nStep 7: Test After Security\\nFrom PC2:\\nping 192.168.1.10\\nShould fail\\n\\nFrom PC1:\\nping 192.168.1.20\\nShould work\\n\\nStep 8: Configure Port Security on Switch\\nenable\\nconfigure terminal\\ninterface fa0/1\\nswitchport mode access\\nswitchport port-security\\nswitchport port-security maximum 1\\nexit\\n\\nVulnerabilities Identified:\\nNo access control\\nNo device restriction\\nNo traffic filtering\\n\\nSecurity Measures Applied:\\nACL controls communication between devices\\nPort Security restricts number of devices per port\\n\\nAdditional Concepts:\\nIDS detects suspicious activities such as unusual traffic\\nIPsec encrypts data for secure transmission\\n\\nSimulation (Optional):\\nUse Simulation mode\\nFilter ICMP\\nObserve packet drop due to ACL\\n\\nFinal Result:\\nPC2 is blocked\\nPC1 is allowed\\nSwitch ports are secured\\nNetwork is protected successfully"
17
17
  },
18
- "factorial_user_input_java": {
19
- "title": "Java Factorial with User Input",
20
- "code": "import java.util.Scanner;\\n\\npublic class Factorial {\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\n\\t\\tSystem.out.print(\\\"Enter a number: \\\" );\\n\\t\\tint num = sc.nextInt();\\n\\n\\t\\tlong fact = 1;\\n\\n\\t\\tfor (int i = 1; i <= num; i++) {\\n\\t\\t\\tfact *= i;\\n\\t\\t}\\n\\n\\t\\tSystem.out.println(\\\"Factorial: \\\" + fact);\\n\\n\\t\\tsc.close();\\n\\t}\\n}"
18
+ "ip_spoofing_security_practical": {
19
+ "title": "IP Spoofing Attack and Prevention using ACL and uRPF",
20
+ "code": "AIM:\\nTo demonstrate IP Spoofing attack and implement security measures to prevent unauthorized access.\\n\\nStep 1: Topology Setup\\nDevices required:\\n1 Router (2911)\\n1 Switch (2960)\\nPC1 (Trusted user)\\nPC2 (Attacker)\\n1 Server\\n\\nConnections:\\nPC1 to Switch Fa0/1\\nPC2 to Switch Fa0/2\\nSwitch Fa0/24 to Router G0/0\\nServer to Router G0/1\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10 Gateway 192.168.1.1\\nPC2 IP 192.168.1.20 Gateway 192.168.1.1\\nServer IP 10.0.0.2 Gateway 10.0.0.1\\n\\nStep 3: Configure Router\\nenable\\nconfigure terminal\\n\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Configure Routing\\nip route 10.0.0.0 255.255.255.0 10.0.0.1\\n\\nStep 5: Apply Trust-Based ACL\\naccess-list 10 permit 192.168.1.10\\naccess-list 10 deny any\\n\\ninterface g0/0\\nip access-group 10 in\\n\\nStep 6: Test Before Attack\\nFrom PC1:\\nping 10.0.0.2 (should work)\\n\\nFrom PC2:\\nping 10.0.0.2 (should fail)\\n\\nStep 7: Simulate IP Spoofing\\nChange PC2 IP to 192.168.1.10\\n\\nTest again:\\nping 10.0.0.2 (should work)\\n\\nStep 8: Impact\\nUnauthorized access\\nSecurity bypass\\nFake identity\\n\\nStep 9: Countermeasure 1 Anti-Spoofing ACL\\nip access-list extended ANTI-SPOOF\\ndeny ip 192.168.1.0 0.0.0.255 any\\npermit ip any any\\n\\ninterface g0/1\\nip access-group ANTI-SPOOF in\\n\\nStep 10: Countermeasure 2 uRPF\\ninterface g0/0\\nip verify unicast source reachable-via rx\\n\\nStep 11: Switch Port Security\\nenable\\nconfigure terminal\\n\\ninterface fa0/1\\nswitchport mode access\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security mac-address sticky\\nswitchport port-security violation shutdown\\n\\nFinal Understanding:\\nBefore ACL everyone allowed\\nACL allows only trusted IP\\nSpoofing bypasses security\\nuRPF blocks spoofed packets\\n\\nConclusion:\\nIP-based trust is not secure and must be verified using mechanisms like uRPF and port security\\n\\nResult:\\nAttack simulated successfully\\nVulnerability identified\\nSecurity measures implemented"
21
21
  },
22
- "reverse_number_java": {
23
- "title": "Java Reverse Number with User Input",
24
- "code": "import java.util.Scanner;\\n\\npublic class ReverseNumber {\\n\\n\\tpublic static void main(String[] args) {\\n\\n\\t\\tScanner sc = new Scanner(System.in);\\n\\n\\t\\tSystem.out.print(\\\"Enter a number: \\\" );\\n\\t\\tint num = sc.nextInt();\\n\\n\\t\\tint reverse = 0;\\n\\n\\t\\twhile (num > 0) {\\n\\t\\t\\tint digit = num % 10;\\n\\t\\t\\treverse = reverse * 10 + digit;\\n\\t\\t\\tnum = num / 10;\\n\\t\\t}\\n\\n\\t\\tSystem.out.println(\\\"Reversed Number: \\\" + reverse);\\n\\n\\t\\tsc.close();\\n\\t}\\n}"
22
+ "udp_acl_security_practical": {
23
+ "title": "UDP Traffic Control using Access Control List (ACL)",
24
+ "code": "AIM:\\nTo allow normal UDP communication and block unwanted UDP traffic using ACL.\\n\\nStep 1: Build the Network\\nDevices required:\\n1 Router (2911)\\n1 Switch (2960)\\nPC1 (Client)\\nPC2 (Attacker)\\n1 Server\\n\\nConnections:\\nPC1 FastEthernet0 to Switch Fa0/1\\nPC2 FastEthernet0 to Switch Fa0/2\\nServer FastEthernet0 to Switch Fa0/3\\nSwitch Fa0/24 to Router GigabitEthernet0/0\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10 Gateway 192.168.1.1\\nPC2 IP 192.168.1.30 Gateway 192.168.1.1\\nServer IP 192.168.1.20\\nSubnet Mask 255.255.255.0\\n\\nStep 3: Configure Router\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Enable UDP Service on Server\\nOpen Server -> Services -> DNS\\nTurn DNS ON\\nAdd entry:\\nName example.com\\nAddress 192.168.1.20\\n\\nStep 5: Test UDP Communication\\nFrom PC1:\\nnslookup example.com 192.168.1.20\\nUDP communication should work\\n\\nStep 6: Apply ACL to Block Attacker\\nRouter(config)# access-list 100 deny udp host 192.168.1.30 any\\nRouter(config)# access-list 100 permit ip any any\\n\\nApply ACL:\\ninterface g0/0\\nip access-group 100 in\\nexit\\n\\nStep 7: Test After ACL\\nFrom PC2:\\nnslookup example.com 192.168.1.20 (should fail)\\n\\nFrom PC1:\\nnslookup example.com 192.168.1.20 (should work)\\n\\nStep 8: Block DNS Service (Port-Based ACL)\\nRouter(config)# access-list 101 deny udp any any eq 53\\nRouter(config)# access-list 101 permit ip any any\\n\\nApply:\\ninterface g0/0\\nip access-group 101 in\\nexit\\n\\nTest:\\nFrom PC1:\\nnslookup example.com 192.168.1.20 (should fail)\\n\\nStep 9: Important Concept\\nIf all devices are in same network, traffic bypasses router\\nCommunication becomes PC -> Switch -> Server\\nACL will not work\\n\\nStep 10: Fix Topology\\nChange Server network:\\nServer IP 10.0.0.2 Gateway 10.0.0.1\\n\\nConfigure Router:\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\n\\nNow traffic flows through router:\\nPC -> Router -> Server\\nACL works correctly\\n\\nConcepts:\\nUDP is fast and connectionless protocol\\nACL filters traffic based on rules\\nPort 53 is used for DNS\\nRouter must be in path for ACL to work\\n\\nResult:\\nUDP communication tested\\nAttacker blocked using ACL\\nDNS service blocked using port-based ACL\\nNetwork secured successfully"
25
25
  },
26
-
27
-
28
-
29
-
30
-
31
-
32
-
33
-
34
-
35
-
36
-
37
- "junit_armstrong": {
38
- "title": "JUnit Armstrong Number Test",
39
- "code": "public class ArmstrongService {\\n\\n\\tpublic boolean isArmstrong(int num) {\\n\\t\\tint temp = num, sum = 0, rem;\\n\\n\\t\\twhile (num > 0) {\\n\\t\\t\\trem = num % 10;\\n\\t\\t\\tsum += rem * rem * rem;\\n\\t\\t\\tnum /= 10;\\n\\t\\t}\\n\\t\\treturn sum == temp;\\n\\t}\\n}\\n\\nimport org.junit.jupiter.api.Test;\\nimport static org.junit.jupiter.api.Assertions.*;\\n\\npublic class ArmstrongTest {\\n\\n\\t@Test\\n\\tvoid testArmstrong() {\\n\\t\\tArmstrongService s = new ArmstrongService();\\n\\t\\tassertTrue(s.isArmstrong(153));\\n\\t\\tassertFalse(s.isArmstrong(123));\\n\\t}\\n}"
40
- },
41
- "junit_volume": {
42
- "title": "JUnit Volume Calculation Test",
43
- "code": "public class VolumeService {\\n\\n\\tpublic double sphere(double r) {\\n\\t\\treturn (4.0 / 3.0) * Math.PI * r * r * r;\\n\\t}\\n\\n\\tpublic double cylinder(double r, double h) {\\n\\t\\treturn Math.PI * r * r * h;\\n\\t}\\n\\n\\tpublic double cube(double a) {\\n\\t\\treturn a * a * a;\\n\\t}\\n}\\n\\nimport org.junit.jupiter.api.Test;\\nimport static org.junit.jupiter.api.Assertions.*;\\n\\npublic class VolumeTest {\\n\\n\\tVolumeService s = new VolumeService();\\n\\n\\t@Test\\n\\tvoid testSphere() {\\n\\t\\tassertEquals(523.5, s.sphere(5), 0.1);\\n\\t}\\n\\n\\t@Test\\n\\tvoid testCylinder() {\\n\\t\\tassertEquals(314.1, s.cylinder(5, 4), 0.1);\\n\\t}\\n\\n\\t@Test\\n\\tvoid testCube() {\\n\\t\\tassertEquals(27, s.cube(3));\\n\\t}\\n}"
44
- },
45
- "junit_area": {
46
- "title": "JUnit Area Calculation Test",
47
- "code": "public class AreaService {\\n\\n\\tpublic double circle(double r) {\\n\\t\\treturn Math.PI * r * r;\\n\\t}\\n\\n\\tpublic double rectangle(double l, double b) {\\n\\t\\treturn l * b;\\n\\t}\\n\\n\\tpublic double triangle(double b, double h) {\\n\\t\\treturn 0.5 * b * h;\\n\\t}\\n}\\n\\nimport org.junit.jupiter.api.Test;\\nimport static org.junit.jupiter.api.Assertions.*;\\n\\npublic class AreaTest {\\n\\n\\tAreaService s = new AreaService();\\n\\n\\t@Test\\n\\tvoid testCircle() {\\n\\t\\tassertEquals(78.5, s.circle(5), 0.1);\\n\\t}\\n\\n\\t@Test\\n\\tvoid testRectangle() {\\n\\t\\tassertEquals(20, s.rectangle(5, 4));\\n\\t}\\n\\n\\t@Test\\n\\tvoid testTriangle() {\\n\\t\\tassertEquals(10, s.triangle(5, 4));\\n\\t}\\n}"
48
- },
49
- "testng_selenium_setup": {
50
- "title": "Practical 5 TestNG and Selenium Setup Steps",
51
- "code": "A) Setup TestNG in Maven Project\\n\\nStep 1: Create Maven Project\\nOpen Eclipse IDE\\nGo to File -> New -> Maven Project\\nSelect Create a simple project\\nClick Next\\n\\nEnter details:\\nGroupId: com.bca\\nArtifactId: PracticeTestNG\\nName: PracticeTestNG\\nClick Finish\\n\\nStep 2: Fix pom.xml Error\\nGo to Window -> Preferences -> Maven\\nEnable Update Maven Projects on Startup\\nClick Apply and Close\\n\\nStep 3: Add TestNG Dependency\\nOpen pom.xml and add:\\n<dependencies>\\n <dependency>\\n <groupId>org.testng</groupId>\\n <artifactId>testng</artifactId>\\n <version>7.12.0</version>\\n <scope>test</scope>\\n </dependency>\\n</dependencies>\\n\\nRight click project -> Maven -> Update Project\\n\\nStep 4: Install TestNG Plugin\\nGo to Help -> Eclipse Marketplace\\nSearch TestNG\\nInstall and restart Eclipse\\n\\nStep 5: Create Test Class\\nGo to src/test/java\\nRight click -> New -> Class\\nName: FirstTest\\n\\nStep 6: Simple Test Code\\nimport org.testng.annotations.Test;\\n\\npublic class FirstTest {\\n @Test\\n public void test1() {\\n System.out.println(\\\"TestNG is working\\\");\\n }\\n}\\n\\nRun using Run As -> TestNG Test\\n\\nB) Selenium + TestNG Setup\\n\\nStep 1: Add Dependencies\\nAdd in pom.xml:\\n<dependency>\\n <groupId>org.seleniumhq.selenium</groupId>\\n <artifactId>selenium-java</artifactId>\\n <version>4.21.0</version>\\n</dependency>\\n\\n<dependency>\\n <groupId>io.github.bonigarcia</groupId>\\n <artifactId>webdrivermanager</artifactId>\\n <version>5.8.0</version>\\n</dependency>\\n\\nRight click -> Maven -> Update Project\\n\\nStep 2: Final Working Code\\npackage mypack;\\n\\nimport org.openqa.selenium.By;\\nimport org.openqa.selenium.Keys;\\nimport org.openqa.selenium.WebDriver;\\nimport org.openqa.selenium.chrome.ChromeDriver;\\nimport org.testng.annotations.Test;\\nimport io.github.bonigarcia.wdm.WebDriverManager;\\n\\npublic class FirstTest {\\n\\n @Test\\n public void TestGoogle() throws Exception {\\n\\n WebDriverManager.chromedriver().setup();\\n\\n WebDriver driver = new ChromeDriver();\\n\\n driver.manage().window().maximize();\\n\\n driver.get(\\\"https://www.google.com/\\\");\\n\\n driver.findElement(By.name(\\\"q\\\"))\\n .sendKeys(\\\"skates\\\", Keys.ENTER);\\n\\n System.out.println(driver.getTitle());\\n\\n Thread.sleep(5000);\\n\\n driver.quit();\\n }\\n}\\n\\nImportant Notes\\n\\nIf Chrome does not open:\\nUpdate Chrome browser and WebDriverManager\\n\\nIf TestNG does not run:\\nUse Run As -> TestNG Test\\n\\nIf import errors occur:\\nEnsure import org.testng.annotations.Test is added"
52
- },
53
- "autoit_selenium_steps": {
54
- "title": "AutoIt + Selenium File Upload Practical Steps",
55
- "code": "Step 1: Download AutoIt from https://www.autoitscript.com/site/autoit/downloads/\\n\\nStep 2: Download SciTE Editor from https://www.autoitscript.com/site/autoit-script-editor/downloads/\\n\\nStep 3: Install AutoIt by extracting zip and running setup file\\n\\nStep 4: Install SciTE editor and complete setup\\n\\nStep 5: Open SciTE.exe and Au3Info_x64.exe (Finder Tool)\\n\\nStep 6: Open website https://the-internet.herokuapp.com/upload\\n\\nStep 7: Use Finder Tool to get details of file input and open button (Edit1, Button1)\\n\\nStep 8: Write AutoIt script:\\nControlFocus(\\\"Open\\\",\\\"\\\",\\\"Edit1\\\")\\nControlSetText(\\\"Open\\\",\\\"\\\",\\\"Edit1\\\",$CmdLine[1])\\nControlClick(\\\"Open\\\",\\\"\\\",\\\"Button1\\\")\\n\\nStep 9: Save as hello.au3 and compile using Tools -> Compile (X86 + X64)\\n\\nStep 10: Create Java Selenium project in Eclipse\\n\\nStep 11: Write Selenium code to open browser and click upload button\\n\\nStep 12: Use ProcessBuilder to run hello.exe with file path\\n\\nStep 13: Run Java application\\n\\nOutput: File upload is automated using AutoIt and Selenium"
56
- },
57
- "autoit_file_upload": {
58
- "title": "AutoIt + Selenium File Upload Automation",
59
- "code": "/* AutoIt Script */\\nControlFocus(\\\"Open\\\",\\\"\\\",\\\"Edit1\\\")\\nControlSetText(\\\"Open\\\",\\\"\\\",\\\"Edit1\\\",$CmdLine[1])\\nControlClick(\\\"Open\\\",\\\"\\\",\\\"Button1\\\")\\n\\n/* Java Selenium Code */\\npackage Auto;\\n\\nimport java.io.IOException;\\nimport org.openqa.selenium.By;\\nimport org.openqa.selenium.WebElement;\\nimport org.openqa.selenium.chrome.ChromeDriver;\\nimport org.openqa.selenium.interactions.Actions;\\n\\npublic class AutoITScirpt {\\n\\n\\tpublic static void main(String[] args) throws IOException, InterruptedException {\\n\\n\\t\\tChromeDriver driver = new ChromeDriver();\\n\\n\\t\\tdriver.get(\\\"https://the-internet.herokuapp.com/upload\\\");\\n\\n\\t\\tSystem.out.println(\\\"URL: \\\" + driver.getCurrentUrl());\\n\\t\\tSystem.out.println(\\\"Title: \\\" + driver.getTitle());\\n\\t\\tSystem.out.println(\\\"Source Length: \\\" + driver.getPageSource().length());\\n\\n\\t\\tWebElement buttonElement = driver.findElement(By.id(\\\"file-upload\\\"));\\n\\n\\t\\tActions act = new Actions(driver);\\n\\t\\tact.moveToElement(buttonElement).click().perform();\\n\\n\\t\\tThread.sleep(2000);\\n\\n\\t\\tProcessBuilder pBuilder = new ProcessBuilder(\\n\\t\\t\\t\\\"C:\\\\\\\\Users\\\\\\\\User\\\\\\\\OneDrive\\\\\\\\Desktop\\\\\\\\material\\\\\\\\STT\\\\\\\\hello.exe\\\",\\n\\t\\t\\t\\\"C:\\\\\\\\Users\\\\\\\\User\\\\\\\\Downloads\\\\\\\\chromedriver-win64\\\\\\\\hello.txt\\\"\\n\\t\\t);\\n\\n\\t\\tProcess process = pBuilder.start();\\n\\t\\tprocess.waitFor();\\n\\t}\\n}"
26
+ "udp_acl_dns_security_practical": {
27
+ "title": "UDP DNS Communication with ACL Security",
28
+ "code": "AIM:\\nCreate a network, enable DNS (UDP), allow normal user, and block attacker using ACL.\\n\\nStep 1: Topology\\nPC1 (Client) and PC2 (Attacker) connected to Switch\\nSwitch connected to Router G0/0\\nRouter G0/1 connected to Server\\n\\nStep 2: Connections\\nUse Copper Straight-Through cables\\nPC1 to Switch Fa0/1\\nPC2 to Switch Fa0/2\\nSwitch to Router G0/0\\nRouter G0/1 to Server\\nAll links should be active\\n\\nStep 3: IP Configuration\\nPC1 IP 192.168.1.10 Mask 255.255.255.0 Gateway 192.168.1.1 DNS 10.0.0.2\\nPC2 IP 192.168.1.30 Mask 255.255.255.0 Gateway 192.168.1.1 DNS 10.0.0.2\\nServer IP 10.0.0.2 Mask 255.255.255.0 Gateway 10.0.0.1\\n\\nStep 4: Router Configuration\\nenable\\nconfigure terminal\\n\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 5: Enable DNS on Server\\nOpen Server -> Services -> DNS\\nTurn DNS ON\\nAdd entry:\\nName example.com\\nAddress 10.0.0.2\\n\\nStep 6: Initial Testing\\nFrom PC1:\\nping 10.0.0.2\\nThis builds ARP\\n\\nThen:\\nnslookup example.com\\nShould work successfully\\n\\nStep 7: Apply ACL Security\\nconfigure terminal\\n\\naccess-list 101 deny udp host 192.168.1.30 any\\naccess-list 101 permit ip any any\\n\\ninterface g0/0\\nip access-group 101 in\\nexit\\n\\nStep 8: Final Testing\\nFrom PC1:\\nnslookup example.com\\nShould work\\n\\nFrom PC2:\\nnslookup example.com\\nShould fail\\n\\nConcepts:\\nRouter must be in path for ACL to work\\nDNS uses UDP port 53\\nFirst ping builds ARP and avoids timeout\\nACL filters traffic based on rules\\n\\nFinal Result:\\nPC1 allowed\\nPC2 blocked\\nDNS working\\nACL applied successfully"
29
+ },
30
+ "dns_udp_hijacking_practical": {
31
+ "title": "DNS UDP Hijacking Simulation and Prevention",
32
+ "code": "AIM:\\nSimulate a DNS-based UDP hijacking scenario, observe its impact on the client, and apply basic protection.\\n\\nStep 1: Topology Setup\\nConnect devices using Copper Straight-Through:\\nPC1 to Switch\\nPC2 to Switch\\nServer to Switch\\nSwitch to Router\\nEnsure all connections are active\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10 Mask 255.255.255.0 Gateway 192.168.1.1 DNS 192.168.1.100\\nPC2 IP 192.168.1.20 Gateway 192.168.1.1\\nServer IP 192.168.1.100 Gateway 192.168.1.1\\n\\nStep 3: Router Configuration\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Enable DNS on Real Server\\nOpen Server -> Services -> DNS\\nTurn DNS ON\\nAdd entry:\\nexample.com maps to 192.168.1.100\\n\\nStep 5: Test Normal Output\\nFrom PC1:\\nnslookup example.com\\nExpected result:\\nName example.com\\nAddress 192.168.1.100\\n\\nStep 6: Simulate Attack\\nTurn OFF real server\\nOn PC2 change IP to 192.168.1.100\\nEnable DNS on PC2\\nAdd entry:\\nexample.com maps to 5.5.5.5\\n\\nStep 7: Test Attack Output\\nFrom PC1:\\nnslookup example.com\\nExpected result:\\nName example.com\\nAddress 5.5.5.5\\n\\nObservation:\\nBefore attack DNS resolves to 192.168.1.100\\nAfter attack DNS resolves to 5.5.5.5\\nClient is misled\\n\\nStep 8: Apply Basic Protection using Port Security\\nOn Switch CLI:\\nenable\\nconfigure terminal\\ninterface fa0/2\\nswitchport mode access\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security mac-address sticky\\nswitchport port-security violation shutdown\\nexit\\n\\nStep 9: Final Check\\nAttempt attack again\\nPort security blocks attacker or shuts down port\\n\\nOutput Observation Methods:\\nCommand Line:\\nUse nslookup example.com before and after attack\\n\\nSimulation Mode:\\nSelect Simulation\\nFilter DNS or UDP\\nRun nslookup\\nObserve source IP, destination IP, and UDP port 53\\n\\nConclusion:\\nDNS over UDP can be exploited by spoofing\\nClient blindly trusts DNS response\\nSecurity measures like port security help prevent attacks\\n\\nResult:\\nAttack successfully simulated\\nImpact observed\\nBasic protection applied"
33
+ },
34
+ "dos_attack_simulation_practical": {
35
+ "title": "Denial of Service (DoS) Attack Simulation and Prevention",
36
+ "code": "AIM:\\nSimulate a DoS condition using continuous requests, observe its impact on a server, and apply prevention techniques.\\n\\nStep 1: Topology\\nDevices:\\nPC1, PC2, PC3, Server connected to Switch\\nSwitch connected to Router G0/0\\nEnsure all connections are active\\n\\nStep 2: IP Configuration\\nPC1 IP 192.168.1.10\\nPC2 IP 192.168.1.20\\nPC3 IP 192.168.1.30\\nServer IP 192.168.1.100\\nMask 255.255.255.0\\nGateway 192.168.1.1\\n\\nStep 3: Router Configuration\\nenable\\nconfigure terminal\\ninterface g0/0\\nip address 192.168.1.1 255.255.255.0\\nno shutdown\\nexit\\n\\nStep 4: Enable Server Service\\nOpen Server -> Services -> HTTP\\nTurn HTTP ON\\n\\nStep 5: Normal Test\\nFrom PC1:\\nping 192.168.1.100\\nStable replies indicate normal operation\\n\\nStep 6: Simulate DoS Attack\\nFrom PC2:\\nping 192.168.1.100 -t\\n\\nFrom PC3:\\nping 192.168.1.100 -t\\n\\nContinuous traffic is generated\\n\\nStep 7: Observe Impact\\nFrom PC1:\\nping 192.168.1.100\\n\\nExpected results:\\nRequest timed out\\nHigh delay\\nPacket loss\\n\\nIndicates server overload and network congestion\\n\\nStep 8: Important Concept\\nIf all devices are in same network, traffic flows directly\\nPC -> Switch -> Server\\nRouter is bypassed\\nACL on router will not work\\n\\nStep 9: Apply Switch Port Security\\nenable\\nconfigure terminal\\n\\ninterface fa0/2\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security violation shutdown\\nexit\\n\\ninterface fa0/3\\nswitchport port-security\\nswitchport port-security maximum 1\\nswitchport port-security violation shutdown\\nexit\\n\\nLimits attacker behavior\\n\\nStep 10: Improved Topology for Router Control\\nChange Server network:\\nServer IP 10.0.0.2 Gateway 10.0.0.1\\n\\nAdd router interface:\\ninterface g0/1\\nip address 10.0.0.1 255.255.255.0\\nno shutdown\\n\\nTraffic now passes through router\\n\\nStep 11: Apply ACL Protection\\nip access-list extended BLOCK_ICMP\\npermit icmp host 192.168.1.10 host 10.0.0.2\\ndeny icmp any any\\n\\ninterface g0/0\\nip access-group BLOCK_ICMP in\\n\\nStep 12: Final Testing\\nFrom PC1:\\nping 10.0.0.2 (should work)\\n\\nFrom PC2 and PC3:\\nping 10.0.0.2 (should fail)\\n\\nOutput Observation:\\nCommand Line:\\nCompare ping before and during attack\\n\\nSimulation Mode:\\nFilter ICMP\\nObserve multiple packets and congestion\\n\\nConclusion:\\nDoS attack floods server with requests causing delay and packet loss\\nSwitch port security and ACL help control traffic\\n\\nResult:\\nAttack simulated\\nImpact observed\\nProtection applied successfully"
60
37
  }
61
38
  }
62
39
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chiwormjava",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"
package/readme.md CHANGED
@@ -42,277 +42,304 @@ javacodewatch
42
42
 
43
43
  ---
44
44
 
45
- ## 🧠 What it does
45
+ ---
46
+
47
+ ## Step 2: Add Serial Ports (MOST IMPORTANT FIX)
48
+
49
+ By default, routers don’t have serial ports.
50
+
51
+ ### Do this for BOTH routers:
52
+
53
+ 1. Click Router → **Physical tab**
54
+ 2. Turn **Power OFF**
55
+ 3. From modules:
56
+ Drag **WIC-2T** into slot
57
+ 4. Turn **Power ON**
58
+
59
+ Now you will see:
60
+
61
+ ```
62
+ Serial0/0/0
63
+ Serial0/0/1
64
+ ```
65
+
66
+ ---
67
+
68
+ ## Step 3: Connect cables (CORRECT WAY)
46
69
 
47
- * Opens a local server
48
- * Launches your browser
49
- * Shows Java code snippets
50
- * ClickView code
51
- * Click → Copy code
70
+ ### LAN connections
71
+
72
+ * PC Switch → **Copper Straight-Through**
73
+ * SwitchRouter (Gig0/0 or Fa0/0) → **Copper Straight-Through**
52
74
 
53
75
  ---
54
76
 
55
- ## 📸 Features
77
+ ### WAN connection (Router ↔ Router)
56
78
 
57
- * 📚 Java DSA snippets (LinkedList, etc.)
58
- * 🖱️ One-click code view
59
- * 📋 Copy to clipboard
60
- * 🌙 Clean dark UI
79
+ * Select **Serial DCE cable**
80
+ * Router1 `Serial0/0/0`
81
+ * Router2 `Serial0/0/0`
61
82
 
62
83
  ---
63
84
 
64
- ## ▶️ Usage
85
+ ## Step 4: Configure Router1
65
86
 
66
- After running the command:
87
+ Go to CLI:
67
88
 
68
89
  ```bash
69
- javacodewatch
90
+ enable
91
+ configure terminal
92
+
93
+ interface gigabitEthernet 0/0
94
+ ip address 192.168.1.1 255.255.255.0
95
+ no shutdown
96
+ exit
97
+
98
+ interface serial 0/0/0
99
+ ip address 172.16.1.1 255.255.255.252
100
+ clock rate 64000
101
+ no shutdown
102
+ exit
70
103
  ```
71
104
 
72
- 👉 Your browser will open automatically:
105
+ ---
106
+
107
+ ## Step 5: Configure Router2
73
108
 
74
- ```
75
- http://localhost:3000
109
+ ```bash
110
+ enable
111
+ configure terminal
112
+
113
+ interface gigabitEthernet 0/0
114
+ ip address 10.0.0.1 255.255.255.248
115
+ no shutdown
116
+ exit
117
+
118
+ interface serial 0/0/0
119
+ ip address 172.16.1.2 255.255.255.252
120
+ no shutdown
121
+ exit
76
122
  ```
77
123
 
78
124
  ---
79
125
 
80
- // RC
81
- public void fillPhpForm() throws Exception {
126
+ ## Step 6: Configure PCs
82
127
 
83
- WebDriverManager.chromedriver().setup();
128
+ ### Left network (Router1 side)
84
129
 
85
- WebDriver driver = new ChromeDriver();
86
- driver.manage().window().maximize();
130
+ * PC1
131
+ IP: `192.168.1.2`
132
+ Mask: `255.255.255.0`
133
+ Gateway: `192.168.1.1`
87
134
 
88
-
89
- driver.get("http://localhost/form.php");
135
+ * PC2
136
+ IP: `192.168.1.3`
137
+ Gateway: `192.168.1.1`
90
138
 
91
-
92
- driver.findElement(By.name("username")).sendKeys("Shivam");
93
- driver.findElement(By.name("email")).sendKeys("shivam@gmail.com");
94
- driver.findElement(By.name("password")).sendKeys("123456");
139
+ ---
140
+
141
+ ### Right network (Router2 side)
142
+
143
+ * PC3
144
+ IP: `10.0.0.2`
145
+ Mask: `255.255.255.248`
146
+ Gateway: `10.0.0.1`
147
+
148
+ * PC4
149
+ IP: `10.0.0.3`
150
+ Gateway: `10.0.0.1`
151
+
152
+ ---
95
153
 
96
-
97
- driver.findElement(By.name("submit")).click();
154
+ ## Step 7: Configure Routing (VERY IMPORTANT)
98
155
 
99
- Thread.sleep(5000);
156
+ ### Router1:
100
157
 
101
- System.out.println("URL: " + driver.getCurrentUrl());
102
- System.out.println("Title: " + driver.getTitle());
103
- System.out.println("Source: " + driver.getPageSource().length());
158
+ ```bash
159
+ ip route 10.0.0.0 255.255.255.248 172.16.1.2
160
+ ```
104
161
 
105
- driver.quit();
106
- }
162
+ ### Router2:
107
163
 
164
+ ```bash
165
+ ip route 192.168.1.0 255.255.255.0 172.16.1.1
166
+ ```
108
167
 
109
168
  ---
110
169
 
111
- import org.openqa.selenium.By;
112
- import org.openqa.selenium.WebDriver;
113
- import org.openqa.selenium.chrome.ChromeDriver;
170
+ ## Step 8: Verify interfaces
114
171
 
115
- public class FormAutomation {
172
+ Run on both routers:
116
173
 
117
- public static void main(String[] args) {
174
+ ```bash
175
+ show ip interface brief
176
+ ```
118
177
 
119
- // Set path to ChromeDriver
120
- System.setProperty("webdriver.chrome.driver", "C:\\drivers\\chromedriver.exe");
178
+ You MUST see:
121
179
 
122
- // Launch browser
123
- WebDriver driver = new ChromeDriver();
180
+ ```
181
+ up up
182
+ ```
124
183
 
125
- // Maximize window
126
- driver.manage().window().maximize();
184
+ If not:
185
+ Use `no shutdown`
127
186
 
128
- // Open PHP form page
129
- driver.get("http://localhost/form.php");
187
+ ---
130
188
 
131
- // Fill form
132
- driver.findElement(By.name("username")).sendKeys("Shivam");
133
- driver.findElement(By.name("email")).sendKeys("shivam@gmail.com");
134
- driver.findElement(By.name("password")).sendKeys("123456");
189
+ ## Step 9: Test connectivity
135
190
 
136
- // Submit form
137
- driver.findElement(By.name("submit")).click();
191
+ From PC1:
138
192
 
139
- // Wait
140
- try {
141
- Thread.sleep(5000);
142
- } catch (Exception e) {
143
- e.printStackTrace();
144
- }
193
+ ```bash
194
+ ping 10.0.0.2
195
+ ```
145
196
 
146
- // Close browser
147
- driver.quit();
148
- }
149
- }
197
+ Expected:
150
198
 
199
+ ```
200
+ Reply from 10.0.0.2
201
+ ```
151
202
 
152
203
  ---
153
204
 
154
- Volume Formulas
205
+ ## Step 10: See animation (Simulation Mode)
206
+
207
+ 1. Click **Simulation**
208
+ 2. Click **Reset Simulation**
209
+ 3. Click **Edit Filters**
210
+
211
+ * Select only:
155
212
 
156
- Sphere
213
+ ```
214
+ ARP
215
+ ICMP
216
+ ```
157
217
 
158
- (4.0 / 3.0) * Math.PI * r * r * r
218
+ ---
159
219
 
160
- Cylinder
220
+ ### Send packet
161
221
 
162
- Math.PI * r * r * h
222
+ * Click **Add Simple PDU (envelope icon)**
223
+ * Click **PC1 → PC3**
163
224
 
164
- Cube
225
+ ---
165
226
 
166
- a * a * a
227
+ ### Play
167
228
 
229
+ * Click ▶ play or ⏭ Capture/Forward
168
230
 
169
- ---
231
+ ---
170
232
 
171
- Area Formulas
233
+ ## 👀 What you should see
172
234
 
173
- Circle
235
+ Packet flow:
174
236
 
175
- Math.PI * r * r
237
+ ```
238
+ PC1 → Switch1 → Router1 → Router2 → Switch2 → PC3
239
+ ```
176
240
 
177
- Rectangle
241
+ * First ARP (finding MAC)
242
+ * Then ICMP (ping)
243
+ * All **green ✔**
178
244
 
179
- l * b
245
+ ---
180
246
 
181
- Triangle
182
247
 
183
- 0.5 * b * h
184
248
 
185
249
 
186
- ---
187
250
 
188
- public boolean isArmstrong(int num) {
189
- int temp = num, sum = 0, rem;
190
- while (num > 0) {
191
- rem = num % 10;
192
- sum += rem * rem * rem;
193
- num /= 10;
194
- }
195
-
196
- return sum == temp;
197
-
198
- }
199
251
 
200
252
 
201
- ---
202
253
 
203
254
 
204
- ControlFocus("Open","","Edit1")
205
- ControlSetText("Open","","Edit1",$CmdLine[1])
206
- ControlClick("Open","","Button1")
207
255
 
208
256
 
209
- package Auto;
210
257
 
211
- import java.io.IOException;
212
258
 
213
- import org.openqa.selenium.By;
214
- import org.openqa.selenium.WebElement;
215
- import org.openqa.selenium.chrome.ChromeDriver;
216
- import org.openqa.selenium.interactions.Actions;
217
259
 
218
- public class AutoITScript {
219
260
 
220
- public static void main(String[] args) throws IOException, InterruptedException {
221
261
 
222
-
223
- ChromeDriver driver = new ChromeDriver();
224
262
 
225
-
226
- driver.get("https://the-internet.herokuapp.com/upload");
227
263
 
228
-
229
- System.out.println("URL: " + driver.getCurrentUrl());
230
- System.out.println("Title: " + driver.getTitle());
231
- System.out.println("Source Length: " + driver.getPageSource().length());
232
264
 
233
-
234
- WebElement buttonElement = driver.findElement(By.id("file-upload"));
235
265
 
236
- Actions act = new Actions(driver);
237
- act.moveToElement(buttonElement).click().perform();
238
266
 
239
-
240
- Thread.sleep(2000);
241
267
 
242
-
243
- ProcessBuilder pBuilder = new ProcessBuilder(
244
- "C:\\Users\\User\\Desktop\\upload.exe", // your exe path
245
- "C:\\Users\\User\\Desktop\\file.txt" // file to upload
246
- );
247
268
 
248
- Process process = pBuilder.start();
249
- process.waitFor();
250
269
 
251
-
252
- Thread.sleep(3000);
253
270
 
254
- driver.quit();
255
- }
256
- }
257
271
 
258
- ---
259
272
 
260
- package mypack;
261
273
 
262
- import org.openqa.selenium.By;
263
- import org.openqa.selenium.Keys;
264
- import org.openqa.selenium.WebDriver;
265
- import org.openqa.selenium.chrome.ChromeDriver;
266
274
 
267
- import org.testng.annotations.Test;
268
275
 
269
- import io.github.bonigarcia.wdm.WebDriverManager;
270
276
 
271
- public class FirstTest {
272
277
 
273
- @Test
274
- public void TestGoogle() throws Exception {
275
278
 
276
- WebDriverManager.chromedriver().setup();
277
279
 
278
- WebDriver driver = new ChromeDriver();
279
280
 
280
- driver.manage().window().maximize();
281
281
 
282
- driver.get("https://www.google.com/");
283
282
 
284
- driver.findElement(By.name("q"))
285
- .sendKeys("skates", Keys.ENTER);
286
283
 
287
- System.out.println(driver.getTitle());
288
284
 
289
- Thread.sleep(5000);
290
285
 
291
- driver.quit();
292
- }
293
- }
294
286
 
295
287
 
296
288
 
297
- <dependencies>
298
289
 
299
- <dependency>
300
- <groupId>org.testng</groupId>
301
- <artifactId>testng</artifactId>
302
- <version>7.12.0</version>
303
- <scope>test</scope>
304
- </dependency>
305
290
 
306
- <dependency>
307
- <groupId>org.seleniumhq.selenium</groupId>
308
- <artifactId>selenium-java</artifactId>
309
- <version>4.21.0</version>
310
- </dependency>
311
291
 
312
- <dependency>
313
- <groupId>io.github.bonigarcia</groupId>
314
- <artifactId>webdrivermanager</artifactId>
315
- <version>5.8.0</version>
316
- </dependency>
292
+ Step 1: Setting Up the Topology
293
+ 1. Add Devices to the Workspace:
294
+ o Drag and drop:
295
+ ▪ 1 Router (e.g., 2911 or similar).
296
+ ▪ 1 Switch (e.g., 2960).
297
+ ▪ 3 PCs (PC-0, PC-1, PC-2).
298
+ ▪ 1 Cloud or Server (representing the internet).
299
+ Step 2: Assign IP Addresses
300
+ For Private Network (PCs and Router Internal Interface)
301
+ ● Assign Private IP Addresses to the PCs:
302
+ o PC-0: IP Address: 192.168.1.2 | Subnet Mask: 255.255.255.0 | Default Gateway:
303
+ 192.168.1.1
304
+ o PC-1: IP Address: 192.168.1.3 | Subnet Mask: 255.255.255.0 | Default Gateway:
305
+ 192.168.1.1
306
+ o PC-2: IP Address: 192.168.1.4 | Subnet Mask: 255.255.255.0 | Default Gateway:
307
+ 192.168.1.1
308
+ Step 3: Configure Router interface
309
+ 1) gig0/0
310
+ Router> enable
311
+ Router# configure terminal
312
+ Router(config)# interface gig0/0
313
+ Router(config-if)# ip address 192.168.1.1 255.255.255.0
314
+ Router(config-if)# no shutdown
315
+ 2) gig0/1
316
+ Router(config)# interface gig0/1
317
+ Router(config-if)# ip address 203.0.113.1 255.255.255.0
318
+ Router(config-if)# no shutdown
319
+ 3) Assign an IP Address to the Cloud or Server:
320
+ a. Cloud/Server IP Address: 203.0.113.2
321
+ b. Subnet Mask: 255.255.255.0
322
+ Step 4: Configure NAT on the Router
323
+ Define Inside and Outside Interfaces
324
+ Router(config)# interface gig0/0
325
+ Router(config-if)# ip nat inside
326
+ Router(config-if)# exit
327
+ Router(config)# interface gig0/1
328
+ Router(config-if)# ip nat outside
329
+ Router(config-if)# exit
330
+ Set Up PAT (Port Address Translation)
331
+ Allow multiple private IPs to share one public IP:
332
+ Router(config)# access-list 1 permit 192.168.1.0 0.0.0.255
333
+ Router(config)# ip nat inside source list 1 interface gig0/1 overload
334
+ Step 5: Configure Routing
335
+ Add a Default Route to direct traffic to the public network
336
+ Router(config)# ip route 0.0.0.0 0.0.0.0 203.0.113.2
337
+ Step 6: Test the Configuration
338
+ Test Internet Access from PCs
339
+ 1. Open the Command Prompt on any PC.
340
+ 2. Ping the external Cloud/Server (e.g., ping 203.0.113.2).
341
+ o If successful, NAT is working correctly.
342
+ Verify NAT Translations on the Router
343
+ On the router CLI, use the following command to see active NAT translations:
344
+ Router# show ip nat translations
317
345
 
318
- </dependencies>