Register - Login
Views: 99870150
Main - Memberlist - Active users - Calendar - Wiki - IRC Chat - Online users
Ranks - Rules/FAQ - Stats - Latest Posts - Color Chart - Smilies
05-04-22 06:51:15 PM
Jul - Computers and Technology - How to differentiate IPv4 and IPv6? New poll - New thread - New reply
Next newer thread | Next older thread
Rena
I had one (1) message in Discord deleted and proceeded to make a huge, huge mess about how it was a violation of free speech and how moderators are supposed to be spam janitors and nobody should have the right to tell me not to talk about school shootings
Level: 135


Posts: 389/5390
EXP: 29079571
For next: 255434

Since: 07-22-07

Pronouns: he/him/whatever
From: RSP Segment 6

Since last post: 343 days
Last activity: 343 days

Posted on 07-29-07 03:07:46 AM Link | Quote
JL2 - Post #389 - 07-28-07 10:07 PM
Day 6, rank 6; Level 16 (83.7%)
3241/3872 (19625/20256)
GPP: 75; GT: 57.611
If you have just the raw 16 bytes of an IP address, such as 0x7F000001 00000000 00000000 00000000, how can you tell if this is an IPv4 or IPv6 address? I'm thinking store the IPv4 addresses in the low 4 bytes and set the upper 12 to something that ends up being a reserved or invalid address in IPv6, so I know if I encounter this that it's IPv4, but I don't know what values I would use for these bytes. 0xFF maybe? ::1 (0000:0000...0000:0001) is a valid address (localhost), so I can't use zero. :-/

____________________
My Site | How this layout should look
WIP layout - todo: make Rena show up correctly in long posts
chungy
Member
Level: 31


Posts: 2/174
EXP: 168466
For next: 16897

Since: 08-04-07


Since last post: 14.1 years
Last activity: 13.9 years

Posted on 08-04-07 08:44:37 AM; last edit by chungy on 08-04-07 08:45 AM Link | Quote
IPv6 is 128-bits, IPv4 is 32-bits. iwin
Rena
I had one (1) message in Discord deleted and proceeded to make a huge, huge mess about how it was a violation of free speech and how moderators are supposed to be spam janitors and nobody should have the right to tell me not to talk about school shootings
Level: 135


Posts: 488/5390
EXP: 29079571
For next: 255434

Since: 07-22-07

Pronouns: he/him/whatever
From: RSP Segment 6

Since last post: 343 days
Last activity: 343 days

Posted on 08-04-07 04:05:49 PM Link | Quote
JL2 - Post #488 - 08-04-07 11:05 AM
Day 13, rank 7; Level 20 (48.3%)
3216/6662 (38993/42439)
GPP: 119; GT: 57.979
Originally posted by chungy
IPv6 is 128-bits, IPv4 is 32-bits. iwin

...Did you read my post? Both are going to be stored as 128-bit numbers.

____________________
Xkeeper

Level: 263


Posts: 1984/25353
EXP: 297181935
For next: 1778518

Since: 07-03-07

Pronouns: they/them/????????

Since last post: 4 days
Last activity: 7 hours

Posted on 08-04-07 05:12:08 PM Link | Quote
Daily Cycle II ~ 1984
How are you getting the information? It might be simpler to just differentiate using a different method (i.e. selecting between the two when entering an IP)...

____________________
"Xkeeper is like the can at the bottom of a supermarket display. Pulling him out is just asking for a catastrophic mess."
Stats
Level 42
EXP: 22876/41217
Time: 32 days
Ranked at #1
 

 
Rena
I had one (1) message in Discord deleted and proceeded to make a huge, huge mess about how it was a violation of free speech and how moderators are supposed to be spam janitors and nobody should have the right to tell me not to talk about school shootings
Level: 135


Posts: 491/5390
EXP: 29079571
For next: 255434

Since: 07-22-07

Pronouns: he/him/whatever
From: RSP Segment 6

Since last post: 343 days
Last activity: 343 days

Posted on 08-04-07 05:45:06 PM Link | Quote
JL2 - Post #491 - 08-04-07 12:45:06 PM
Day 13, rank 7; Level 20 (55.2%)
3679/6662 (39456/42439)
GPP: 120; GT: 57.600
From a 16-byte BINARY field in a MySQL database.

Maybe I'll just use VARBINARY, the added size for the length byte shouldn't be too bad. Few megabytes at most. :-/

____________________
chungy
Member
Level: 31


Posts: 4/174
EXP: 168466
For next: 16897

Since: 08-04-07


Since last post: 14.1 years
Last activity: 13.9 years

Posted on 08-04-07 09:42:18 PM Link | Quote
If the number is bigger than what IPv4 can possibly support then it's obviously IPv6. Other than that, you should probably be using a better method to store them so you can tell the difference (like VARBINARY as you said).
Rena
I had one (1) message in Discord deleted and proceeded to make a huge, huge mess about how it was a violation of free speech and how moderators are supposed to be spam janitors and nobody should have the right to tell me not to talk about school shootings
Level: 135


Posts: 492/5390
EXP: 29079571
For next: 255434

Since: 07-22-07

Pronouns: he/him/whatever
From: RSP Segment 6

Since last post: 343 days
Last activity: 343 days

Posted on 08-05-07 03:44:42 AM Link | Quote
JL2 - Post #492 - 08-04-07 10:44:42 PM
Day 13, rank 7; Level 20 (66.4%)
4422/6662 (40199/42439)
GPP: 122; GT: 58.326
Originally posted by chungy
If the number is bigger than what IPv4 can possibly support then it's obviously IPv6.
That's along the lines of what I was thinking, but e.g. ::7F00:0001 and 127.0.0.1 would both produce the same result.

____________________
Rena
I had one (1) message in Discord deleted and proceeded to make a huge, huge mess about how it was a violation of free speech and how moderators are supposed to be spam janitors and nobody should have the right to tell me not to talk about school shootings
Level: 135


Posts: 494/5390
EXP: 29079571
For next: 255434

Since: 07-22-07

Pronouns: he/him/whatever
From: RSP Segment 6

Since last post: 343 days
Last activity: 343 days

Posted on 08-05-07 03:56:57 AM Link | Quote
JL2 - Post #494 - 08-04-07 10:56:57 PM
Day 13, rank 7; Level 20 (70.2%)
4680/6662 (40457/42439)
GPP: 122; GT: 57.991
No, but both of them would end up being stored as 00000000 00000000 00000000 7F000001 in the database. No way to tell whether it was v4 or v6 originally.

____________________
chungy
Member
Level: 31


Posts: 8/174
EXP: 168466
For next: 16897

Since: 08-04-07


Since last post: 14.1 years
Last activity: 13.9 years

Posted on 08-05-07 04:00:27 AM Link | Quote
Heh, you read that too soon I realized what you meant
Next newer thread | Next older thread
Jul - Computers and Technology - How to differentiate IPv4 and IPv6? New poll - New thread - New reply


Rusted Logic

Acmlmboard - commit 47be4dc [2021-08-23]
©2000-2022 Acmlm, Xkeeper, Kaito Sinclaire, et al.

28 database queries, 2 query cache hits.
Query execution time: 0.084115 seconds
Script execution time: 0.022805 seconds
Total render time: 0.106920 seconds