1. What is Hamming Code?
2. What is CRC?
3. Which one is better and why?
4. Application of both
5. What is Redundant bit?
*CRC -*
1. What is CRC?
2. Difference between Hamming and CRC
3. Which one is used for error correction?
*VLAN -*
1. What is VLAN?
2. Advantage and it's use
3. Which Model is it used?
4. What different types of models?
*Linux -*
1. What are trouble shooting commands?
2. Difference between trouble shooting vs networking commands
3. What is ARP? Use?
4. What is Dig command?
5. What is Netstat?
6. IP vs Netstat
7. What is Switching and types?
*Network Architecture -*
1. Explain subnet and dhcp
2. Topology?
3. Classful and Classless
4. Handshaking
5. Router, Hub, Bridge
*Subnetting -*
1. What is Physical and Virtual address?
2. Is Dynamic routing similar to Circuit Switching?
3. What is Layer? Applications of each layer
4. What is Socket?
5. What is subnetting?
*Socket Programming -*
1. What is Circuit Switching?
2. Socket vs Port
3. What is UDP? TCP? Difference
4. What is Physical and Virtual address in Socket? Difference
5. Is Dynamic routing similar to Circuit Switching?
*DHCP -*
1. What's DHCP use for?
2. Socket Programming
Hamming Code:
1. A technique for error-correcting digital data transmission over communication channels.
2. A checksum algorithm for detecting changes in data during transmission or storage.
3. Hamming Code is better for error correction than CRC.
4. Hamming Code is used in digital communication and storage systems, while CRC is used in data communication protocols.
5. A redundant bit is an extra bit used for error detection or correction.
CRC:
1. A checksum algorithm for detecting changes in data during transmission or storage.
2. Used for error detection, not correction.
3. Hamming Code is better for error correction than CRC.
4. Used in data communication protocols like Ethernet and ATM.
5. A redundant bit is not used in CRC.
VLAN:
1. A virtual LAN used to group devices together based on logical criteria rather than physical location.
2. Advantages include improved security, network segmentation, and easier network management.
3. Used in the OSI model's Data Link layer.
4. Types include port-based, MAC-based, and protocol-based VLANs.
Linux:
1. Commands used to diagnose and resolve issues with a Linux system.
2. Troubleshooting commands focus on identifying and resolving system issues, while networking commands focus on network configuration and management.
3. ARP is Address Resolution Protocol, used to map IP addresses to MAC addresses.
4. Dig is a command-line DNS lookup tool.
5. Netstat is a command-line network utility for displaying active network connections.
6. IP (Internet Protocol) is a network layer protocol, while Netstat is a utility used to display network connection information.
7. Switching refers to the process of forwarding network traffic between devices. Types include circuit switching, packet switching, and message switching.
Network Architecture:
1. Subnetting is the process of dividing a network into smaller subnetworks. DHCP (Dynamic Host Configuration Protocol) is a network management protocol used to dynamically assign IP addresses and other network configuration settings to devices on a network.
2. Topology refers to the physical or logical arrangement of devices in a network.
3. Classful addressing uses fixed-length subnet masks, while classless addressing uses variable-length subnet masks.
4. Handshaking is the process of establishing and confirming a connection between two devices.
5. A router is a networking device used to forward data packets between networks. A hub is a device used to connect multiple devices on a network. A bridge is a device used to connect two separate network segments.
Subnetting:
1. Physical addresses are hardware addresses assigned to network devices, while virtual addresses are IP addresses assigned to network interfaces.
2. No, Dynamic routing is a method for routing data dynamically based on real-time network conditions, while Circuit Switching is a method for establishing a dedicated communication channel between two devices.
3. Layers refer to the abstraction levels of the OSI model. Each layer has a specific function, such as data encapsulation, error detection, or data transmission. Applications of each layer vary depending on the specific protocol or network service being used.
4. A socket is an endpoint of a two-way communication link between two programs running on a network.
5. Subnetting is the process of dividing a network into smaller subnetworks.
Socket Programming:
1. Circuit Switching is a method for establishing a dedicated communication channel between two devices.
2. A socket is an endpoint of a two-way communication link between two programs, while a port is a specific address used to identify a specific process or service on a network device.
3. UDP (User Datagram Protocol) is a connectionless protocol that does not guarantee reliable data transmission, while TCP (Transmission Control Protocol) is a connection-oriented protocol that ensures
Basics command in Computer Networks:
>ipconfig
>tracert www.tcetmumbai.in
>nslookup www.tcetmumbai.in
>netstat
> route print
>ARP
Socket Programming in Computer network:
Java-
TCP Server:
import java.io.*;
import java.net.*;
public class TCPServer {
public static void main(String[] args) throws IOException {
ServerSocket serverSocket = null;
try {
serverSocket = new ServerSocket(8888);
} catch (IOException e) {
System.err.println("Could not listen on port: 8888.");
System.exit(1);
}
Socket clientSocket = null;
try {
System.out.println("Waiting for connection...");
clientSocket = serverSocket.accept();
System.out.println("Connection established!");
} catch (IOException e) {
System.err.println("Accept failed.");
System.exit(1);
}
PrintWriter out = new PrintWriter(clientSocket.getOutputStream(), true);
BufferedReader in = new BufferedReader(new
InputStreamReader(clientSocket.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null) {
System.out.println("Received: " + inputLine);
out.println("ACK: " + inputLine);
}
out.close();
in.close();
clientSocket.close();
serverSocket.close();
}
}
TCP Client:
import java.io.*;
import java.net.*;
public class TCPClient {
public static void main(String[] args) throws IOException
{
Socket socket = null;
PrintWriter out = null;
BufferedReader in = null;
try {
socket = new Socket("localhost", 8888);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
} catch (UnknownHostException e)
{
System.err.println("Unknown host: localhost");
System.exit(1);
} catch (IOException e)
{
System.err.println("Could not establish connection to localhost.");
System.exit(1);
}
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String userInput;
while ((userInput = stdIn.readLine()) != null)
{
out.println(userInput);
System.out.println("Sent: " + userInput);
System.out.println("Received: " + in.readLine());
}
out.close();
in.close();
stdIn.close();
socket.close();
}
}
UDP Server:
import java.net.*;
import java.io.*;
public class UDPServer {
public static void main(String[] args) {
try {
DatagramSocket serverSocket = new DatagramSocket(9876);
byte[] receiveData = new byte[1024];
byte[] sendData = new byte[1024];
System.out.println("Server is listening on port 9876...");
while (true) {
DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length);
serverSocket.receive(receivePacket);
String message = new String(receivePacket.getData());
InetAddress IPAddress = receivePacket.getAddress();
int port = receivePacket.getPort();
System.out.println("Received from client: " + message.trim());
String replyMessage = "ACK: " + message.trim();
sendData = replyMessage.getBytes();
DatagramPacket sendPacket = new DatagramPacket(sendData,
sendData.length, IPAddress, port);
serverSocket.send(sendPacket); }}catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
UDP Client:
import java.net.*;
import java.io.*;
import java.util.Scanner;
public class UDPClient {
public static void main(String[] args) {
try {
DatagramSocket clientSocket = new DatagramSocket();
InetAddress IPAddress = InetAddress.getByName("localhost");
int port = 9876;
while (true) {
byte[] sendData = new byte[1024];
byte[] receiveData = new byte[1024];
String message = getUserInput();
sendData = message.getBytes();
DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length,
IPAddress, port);
clientSocket.send(sendPacket);
DatagramPacket receivePacket = new DatagramPacket(receiveData,
receiveData.length);
clientSocket.receive(receivePacket);
String replyMessage = new String(receivePacket.getData());
System.out.println("Received from server: " + replyMessage.trim());
}
}
catch (Exception e) {
System.out.println("Error: " + e.getMessage());
}
}
private static String getUserInput() {
System.out.print("Enter message to send: ");
Scanner scanner = new Scanner(System.in);
String message = scanner.nextLine();
return message;
}
}
CRC:
#include <stdio.h>
#include <string.h>
int main()
{
int i, j, keylen, msglen, error = 0;
char input[150], key[50], temp[50], quot[150], rem[50], key1[50]; printf("Enter Data: ");
fgets(input, sizeof(input), stdin); printf("Enter Key: ");
fgets(key, sizeof(key), stdin);
keylen = strlen(key) - 1; msglen = strlen(input) - 1; strcpy(key1, key);
for (i = 0; i < keylen - 1; i++)
{
input[msglen + i] = '0';
}
for (i = 0; i < keylen; i++)
{
temp[i] = input[i]; }
for (i = 0; i < msglen; i++)
{
quot[i] = temp[0];
if (quot[i] == '0')
{
for (j = 0; j < keylen; j++)
{
key[j] = '0';
}
}
else
{
for (j = 0; j < keylen; j++)
{
key[j] = key1[j];
}
}
for (j = keylen - 1; j > 0; j--)
{
if (temp[j] == key[j])
{
rem[j - 1] = '0';
}
else
{
rem[j - 1] = '1';
}}
rem[keylen - 1] = input[i + keylen];
strcpy(temp, rem); }
strcpy(rem, temp);
printf("\nQuotient is ");
for (i = 0; i < msglen; i++)
{
printf("%c", quot[i]); }
printf("\nRemainder is ");
for (i = 0; i < keylen - 1; i++)
{
printf("%c", rem[i]);
if (rem[i] != '0')
{
error = 1;
}
}
printf("\n");
if (error)
{
printf("Error detected in the data.\n");
}
else
{
printf("No error detected in the data.\n");
}
printf("Final data is: ");
for (i = 0; i < msglen; i++)
{
printf("%c", input[i]);
}
if (error)
{
for (i = 0; i < keylen - 1; i++)
{
printf("%c", rem[i]);
}
}
printf("\n");
return 0;}
Hamming:
#include<stdio.h>
void main() {
int data[10];
int dataatrec[10],c,c1,c2,c3,i;
printf("Enter 4 bits of data one by one\n");
scanf("%d",&data[0]);
scanf("%d",&data[1]);
scanf("%d",&data[2]);
scanf("%d",&data[4]);
data[6]=data[0]^data[2]^data[4];
data[5]=data[0]^data[1]^data[4];
data[3]=data[0]^data[1]^data[2];
printf("\nEncoded data is\n");
for(i=0;i<7;i++)
printf("%d",data[i]);
printf("\n\nEnter received data bits one by one\n");
for(i=0;i<7;i++)
scanf("%d",&dataatrec[i]);
c1=dataatrec[6]^dataatrec[4]^dataatrec[2]^dataatrec[0];
c2=dataatrec[5]^dataatrec[4]^dataatrec[1]^dataatrec[0];
c3=dataatrec[3]^dataatrec[2]^dataatrec[1]^dataatrec[0];
c=c3*4+c2*2+c1 ;
if(c==0) {
printf("\nNo error while transmission of data\n");
}
else {
printf("\nError on position %d",c);
printf("\nData sent : ");
for(i=0;i<7;i++)
printf("%d",data[i]);
printf("\nData received : ");
for(i=0;i<7;i++)
printf("%d",dataatrec[i]);
printf("\nCorrect message is\n");
if(dataatrec[7-c]==0)
dataatrec[7-c]=1;
else
dataatrec[7-c]=0;
for (i=0;i<7;i++) {
printf("%d",dataatrec[i]);}}}
In PYTHON :
TCP
Server.py
# first of all import the socket library
import socket
# next create a socket object
s = socket.socket()
print ("Socket successfully created")
# reserve a port on your computer in our
# case it is 12345 but it can be anything
port = 12345
# Next bind to the port
# we have not typed any ip in the ip field
# instead we have inputted an empty string
# this makes the server listen to requests
# coming from other computers on the network
s.bind(('', port))
print ("socket binded to %s" %(port))
# put the socket into listening mode
s.listen(5)
print ("socket is listening")
# a forever loop until we interrupt it or
# an error occurs
while True:
# Establish connection with client.
c, addr = s.accept()
print ('Got connection from', addr )
# send a thank you message to the client. encoding to send byte type.
c.send('Thank you for connecting'.encode())
# Close the connection with the client
c.close()
# Breaking once connection closed
Break
CLIENt.py
# Import socket module
import socket
# Create a socket object
s = socket.socket()
# Define the port on which you want to connect
port = 12345
# connect to the server on local computer
s.connect(('127.0.0.1', port))
# receive data from the server and decoding to get the string.
print (s.recv(1024).decode())
# close the connection
s.close()
UDP
Server.py
import socket
localIP = "127.0.0.1"
localPort = 20001
bufferSize = 1024
msgFromServer = "Hello UDP Client"
bytesToSend = str.encode(msgFromServer)
# Create a datagram socket
UDPServerSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
# Bind to address and ip
UDPServerSocket.bind((localIP, localPort))
print("UDP server up and listening")
# Listen for incoming datagrams
while(True):
bytesAddressPair = UDPServerSocket.recvfrom(bufferSize)
message = bytesAddressPair[0]
address = bytesAddressPair[1]
clientMsg = "Message from Client:{}".format(message)
clientIP = "Client IP Address:{}".format(address)
print(clientMsg)
print(clientIP)
# Sending a reply to client
UDPServerSocket.sendto(bytesToSend, address)
Client.py
import socket
msgFromClient = "Hello UDP Server"
bytesToSend = str.encode(msgFromClient)
serverAddressPort = ("127.0.0.1", 20001)
bufferSize = 1024
# Create a UDP socket at client side
UDPClientSocket = socket.socket(family=socket.AF_INET, type=socket.SOCK_DGRAM)
# Send to server using created UDP socket
UDPClientSocket.sendto(bytesToSend, serverAddressPort)
msgFromServer = UDPClientSocket.recvfrom(bufferSize)
msg = "Message from Server {}".format(msgFromServer[0])
print(msg