Jyothi
Jyothi
Jyothi
JYOTHI T
Client side –
port = 12345
client_socket.connect(('127.0.0.1', port))
client_socket.send(message.encode())
client_socket.close()
Server side –
port = 12345
server_socket = socket(AF_INET,SOCK_STREAM)
server_socket.bind(('127.0.0.1', port))
server_socket.listen(1)
print('Server is listening:')
while True:
message = client_socket.recv(1024).decode()
client_socket.close()
server_socket.close()
Wireshark output
2. Write client and server socket programs using UDP for any
requirement.
Client side –
from socket import *
port = 12345
client_socket.close()
Server side –
from socket import *
port = 12345
while True:
message, client_address = server_socket.recvfrom(1024)
number = int(message.decode())
square = number ** 2
server_socket.sendto(str(square).encode(), client_address)
Run server code
Wireshark output -
3.Usage of ping and netstat in networks
Ping –
Ping works by sending an Internet Control Message Protocol (ICMP)
Echo Request to a specified interface on the network and waiting for
a reply. When a ping command is issued, a ping signal is sent to a
specified address. When the target host receives the echo request, it
responds by sending an echo reply packet.
Eg: ping youtube.com
Netstat –
The netstat command is used to show network status.
Traditionally, it is used more for problem determination than for
performance measurement. However, the netstat command can be
used to determine the amount of traffic on the network to ascertain
whether performance problems are due to network congestion.
The netstat command displays information regarding traffic on the
configured network interfaces, such as the following:
The address of any protocol control blocks associated with the
sockets and the state of all sockets
The number of packets received, transmitted, and dropped in
the communications subsystem
Cumulative statistics per interface
Routes and their status
Example : netstat -a