Network programming lab experiments
Network programming lab experiments
if __name__ == "__main__":
main()
Diffie hellman key exchange Distance vector
import math class NetworkGraph:
def __init__(self):
def power(a, b, P): self.nodes = set()
return a ** b % P self.edges = {}
status, output =
subprocess.getstatusoutput(request)
response = output if status == 0 else
f'Error: {output}'
connectionSocket.send(response.encode())
print('Bye')
connectionSocket.close()
Simple multicast routing
Receiver.py Sender.py
from socket import * import socket
import struct import time
carry = '0'
for j in range(max_len):
b = [x[j] for x in a]
result, carry = binary_addition(b, ['0'] * n,
carry)
if checksum_result != checksum:
print("There is an error detected")
else:
print("There is no error detected")
Gethostbyaddr()
The function gethostbyaddr() is used in network programming to retrieve the hostname corresponding
to a given IP address. It's part of the standard library in many programming languages like C, Python,
and others, and it provides reverse DNS lookup.