0

If I was using @$ as my flag pattern (to signal the end of the data) what would I do if @$ was seen in the data? I would just stuff another @$ right after it in the sender and in the receiver, if I saw two consecutive @$ I would remove the second one (and not include it as part of the data) ... right? And what advantage does using these two bytes have over just using one byte such as 01111110?

Thanks.

2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by BestJewSinceJC
0

In case anyone was wondering, I emailed my TA about this (since I got no response here, which I thought would be much faster) and I received the following response:

Yes, it works as you said, but you have to check @$@$ four characters.
Another way is you use @@ to represent the real @ in the text, and if
you see a @ followed by a $, then you know it's the end of file.

I forgot to ask him what the advantage of this was, but it seems like there is no advantage to using @$ instead of just @. In any case, maybe I'm wrong, but there you have it.

0

If I was using @$ as my flag pattern (to signal the end of the data) what would I do if @$ was seen in the data? I would just stuff another @$ right after it in the sender and in the receiver, if I saw two consecutive @$ I would remove the second one (and not include it as part of the data) ... right?

Correct.

And what advantage does using these two bytes have over just using one byte such as 01111110?

Depending on what kind of data you're sending, so might need less stuffing if you use two bytes. Because the chance that the pattern of 2 bytes is in your data is a lot smaller then just 1 byte. If we assume the standard ascii-set, and you send completely random data, then 1 in 127 bytes will be your EOT-char and needs stuffing.
If you have 2 bytes then 1 in 127x127 byte-pairs will be the same as your EOT-byte-pair. So now you only need to stuff 2 bytes in each 127^2 bytes.
But because data is never random, you'll have to asses each situation before making a choice.


Another way is you use @@ to represent the real @ in the text, and if
you see a @ followed by a $, then you know it's the end of file.

I forgot to ask him what the advantage of this was, but it seems like there is no advantage to using @$ instead of just @. In any case, maybe I'm wrong, but there you have it.

This has a small advantage, because if you have a @$ in your data, you'll stuff it as @@$ instead of @$@$. The obvious downside is that you'll need a lot more stuffing if your data contains a lot of @'s.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.