Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Transmitted messages are divided into predetermined lengths that are divided by a fixed divi- sor. According to the calculation, the remainder number is appended onto

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Transmitted messages are divided into predetermined lengths that are divided by a fixed divi- sor. According to the calculation, the remainder number is appended onto and sent with the CISC 4615, Spring 2020 Data Communication and Networking Data CRC Data 00...O mbits Divisor Data CRC Divisor n + 1 bits Remainder CRC n bits Remainder Zero, accept Nonzero, reject Receiver Sender message. When the message is received, the receiver recalculates the remainder and compares it to the transmitted remainder. If the numbers do not match, an error is detected. In the Lab 1, we learned how to programming with sockets and TCP. In the lab 2, we will UPD as our protocol and integrate CRC into the tranmissions.Different from TCP, UDP is a connection less protocol. There is no connection is established between client and server. UDP Protocol Workflow Client Server Socket() Socket Connect with server, store server IP address and port number bind() Connect() recyfrom() sendto() request recurom request wait for datagram and process request recyfrom() - reply sendto() close() In UDP, the client does not form a connection with the server like in TCP and instead, it just sends a datagram. Similarly, the server need not to accept a connection and just waits for datagrams to arrive. We can call a function called connect() in UDP but it does not result anything like it does in TCP. There is no 3 way handshake(we will study this topic later). It just checks for any immediate errors and store the peer's IP address and port number. connect() is storing peers address so no need to pass server address and server address length arguments in apudtal Lab 1 Assignment: Part 1 and 2 Lab 1 consists of the following two parts. 1. Base on sample 1, create a "forwarder for your program as shown below. A sends a message, B receives it and forwards it to C, C receives it and print it out. They all use UDP protocol. 2. Based on sample 3, integrate CRC into your 3-node program. A sends a message to B along with the CRC32 code. B receives this message and CRC32 code. B follows a 40% probability to change the message. B sends the message along with the original CRC32 code to C. C receives the message and CRC32 code and check whether it is correct or not. After compiling the samples (C++), you can run the samples as shown below (using python2.7) Sample 1: CPP: ./server 9000(port number) and ./client 127.0.0.1 9000(port number) Python: python2.7 client.py 127.0.0.1 9000 and python server.py 9000 Sample 3: CPP: ./server 9000(port number) and ./client 127.0.0.1 9000(port number) Python: python2.7 client.py 127.0.0.1 9000 and python server.py 9000 sample 1 Server 1 2 import socket import sys m 4 if len(sys.argv) != 2: print("Useage: python " + sys.argv[0] + " ") sys.exit(-1) 8 S = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind(("0.0.0.0", int(sys.argv[1]))) print("Waiting..") while True: data, addr = s.recyfrom(1024) data = data.decode("utf-8").replace("10","") print data if data == "bye": break Sample I client 1 import socket import sys 2 5 if len(sys.argv) != 3: print("Useage: python " + sys.argv[0] + " ") sys.exit(-1) 8 S = socket.socket (socket.AF_INET, socket. SOCK_DGRAM) while True: print("Input text:") text = sys.stdin.readline().strip() s.sendto(text, (sys.argv[1],int(sys.argv[2]))) if text == "bye": break Sample 3 server 2 7 import socket import sys import binascii import struct def crc32(v): return binascii.crc32(v) if len(sys.argv) != 2: print("Useage: python " + sys.argv[O] + " ") sys.exit(-1) s = socket.socket(socket.AF_INET, socket. SOCK_DGRAM) s.bind(("0.0.0.0", int(sys.argv[1]))) print("Waiting...") while True: data, addr = s.recvfrom(1024) str,crc = struct.unpack("!50si", data) str = str.decode("utf-8").replace("\0","") print "str:%s crc:%X" % (str,crc & Oxffffffff) if data == "bye": break 11 Sample 3 client 1 import socket import struct import sys import binascii def crc32(v): return binascii.crc32(v) if len(sys.argv) != 3: print("Useage: python " + sys.argv[0] + " ") sys.exit(-1) S = socket.socket (socket.AF_INET, socket. SOCK_DGRAM) while True: print("Input text:") text = sys.stdin.readline().strip() ss = struct.pack("!50si", text, crc32(text)) s.sendto(ss, (sys.argv[1], int (sys.argv[2]))) if text == "bye": break Transmitted messages are divided into predetermined lengths that are divided by a fixed divi- sor. According to the calculation, the remainder number is appended onto and sent with the CISC 4615, Spring 2020 Data Communication and Networking Data CRC Data 00...O mbits Divisor Data CRC Divisor n + 1 bits Remainder CRC n bits Remainder Zero, accept Nonzero, reject Receiver Sender message. When the message is received, the receiver recalculates the remainder and compares it to the transmitted remainder. If the numbers do not match, an error is detected. In the Lab 1, we learned how to programming with sockets and TCP. In the lab 2, we will UPD as our protocol and integrate CRC into the tranmissions.Different from TCP, UDP is a connection less protocol. There is no connection is established between client and server. UDP Protocol Workflow Client Server Socket() Socket Connect with server, store server IP address and port number bind() Connect() recyfrom() sendto() request recurom request wait for datagram and process request recyfrom() - reply sendto() close() In UDP, the client does not form a connection with the server like in TCP and instead, it just sends a datagram. Similarly, the server need not to accept a connection and just waits for datagrams to arrive. We can call a function called connect() in UDP but it does not result anything like it does in TCP. There is no 3 way handshake(we will study this topic later). It just checks for any immediate errors and store the peer's IP address and port number. connect() is storing peers address so no need to pass server address and server address length arguments in apudtal Lab 1 Assignment: Part 1 and 2 Lab 1 consists of the following two parts. 1. Base on sample 1, create a "forwarder for your program as shown below. A sends a message, B receives it and forwards it to C, C receives it and print it out. They all use UDP protocol. 2. Based on sample 3, integrate CRC into your 3-node program. A sends a message to B along with the CRC32 code. B receives this message and CRC32 code. B follows a 40% probability to change the message. B sends the message along with the original CRC32 code to C. C receives the message and CRC32 code and check whether it is correct or not. After compiling the samples (C++), you can run the samples as shown below (using python2.7) Sample 1: CPP: ./server 9000(port number) and ./client 127.0.0.1 9000(port number) Python: python2.7 client.py 127.0.0.1 9000 and python server.py 9000 Sample 3: CPP: ./server 9000(port number) and ./client 127.0.0.1 9000(port number) Python: python2.7 client.py 127.0.0.1 9000 and python server.py 9000 sample 1 Server 1 2 import socket import sys m 4 if len(sys.argv) != 2: print("Useage: python " + sys.argv[0] + " ") sys.exit(-1) 8 S = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.bind(("0.0.0.0", int(sys.argv[1]))) print("Waiting..") while True: data, addr = s.recyfrom(1024) data = data.decode("utf-8").replace("10","") print data if data == "bye": break Sample I client 1 import socket import sys 2 5 if len(sys.argv) != 3: print("Useage: python " + sys.argv[0] + " ") sys.exit(-1) 8 S = socket.socket (socket.AF_INET, socket. SOCK_DGRAM) while True: print("Input text:") text = sys.stdin.readline().strip() s.sendto(text, (sys.argv[1],int(sys.argv[2]))) if text == "bye": break Sample 3 server 2 7 import socket import sys import binascii import struct def crc32(v): return binascii.crc32(v) if len(sys.argv) != 2: print("Useage: python " + sys.argv[O] + " ") sys.exit(-1) s = socket.socket(socket.AF_INET, socket. SOCK_DGRAM) s.bind(("0.0.0.0", int(sys.argv[1]))) print("Waiting...") while True: data, addr = s.recvfrom(1024) str,crc = struct.unpack("!50si", data) str = str.decode("utf-8").replace("\0","") print "str:%s crc:%X" % (str,crc & Oxffffffff) if data == "bye": break 11 Sample 3 client 1 import socket import struct import sys import binascii def crc32(v): return binascii.crc32(v) if len(sys.argv) != 3: print("Useage: python " + sys.argv[0] + " ") sys.exit(-1) S = socket.socket (socket.AF_INET, socket. SOCK_DGRAM) while True: print("Input text:") text = sys.stdin.readline().strip() ss = struct.pack("!50si", text, crc32(text)) s.sendto(ss, (sys.argv[1], int (sys.argv[2]))) if text == "bye": break

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions