Cyclic Redundancy Check Generates Different Values for MessageHow can I check for NaN values?Difference between Python's Generators and IteratorsPyAudio Over Network crashesFastest way to check if a value exist in a listMalformed Packet on ICMP pythonWhat is redundant in a Cyclic Redundancy Check (CRC)?Cyclic Redundancy Check How To?cyclic redundancy check in DLLCyclic Redundancy Check - Message starting with 0client-server python and file opening error

What defenses are there against being summoned by the Gate spell?

What is the command to reset a PC without deleting any files

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

Is there a familial term for apples and pears?

How old can references or sources in a thesis be?

Accidentally leaked the solution to an assignment, what to do now? (I'm the prof)

Schwarzchild Radius of the Universe

Motorized valve interfering with button?

Why doesn't Newton's third law mean a person bounces back to where they started when they hit the ground?

If Manufacturer spice model and Datasheet give different values which should I use?

declaring a variable twice in IIFE

Can a German sentence have two subjects?

How do we improve the relationship with a client software team that performs poorly and is becoming less collaborative?

How to make payment on the internet without leaving a money trail?

Extreme, but not acceptable situation and I can't start the work tomorrow morning

What is the offset in a seaplane's hull?

whey we use polarized capacitor?

Is Social Media Science Fiction?

How can bays and straits be determined in a procedurally generated map?

The magic money tree problem

A newer friend of my brother's gave him a load of baseball cards that are supposedly extremely valuable. Is this a scam?

Do airline pilots ever risk not hearing communication directed to them specifically, from traffic controllers?

How to add power-LED to my small amplifier?

Why was the small council so happy for Tyrion to become the Master of Coin?



Cyclic Redundancy Check Generates Different Values for Message


How can I check for NaN values?Difference between Python's Generators and IteratorsPyAudio Over Network crashesFastest way to check if a value exist in a listMalformed Packet on ICMP pythonWhat is redundant in a Cyclic Redundancy Check (CRC)?Cyclic Redundancy Check How To?cyclic redundancy check in DLLCyclic Redundancy Check - Message starting with 0client-server python and file opening error






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








-1















For the 3 codes, I need to achieve the following:



  • 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.

The code is nearly complete, but the CRC's are completely different, and they never equal one another. When comparing the CRC from message one to the second CRC, they are never equal.



Part A:



import socket
import struct
import sys
import binascii

def crc32(v):
r = binascii.crc32(v.encode())
return r


if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <ip> <liseten port>")
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("!50sL",text.encode(),crc32(text))
s.sendto(ss,(sys.argv[1],int(sys.argv[2])))
if text == "bye":
break


Part B:



import socket
import operator
import sys
import binascii
import struct
import random

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8").replace("","")
if random.randint(0,100) < 40:
str = str + "x"
print("str:%sncrc:%X" % (str,crc & 0xffffffff))
str2 = str.encode("utf-8")
tpack = struct.pack("!50sL", str2, crc)
s.sendto(tpack,("127.0.0.1",int(sys.argv[2])))

if str == "bye":
break


Part C:



import socket
import operator
import sys
import binascii
import struct

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 2:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8")
print("str:%sncrc:%X" % (str,crc & 0xffffffff))

ncrc = crc32(str)
if crc == ncrc:
print ("CRC's are equal.")
if str == "bye":
break









share|improve this question
























  • In Part C, you need to recalculate the checksum of the received string and compare it to the received checksum. Also, the probability in Part B is only 35.6%.

    – Eric
    Mar 8 at 6:16











  • I fixed that and tried the checksum, but for some reason I keep getting errors when I try and implement the 40% chance and alter the message, can't seem to send that altered message.

    – godspeedd
    Mar 8 at 7:07











  • Define 'cross redundancy check'. Do you mean 'cyclic redundancy check'?

    – user207421
    Mar 8 at 9:10











  • Yeah, that is what I meant.

    – godspeedd
    Mar 8 at 18:09

















-1















For the 3 codes, I need to achieve the following:



  • 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.

The code is nearly complete, but the CRC's are completely different, and they never equal one another. When comparing the CRC from message one to the second CRC, they are never equal.



Part A:



import socket
import struct
import sys
import binascii

def crc32(v):
r = binascii.crc32(v.encode())
return r


if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <ip> <liseten port>")
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("!50sL",text.encode(),crc32(text))
s.sendto(ss,(sys.argv[1],int(sys.argv[2])))
if text == "bye":
break


Part B:



import socket
import operator
import sys
import binascii
import struct
import random

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8").replace("","")
if random.randint(0,100) < 40:
str = str + "x"
print("str:%sncrc:%X" % (str,crc & 0xffffffff))
str2 = str.encode("utf-8")
tpack = struct.pack("!50sL", str2, crc)
s.sendto(tpack,("127.0.0.1",int(sys.argv[2])))

if str == "bye":
break


Part C:



import socket
import operator
import sys
import binascii
import struct

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 2:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8")
print("str:%sncrc:%X" % (str,crc & 0xffffffff))

ncrc = crc32(str)
if crc == ncrc:
print ("CRC's are equal.")
if str == "bye":
break









share|improve this question
























  • In Part C, you need to recalculate the checksum of the received string and compare it to the received checksum. Also, the probability in Part B is only 35.6%.

    – Eric
    Mar 8 at 6:16











  • I fixed that and tried the checksum, but for some reason I keep getting errors when I try and implement the 40% chance and alter the message, can't seem to send that altered message.

    – godspeedd
    Mar 8 at 7:07











  • Define 'cross redundancy check'. Do you mean 'cyclic redundancy check'?

    – user207421
    Mar 8 at 9:10











  • Yeah, that is what I meant.

    – godspeedd
    Mar 8 at 18:09













-1












-1








-1








For the 3 codes, I need to achieve the following:



  • 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.

The code is nearly complete, but the CRC's are completely different, and they never equal one another. When comparing the CRC from message one to the second CRC, they are never equal.



Part A:



import socket
import struct
import sys
import binascii

def crc32(v):
r = binascii.crc32(v.encode())
return r


if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <ip> <liseten port>")
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("!50sL",text.encode(),crc32(text))
s.sendto(ss,(sys.argv[1],int(sys.argv[2])))
if text == "bye":
break


Part B:



import socket
import operator
import sys
import binascii
import struct
import random

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8").replace("","")
if random.randint(0,100) < 40:
str = str + "x"
print("str:%sncrc:%X" % (str,crc & 0xffffffff))
str2 = str.encode("utf-8")
tpack = struct.pack("!50sL", str2, crc)
s.sendto(tpack,("127.0.0.1",int(sys.argv[2])))

if str == "bye":
break


Part C:



import socket
import operator
import sys
import binascii
import struct

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 2:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8")
print("str:%sncrc:%X" % (str,crc & 0xffffffff))

ncrc = crc32(str)
if crc == ncrc:
print ("CRC's are equal.")
if str == "bye":
break









share|improve this question
















For the 3 codes, I need to achieve the following:



  • 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.

The code is nearly complete, but the CRC's are completely different, and they never equal one another. When comparing the CRC from message one to the second CRC, they are never equal.



Part A:



import socket
import struct
import sys
import binascii

def crc32(v):
r = binascii.crc32(v.encode())
return r


if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <ip> <liseten port>")
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("!50sL",text.encode(),crc32(text))
s.sendto(ss,(sys.argv[1],int(sys.argv[2])))
if text == "bye":
break


Part B:



import socket
import operator
import sys
import binascii
import struct
import random

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 3:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8").replace("","")
if random.randint(0,100) < 40:
str = str + "x"
print("str:%sncrc:%X" % (str,crc & 0xffffffff))
str2 = str.encode("utf-8")
tpack = struct.pack("!50sL", str2, crc)
s.sendto(tpack,("127.0.0.1",int(sys.argv[2])))

if str == "bye":
break


Part C:



import socket
import operator
import sys
import binascii
import struct

def crc32(v):
return binascii.crc32(v.encode())

if len(sys.argv) != 2:
print("Useage: python " + sys.argv[0] + " <liseten port>")
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("!50sL",data)
str = str.decode("utf-8")
print("str:%sncrc:%X" % (str,crc & 0xffffffff))

ncrc = crc32(str)
if crc == ncrc:
print ("CRC's are equal.")
if str == "bye":
break






python sockets udp crc udpclient






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 8 at 18:09







godspeedd

















asked Mar 8 at 5:58









godspeeddgodspeedd

11




11












  • In Part C, you need to recalculate the checksum of the received string and compare it to the received checksum. Also, the probability in Part B is only 35.6%.

    – Eric
    Mar 8 at 6:16











  • I fixed that and tried the checksum, but for some reason I keep getting errors when I try and implement the 40% chance and alter the message, can't seem to send that altered message.

    – godspeedd
    Mar 8 at 7:07











  • Define 'cross redundancy check'. Do you mean 'cyclic redundancy check'?

    – user207421
    Mar 8 at 9:10











  • Yeah, that is what I meant.

    – godspeedd
    Mar 8 at 18:09

















  • In Part C, you need to recalculate the checksum of the received string and compare it to the received checksum. Also, the probability in Part B is only 35.6%.

    – Eric
    Mar 8 at 6:16











  • I fixed that and tried the checksum, but for some reason I keep getting errors when I try and implement the 40% chance and alter the message, can't seem to send that altered message.

    – godspeedd
    Mar 8 at 7:07











  • Define 'cross redundancy check'. Do you mean 'cyclic redundancy check'?

    – user207421
    Mar 8 at 9:10











  • Yeah, that is what I meant.

    – godspeedd
    Mar 8 at 18:09
















In Part C, you need to recalculate the checksum of the received string and compare it to the received checksum. Also, the probability in Part B is only 35.6%.

– Eric
Mar 8 at 6:16





In Part C, you need to recalculate the checksum of the received string and compare it to the received checksum. Also, the probability in Part B is only 35.6%.

– Eric
Mar 8 at 6:16













I fixed that and tried the checksum, but for some reason I keep getting errors when I try and implement the 40% chance and alter the message, can't seem to send that altered message.

– godspeedd
Mar 8 at 7:07





I fixed that and tried the checksum, but for some reason I keep getting errors when I try and implement the 40% chance and alter the message, can't seem to send that altered message.

– godspeedd
Mar 8 at 7:07













Define 'cross redundancy check'. Do you mean 'cyclic redundancy check'?

– user207421
Mar 8 at 9:10





Define 'cross redundancy check'. Do you mean 'cyclic redundancy check'?

– user207421
Mar 8 at 9:10













Yeah, that is what I meant.

– godspeedd
Mar 8 at 18:09





Yeah, that is what I meant.

– godspeedd
Mar 8 at 18:09












0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057511%2fcyclic-redundancy-check-generates-different-values-for-message%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55057511%2fcyclic-redundancy-check-generates-different-values-for-message%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

1928 у кіно

Захаров Федір Захарович

Ель Греко