0% ont trouvé ce document utile (0 vote)
44 vues39 pages

CN Lab

Le document présente des expériences de laboratoire réalisées par un étudiant en informatique, Anurag Kumar, sur divers sujets liés aux réseaux informatiques, y compris l'implémentation des appels de procédure à distance (RPC), des applications utilisant des sockets TCP et UDP, et des algorithmes de routage. Il décrit également des simulations de commandes PING et TRACEROUTE, ainsi que des protocoles ARP et RARP, et fournit des exemples de code en Java et C. Enfin, il aborde la configuration de dispositifs réseau tels que les routeurs, les hubs et les commutateurs.

Transféré par

roshni97777
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF ou lisez en ligne sur Scribd
0% ont trouvé ce document utile (0 vote)
44 vues39 pages

CN Lab

Le document présente des expériences de laboratoire réalisées par un étudiant en informatique, Anurag Kumar, sur divers sujets liés aux réseaux informatiques, y compris l'implémentation des appels de procédure à distance (RPC), des applications utilisant des sockets TCP et UDP, et des algorithmes de routage. Il décrit également des simulations de commandes PING et TRACEROUTE, ainsi que des protocoles ARP et RARP, et fournit des exemples de code en Java et C. Enfin, il aborde la configuration de dispositifs réseau tels que les routeurs, les hubs et les commutateurs.

Transféré par

roshni97777
Copyright
© All Rights Reserved
Nous prenons très au sérieux les droits relatifs au contenu. Si vous pensez qu’il s’agit de votre contenu, signalez une atteinte au droit d’auteur ici.
Formats disponibles
Téléchargez aux formats PDF ou lisez en ligne sur Scribd
INSTITUTE OF TECHNOLOGY & MANAGEMENT Integrated Technical Campus: Engineering, Pharmacy & Management Approved by AICTE, Pharmacy Council of India, New Delhi & Affiliated to Dr. APJAKTU, Lucknow AL-1, Sector - 7, GIDA, Gorakhpur - 273209 (UP) Department of Computer Science & Engineering Name of Student: Anurag Kumar University Roll No.: 2201201640016 Lab Name: Computer Network Lab Lab Code: BCS653 Total Internal Lab. Max Marks: Submitted To: Mrs. Aisha Khatoon Experiment No. - 5 Objective: Write a program to implement RPC (Remote Procedure Call) RPC, or Remote Procedure Call, is a powerful technique for constructing distributed, client-server based applications, RPC uses the client-server architecture where the client requests a service, and the server provides it Advantages of RPC ‘Transparency: Makes remote procedure calls look like local ones, simplifying distributed application development. Abstraction; Abstracts the communication layer, allowing developers to focus on application logic, Reusability: Encourages code reuse by separating client and server functionalities. [Link] import [Link].*; import [Link].*; import [Link].®; class. serverPC ( public static void main(String ar{)) ServerSocket obj = new ServerSocket(18); while(true) t Socket obj2=0bj Laccept0; DatalnputStream dins= new DatalnputStream([Link]()); DataOutputStream dout= new DataOutputStream([Link](): String str=[Link](): Process p=[Link]().exec(str); Anurag Kumar (2201201640016) 1 } catch(Exception e) { [Link](e); } 1 [Link] import [Link].*; import [Link].*; import [Link]"; class clientPC { public static void main(String ar{]) { Try t BufferedReader brin=new BufferedReader(new InputStreamReader([Link])); Socket soc=new Socket("[Link]",818); DatalnputStream din= new DatalnputStream([Link]()): DataOutputStream dout= new DataOutputStream([Link]()); System_out printin("Enter a string : "); String st = [Link]):; [Link](st+\n)); [Link](); } catch (Exception e1) ( [Link] printin(el); } } } Anurag Kumar (2201201640016) Output- Anurag Kumar (2201201640016) Standard Experiment Ne Objective: Applications using TCP and UDP Sockets (like DNS) Program: Write a java program for DNS application. IDNSServer,java import [Link].*; import javanet.*; import [Link].*; public class DNSServer { private static final int PORT = 1248; public static void main(String] args) { [Link]("DNS Server started..."); try (ServerSocket serverSocket = new ServerSocket(PORT)) { while (true) { try (Socket clientSocket = serverSocket accept()) { [Link] printin("* Client connected..."): //Tnpat and output streams for communicating with the client BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket getInputStream()); PrintWriter out = new PrintWriter(clientSocket. getOutputStream(), true); 11 Read domain name from client String domainName = [Link] ine() [Link](’ Received domain name: " + domainName); J/ Resolve the domain name to an IP address String ipAddress = resolveDomainName(domainName); ‘Anurag Kumar (2201201640016) 11 Send the TP address back to the client out-printin(ipAddress); [Link] printin(* Sent IP address: " + ipAddress); } catch (IOException e) { [Link](” Connection error: " + [Link](); t } catch (IOException e) [ [Link](); private static String resolveDomainName(String domainName) ( try ( InetAddress inetAddress = [Link](domainName); retum [Link](); } catch (UnknownHostException e) { return "Unknown host"; JIDNSClient,java import [Link].*; import [Link].*; public class DNSClient It private static final String SERVER_ADDRESS = “localhost”; private static final int PORT = 1248; public static void main(String[] args) { try (Socket socket = new Socket(SERVER_ADDRESS, PORT) { ‘Anurag Kumar (2201201640016) // Input and output streams for communicating with the server BufferedReader in = new BufferedReader(new InputStreamReader(socket getInputStream() Ds Print Writer out = new PrintWriter([Link](), true); // Read domain name from the console BufferedReader consoleInput = new BufferedReader(new InputStreamReader([Link])); [Link] print("Enter domain name: "); String domainName = [Link](); // Send domain name to the server [Link](domainName); 1/ Read and display the IP address from the server String ipAddress = [Link] ine(); [Link] printin("IP address: " + ipAddress); } catch (IOException e) { eprintStackTrace(); ‘Anurag Kumar (2201201640016) Output- Anurag Kumar (2201201640016) Experiment No. - 7 Objective: Perform case study on different routing algorithms. 1. Link State routing Link State Routing is a method used in computer networks to figure out the best paths for data to travel. Unlike another method called distance-vector routing, where routers share their whole list of paths with their neighbours, Link State Routing has each router keeping a full map of the network. This helps routers make better decisions about where to send data. One of the most well-known protocols that use Link State Routing is called Open Shortest Path First, or OSPF. Key Features of Link State Routing Network Topology Awareness: Each router has a full view of the network topology. Link State Advertisements (LSAs): Routers periodically broadcast information to neighbors Shortest Path First (SPF) Algorithm: Uses algorithms like Dijkstra’s to compute the shortest path. Fast Convergence: Quickly adapt network changes and recalculates optimal paths. 2. Flooding Flooding is a simple routing algorithm where every incoming packet is sent out on every outgoing line, except the one it arrived on. This ensures that packets reach every node in the network, but can lead to excessive redundancy and bandwidth usage. Key Features of Flooding Optimality: Guarantees that the packet reaches every node. Economy: Highly inefficient due to excessive redundancy. Every node may receive multiple copies of the same packet, leading to high bandwidth consumption and potential network congestion. 3. Distance vector Routing Distance Vector Routing is a routing protocol used in computer networks to determine the best path for data packets to travel from a source to a destination. tis based on the Bellman-Ford algorithm and is one of the simplest types of routing protocols. Each router maintains a table (or vector) that holds the distance (or cost) to every other router in the network. This table is updated periodically based on information received from neighbouring routers. Bellman-Ford Algorithm calculates the shortest path from a single source node to all other nodes in a weighted graph. It helps to determine the shortest path to each destination. Anurag Kumar (2201201640016) Key Features of Distance Vector Routing 1 Initialization: Each router initializes its routing table with the direct distances between its immediate neighbours. For all other destinations, the distance is set to infinity (unknown), 2. Periodic Updates: Routers periodically exchange routing tables with their immediate neighbours. Each router updates own routing table based on the received information. If a router learns of a shorter path to a destination through a neighbour, it updates its table with the new distance and next hop. 3. Bellman-Ford Update Rule: The routing able is updated using the Bellman-Ford equation: Dy) = min (c(x, y) + D.(y)) Here D,(y)is the distance from router v to destination y, ¢(x, y) is the cost to reach neighbour x, and Dx(y) is the distance from x to y 4, Convergence: Over time, the routing tables across the network converge, meaning they become stable and reflect the shortest paths to all destinations. Performance Results Flooding High’ [Distance Vector [Medium Anurag Kumar (2201201640016) Experiment No. - 8 Objective: Write a code simulating PING and TRACEROUTE commands Java program for simulating PING command import javaio.*; import [Link].*; class pinger t public static void main(String args{]) i uy t String su; [Link] print(" Enter the IP Address to be Ping : BufferedReader bri=new BufferedReader(new InputStreamReader(System in)); String ip=[Link]; Runtime H=Runtime getRuntime(); Process p=[Link]("ping * + ip); InputStream ins=[Link](); BufferedReader br2=new BufferedReader(new InputStreamReader(ins)): while((str=[Link])!=null) { [Link] println(” " + str) } } ‘Anurag Kumar (2201201640016) catch(Exception e) { ‘[Link] printin([Link]()) } Java program for simulating TRACEROUTE command import [Link] BufferedReader; import [Link] public class traceroute i public static void runSystemCommand(String command) i uy Process p= Runtime. getRuntime().exec(command); ‘Anurag Kumar (2201201640016) BufferedReader inputStream = new BufferedReader(new InputStreamReader([Link]())); String st = while ((st=[Link]()) != null) [Link](st); } catch (Exception e) public static void main(String] args) { String ip = "www [Link] in" runSystemCommand(tracert " + ip); ‘Anurag Kumar (2201201640016) Experiment No. - 9 Objective: Write a code simulating ARP /RARP protocols. Devices communicate in a network simulation to resolve IP addresses to MAC addresses (ARP) or MAC addresses to IP addresses (RARP) using the address resolution protocol (ARP) and the reverse address resolution protocol (RARP). Here we are performing implementations of ARP and RARP protocols in C programming, ARP Simulation (Address Resolution Protocol):- ARP is used to resolve IP addresses to MAC addresses on a local network. Program Code #include include // Define a structure for ARP table entry struct ARPEntry { char ip_address[16]; // IPva address in string format (1009200 00) char mac_address(18}; // MAC address in string format (xx:XX:2X:XX2XX:%) i // Sample ARP table (can be expanded with more entries) struct ARPEntry arp_table[] = { {°[Link]","00:11:22:33:44:55"), (7192.168.1.2, 11:22:33:44:55:66"}, {"[Link]", "22:33:44:55:66:77"}, // Add more entries as needed 1] Function to perform ARP resolution void arp_resolve(const char* ip_address) { int is int num_entry = sizeof(arp_table) / sizeof{struct ARPEntry); int found ‘Anurag Kumar (2201201640016) {Search the ARP table for the given |P address for (i= 0; i IP Address %s -> MAC Address %s\n", ip_address, arp_table[i].mac_address); found = 1; break; } t If (Ifound) { print{("ARP=> IP Address %s is not found in ARP table\n", ip_address}; int main() { 11 Simulating ARP requests arp_resolve(""[Link]"), arp_resolve("[Link]"); arp_resolve("[Link]"); // IP address not in ARP table return 0; RARP Simulation (Reverse Address Resolution Protocol): RARP is used to resolve MAC addresses to IP addresses. Program Code ‘Anurag Kumar (2201201640016) include include // Structure of RARP table entry struct RARPEntry { char mac_address[218]; // MAC address char ip_address(16]; // IPv4 address i JT RARP table struct RARPEntry rarp_table{] = { {°00:11:22:33: [Link]"}, {°11:22:33:44:55:66", "[Link]"), (°22:33:44:55:66:77", "[Link]"), i J/ Function to perform RARP resolution void rarp_resolve(const char* mac_address) { int i; int num_entry = sizeof(rarp_table} / sizeof{struct RARPEntry); int found 1 Search the RARP table for the given MAC address for (i =0;1 MAC Address %s -> IP Address %s\n", mac_address, rarp_tablefi found = 1; break; ‘Anurag Kumar (2201201640016) )_address); if (ifound) { printf("RARP=> MAC Address %s is not exist in RARP table\n", mac_address); int main(){ IP RARP requests, rarp_resolve(*00:11:22:33:44:55"); rarp_resolve("11:22:33:44:55:66"); rarp_resolve("00:00:00:00:00:00"); // MAC address not in RARP table return 0; ‘Anurag Kumar (2201201640016) Experiment No. -10 Objective: Configuration of router, hub, switch etc. (using real devices or simulators) Introduction: Repeater:Functioning at Physical Layer.A repeater is an electronic device that receives a signal and retransmits it at a higher level and/or higher power, or onto the other side of an obstruction, so that the signal can cover longer distances. Repeater have two ports ,so cannot be use to connect for more than two devices Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator is a device for connecting multiple twisted pair or fiber optic Ethernet devices together and making them act as a single network segment. Hubs work at the physical layer (layer 1) of the OSI model. The device is a form of multiport repeater. Repeater hubs also participate in collision detection, forwarding a jam signal to all ports if it detects a collision. ‘Switch: network switch or switching hub is a computer networking device that connects network segments. The term commonly refers to a network bridge that processes and routes data at the data link layer (layer 2) of the OSI model. Switches that additionally process data at the network layer (layer 3 and above) are often referred to as Layer 3 switches or multilayer switches. Bridge: A network bridge connects multiple network segments at the data link layer (Layer 2) of the OSI model. In Ethernet networks, the term bridge formally means a device that behaves according to the IEEE 802.10 standard. A bridge and switch are very much alike; a switch being a bridge with numerous ports. Switch or Layer 2 switch is often used interchangeably with [Link] can analyze incoming data packets to determine if the bridge is able to send the given packet to another segment of the network. Router: A router is an electronic device that interconnects two or more computer networks, and selectively interchanges packets of data between them, Each data packet contains address information that a router can use to determine if the source and destination are on the same network, or if the data packet must be transferred from one network to another. Where multiple routers are used in a large collection of interconnected networks, the routers exchange information about target system addresses, so that each router can build up a table showing the preferred paths between any two systems on the interconnected networks. > —wy Hub Switch Router ‘Anurag Kumar (2201201640016) Router Switch 1 So Switch 2 Hub A a) Hub B 7 Program Code : Router Configuration- Router> enable Router configure terminal Router(config}#t hostname Ri Router(config}# interface gigabitEthernet 0/0 Router(config-if}# ip address [Link] [Link] Router(config-if}# no shutdown Router(config-if}# exit Router(config}# ip route [Link] [Link] [Link] ! (default route if needed) Router(config}# exit Router# write memory ‘Anurag Kumar (2201201640016) Switch Configuration- Switch> enable Switch configure terminal Switch(confight hostname S1 Switch(config} interface vian 4 Switch(configcif)W ip address [Link] [Link], Switch(config-if}# no shutdown Switch(config-if}# exit ‘Switch(config)# ip default-gateway [Link] Switch(config}# exit Switch# write memory Hub Configuration- No configuration. You just plug it in and connect devices. (That's why hubs are outdated and rarely used in madern networks.) ‘Anurag Kumar (2201201640016) Experiment No. - 5 Objective: Write a program to implement RPC (Remote Procedure Call) RPC, or Remote Procedure Call, is a powerful technique for constructing distributed, client-server based applications, RPC uses the client-server architecture where the client requests a service, and the server provides it Advantages of RPC ‘Transparency: Makes remote procedure calls look like local ones, simplifying distributed application development. Abstraction; Abstracts the communication layer, allowing developers to focus on application logic, Reusability: Encourages code reuse by separating client and server functionalities. [Link] import [Link].*; import [Link].*; import [Link].®; class. serverPC ( public static void main(String ar{)) ServerSocket obj = new ServerSocket(18); while(true) t Socket obj2=0bj Laccept0; DatalnputStream dins= new DatalnputStream([Link]()); DataOutputStream dout= new DataOutputStream([Link](): String str=[Link](): Process p=[Link]().exec(str); Akash Kumar Paswan(2201201640010) 1 } catch(Exception e) { [Link](e); } 1 [Link] import [Link].*; import [Link].*; import [Link]"; class clientPC { public static void main(String ar{]) { Try t BufferedReader brin=new BufferedReader(new InputStreamReader([Link])); Socket soc=new Socket("[Link]",818); DatalnputStream din= new DatalnputStream([Link]()): DataOutputStream dout= new DataOutputStream([Link]()); System_out printin("Enter a string : "); String st = [Link]):; [Link](st+\n)); [Link](); } catch (Exception e1) ( [Link] printin(el); } } } Akash Kumar Paswan(2201201640010) Output- Akash Kumar Paswan(2201201640010) Standard Experiment Ne Objective: Applications using TCP and UDP Sockets (like DNS) Program: Write a java program for DNS application. IDNSServer,java import [Link].*; import javanet.*; import [Link].*; public class DNSServer { private static final int PORT = 1248; public static void main(String] args) { [Link]("DNS Server started..."); try (ServerSocket serverSocket = new ServerSocket(PORT)) { while (true) { try (Socket clientSocket = serverSocket accept()) { [Link] printin("* Client connected..."): //Tnpat and output streams for communicating with the client BufferedReader in = new BufferedReader(new InputStreamReader(clientSocket getInputStream()); PrintWriter out = new PrintWriter(clientSocket. getOutputStream(), true); 11 Read domain name from client String domainName = [Link] ine() [Link](’ Received domain name: " + domainName); J/ Resolve the domain name to an IP address String ipAddress = resolveDomainName(domainName); Akash Kumar Paswan(2201201640010) 11 Send the TP address back to the client out-printin(ipAddress); [Link] printin(* Sent IP address: " + ipAddress); } catch (IOException e) { [Link](” Connection error: " + [Link](); t } catch (IOException e) [ [Link](); private static String resolveDomainName(String domainName) ( try ( InetAddress inetAddress = [Link](domainName); retum [Link](); } catch (UnknownHostException e) { return "Unknown host"; JIDNSClient,java import [Link].*; import [Link].*; public class DNSClient It private static final String SERVER_ADDRESS = “localhost”; private static final int PORT = 1248; public static void main(String[] args) { try (Socket socket = new Socket(SERVER_ADDRESS, PORT) { Akash Kumar Paswan(2201201640010) // Input and output streams for communicating with the server BufferedReader in = new BufferedReader(new InputStreamReader(socket getInputStream() Ds Print Writer out = new PrintWriter([Link](), true); // Read domain name from the console BufferedReader consoleInput = new BufferedReader(new InputStreamReader([Link])); [Link] print("Enter domain name: "); String domainName = [Link](); // Send domain name to the server [Link](domainName); 1/ Read and display the IP address from the server String ipAddress = [Link](); [Link]-printin("IP address: " + ipAddress); } catch (IOException e) { eprintStackTrace(); Akash Kumar Paswan(2201201640010) Output- Akash Kumar Paswan(2201201640010) Experiment No. - 7 Objective: Perform case study on different routing algorithms. 1. Link State routing Link State Routing is a method used in computer networks to figure out the best paths for data to travel. Unlike another method called distance-vector routing, where routers share their whole list of paths with their neighbours, Link State Routing has each router keeping a full map of the network. This helps routers make better decisions about where to send data. One of the most well-known protocols that use Link State Routing is called Open Shortest Path First, or OSPF. Key Features of Link State Routing Network Topology Awareness: Each router has a full view of the network topology. Link State Advertisements (LSAs): Routers periodically broadcast information to neighbors Shortest Path First (SPF) Algorithm: Uses algorithms like Dijkstra’s to compute the shortest path. Fast Convergence: Quickly adapt network changes and recalculates optimal paths. 2. Flooding Flooding is a simple routing algorithm where every incoming packet is sent out on every outgoing line, except the one it arrived on. This ensures that packets reach every node in the network, but can lead to excessive redundancy and bandwidth usage. Key Features of Flooding Optimality: Guarantees that the packet reaches every node. Economy: Highly inefficient due to excessive redundancy. Every node may receive multiple copies of the same packet, leading to high bandwidth consumption and potential network congestion. 3. Distance vector Routing Distance Vector Routing is a routing protocol used in computer networks to determine the best path for data packets to travel from a source to a destination. tis based on the Bellman-Ford algorithm and is one of the simplest types of routing protocols. Each router maintains a table (or vector) that holds the distance (or cost) to every other router in the network. This table is updated periodically based on information received from neighbouring routers. Bellman-Ford Algorithm calculates the shortest path from a single source node to all other nodes in a weighted graph. It helps to determine the shortest path to each destination. Akash Kumar Paswan(2201201640010) Key Features of Distance Vector Routing 1 Initialization: Each router initializes its routing table with the direct distances between its immediate neighbours. For all other destinations, the distance is set to infinity (unknown), 2. Periodic Updates: Routers periodically exchange routing tables with their immediate neighbours. Each router updates own routing table based on the received information. If a router learns of a shorter path to a destination through a neighbour, it updates its table with the new distance and next hop. 3. Bellman-Ford Update Rule: The routing able is updated using the Bellman-Ford equation: Dy) = min (c(x, y) + D.(y)) Here D,(y)is the distance from router v to destination y, ¢(x, y) is the cost to reach neighbour x, and Dx(y) is the distance from x to y 4, Convergence: Over time, the routing tables across the network converge, meaning they become stable and reflect the shortest paths to all destinations. Performance Results Flooding High’ [Distance Vector [Medium Akash Kumar Paswan(2201201640010) Experiment No. - 8 Objective: Write a code simulating PING and TRACEROUTE commands Java program for simulating PING command import javaio.*; import [Link].*; class pinger t public static void main(String args{]) i uy t String su; [Link] print(" Enter the IP Address to be Ping : BufferedReader bri=new BufferedReader(new InputStreamReader(System in)); String ip=[Link]; Runtime H=Runtime getRuntime(); Process p=[Link]("ping * + ip); InputStream ins=[Link](); BufferedReader br2=new BufferedReader(new InputStreamReader(ins)): while((str=[Link])!=null) { [Link] println(” " + str) } } ‘Akash Kumar Paswan(2201201640010) catch(Exception e) { ‘[Link] printin([Link]()) } Java program for simulating TRACEROUTE command import [Link] BufferedReader; import [Link] public class traceroute i public static void runSystemCommand(String command) i uy Process p= Runtime. getRuntime().exec(command); ‘Akash Kumar Paswan(2201201640010) BufferedReader inputStream = new BufferedReader(new InputStreamReader([Link]())); String st = while ((st=[Link]()) != null) [Link](st); } catch (Exception e) public static void main(String] args) { String ip = "www [Link] in" runSystemCommand(tracert " + ip); ‘Akash Kumar Paswan(2201201640010) Experiment No. - 9 Objective: Write a code simulating ARP /RARP protocols. Devices communicate in a network simulation to resolve IP addresses to MAC addresses (ARP) or MAC addresses to IP addresses (RARP) using the address resolution protocol (ARP) and the reverse address resolution protocol (RARP). Here we are performing implementations of ARP and RARP protocols in C programming, ARP Simulation (Address Resolution Protocol):- ARP is used to resolve IP addresses to MAC addresses on a local network. Program Code #include include // Define a structure for ARP table entry struct ARPEntry { char ip_address[16]; // IPva address in string format (1009200 00) char mac_address(18}; // MAC address in string format (xx:XX:2X:XX2XX:%) i // Sample ARP table (can be expanded with more entries) struct ARPEntry arp_table[] = { {°[Link]","00:11:22:33:44:55"), (7192.168.1.2, 11:22:33:44:55:66"}, {"[Link]", "22:33:44:55:66:77"}, // Add more entries as needed 1] Function to perform ARP resolution void arp_resolve(const char* ip_address) { int is int num_entry = sizeof(arp_table) / sizeof{struct ARPEntry); int found ‘Akash Kumar Paswan (2201201640010) {Search the ARP table for the given |P address for (i= 0; i IP Address %s -> MAC Address %s\n", ip_address, arp_table[i].mac_address); found = 1; break; } t If (Ifound) { print{("ARP=> IP Address %s is not found in ARP table\n", ip_address}; int main() { 11 Simulating ARP requests arp_resolve(""[Link]"), arp_resolve("[Link]"); arp_resolve("[Link]"); // IP address not in ARP table return 0; RARP Simulation (Reverse Address Resolution Protocol): RARP is used to resolve MAC addresses to IP addresses. Program Code ‘Akash Kumar Paswan (2201201640010) include include // Structure of RARP table entry struct RARPEntry { char mac_address[218]; // MAC address char ip_address(16]; // IPv4 address i JT RARP table struct RARPEntry rarp_table{] = { {°00:11:22:33: [Link]"}, {°11:22:33:44:55:66", "[Link]"), (°22:33:44:55:66:77", "[Link]"), i J/ Function to perform RARP resolution void rarp_resolve(const char* mac_address) { int i; int num_entry = sizeof(rarp_table} / sizeof{struct RARPEntry); int found 1 Search the RARP table for the given MAC address for (i =0;1 MAC Address %s -> IP Address %s\n", mac_address, rarp_tablefi found = 1; break; ‘Akash Kumar Paswan (2201201640010) )_address); if (ifound) { printf("RARP=> MAC Address %s is not exist in RARP table\n", mac_address); int main(){ IP RARP requests, rarp_resolve(*00:11:22:33:44:55"); rarp_resolve("11:22:33:44:55:66"); rarp_resolve("00:00:00:00:00:00"); // MAC address not in RARP table return 0; ‘Akash Kumar Paswan (2201201640010) Experiment No. -10 Objective: Configuration of router, hub, switch etc. (using real devices or simulators) Introduction: Repeater:Functioning at Physical Layer.A repeater is an electronic device that receives a signal and retransmits it at a higher level and/or higher power, or onto the other side of an obstruction, so that the signal can cover longer distances. Repeater have two ports ,so cannot be use to connect for more than two devices Hub: An Ethernet hub, active hub, network hub, repeater hub, hub or concentrator is a device for connecting multiple twisted pair or fiber optic Ethernet devices together and making them act as a single network segment. Hubs work at the physical layer (layer 1) of the OSI model. The device is a form of multiport repeater. Repeater hubs also participate in collision detection, forwarding a jam signal to all ports if it detects a collision. ‘Switch: network switch or switching hub is a computer networking device that connects network segments. The term commonly refers to a network bridge that processes and routes data at the data link layer (layer 2) of the OSI model. Switches that additionally process data at the network layer (layer 3 and above) are often referred to as Layer 3 switches or multilayer switches. Bridge: A network bridge connects multiple network segments at the data link layer (Layer 2) of the OSI model. In Ethernet networks, the term bridge formally means a device that behaves according to the IEEE 802.10 standard. A bridge and switch are very much alike; a switch being a bridge with numerous ports. Switch or Layer 2 switch is often used interchangeably with [Link] can analyze incoming data packets to determine if the bridge is able to send the given packet to another segment of the network. Router: A router is an electronic device that interconnects two or more computer networks, and selectively interchanges packets of data between them, Each data packet contains address information that a router can use to determine if the source and destination are on the same network, or if the data packet must be transferred from one network to another. Where multiple routers are used in a large collection of interconnected networks, the routers exchange information about target system addresses, so that each router can build up a table showing the preferred paths between any two systems on the interconnected networks. > —wy Hub Switch Router ‘Akash Kumar Paswan (2201201640010) Router Switch 1 Lo Switch 2 Hub A a) Hub B 7 Program Code : Router Configuration- Router> enable Router configure terminal Router(config}#t hostname Ri Router(config}# interface gigabitEthernet 0/0 Router(config-if}# ip address [Link] [Link] Router(config-if}# no shutdown Router(config-if}# exit Router(config}# ip route [Link] [Link] [Link] ! (default route if needed) Router(config}# exit Router# write memory ‘Akash Kumar Paswan (2201201640010) Switch Configuration- Switch> enable Switch configure terminal Switch(confight hostname S1 Switch(config} interface vian 4 Switch(configcif)W ip address [Link] [Link], Switch(config-if}# no shutdown Switch(config-if}# exit ‘Switch(config)# ip default-gateway [Link] Switch(config}# exit Switch# write memory Hub Configuration- No configuration. You just plug it in and connect devices. (That's why hubs are outdated and rarely used in madern networks.) ‘Akash Kumar Paswan (2201201640010)

Vous aimerez peut-être aussi