Git Product home page Git Product logo

2c.arp_rarp_protocols's Introduction

EX 2c.SIMULATING ARP /RARP PROTOCOLS

Register No: 212222230045

Name: HARISH RAGAVENDRA S

AIM

To write a python program for simulating ARP protocols using TCP.

ALGORITHM:

Client:

  1. Start the program
  2. Using socket connection is established between client and server.
  3. Get the IP address to be converted into MAC address.
  4. Send this IP address to server.
  5. Server returns the MAC address to client.

Server:

  1. Start the program
  2. Accept the socket which is created by the client.
  3. Server maintains the table in which IP and corresponding MAC addresses are stored.
  4. Read the IP address which is send by the client.
  5. Map the IP address with its MAC address and return the MAC address to client. P

PROGRAM - ARP

Client Program:

import socket
s=socket.socket()
s.bind(('localhost',8000))
s.listen(5)
c,addr=s.accept()
address={"165.165.80.80":"6A:08:AA:C2","165.165.79.1":"8A:BC:E3:FA"};
while True:
    ip=c.recv(1024).decode()
    try:
        c.send(address[ip].encode())
    except KeyError:
        c.send("Not Found".encode())    

Server Program:

import socket
s=socket.socket()
s.connect(('localhost',8000))
while True:
    ip=input("Enter logical address: ")
    s.send(ip.encode())
    print("MAC Address",s.recv(1024).decode())

OUPUT - ARP

Screenshot 2024-03-04 143614

PROGRAM - RARP

Client Progam:

import socket
s=socket.socket()
s.bind(('localhost',9000))
s.listen(5)
c,addr=s.accept()
address={"6A:08:AA:C2":"192.168.1.100","8A:BC:E3:FA":"192.168.1.99"}
while True:
    ip=c.recv(1024).decode()
    try:
        c.send(address[ip].encode())
    except KeyError:
        c.send("Not found".encode())    

Server Program:

import socket
s=socket.socket()
s.connect(('localhost',9000))
while True:
    ip=input("Enter mac address: ")
    s.send(ip.encode())
    print("Logical address",s.recv(1024).decode())

OUPUT -RARP

Screenshot 2024-02-26 144916

RESULT

Thus, the python program for simulating ARP protocols using TCP was successfully executed.

2c.arp_rarp_protocols's People

Contributors

nalinig007 avatar harish-ragavendra-25 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.