Yuav Muab Txhais Chaw Nyob Ip Li Cas

Cov txheej txheem:

Yuav Muab Txhais Chaw Nyob Ip Li Cas
Yuav Muab Txhais Chaw Nyob Ip Li Cas

Video: Yuav Muab Txhais Chaw Nyob Ip Li Cas

Video: Yuav Muab Txhais Chaw Nyob Ip Li Cas
Video: Qhia saib yus tus hluas nkauj qhov chaw nyob 2024, Plaub Hlis Ntuj
Anonim

Qhov chaw nyob IP muaj plaub tus lej zauv, txhua tus tuaj yeem yog txij 0 txog 255. Txhua tus lej zoo ib yam li ob tus lej hexadecimal lossis yim-binary, thiab yog li ntawd hu ua octet. Cov plaub luv luv no qee zaum yuav tsum tau muab txhais ua ib qho ntev thaum sau cov lus sau.

Yuav muab txhais chaw nyob ip li cas
Yuav muab txhais chaw nyob ip li cas

Cov Lus Qhia

Kauj ruam 1

Tshaj tawm thawj octet ntawm tus IP chaw nyob los ntawm 16777216, los yog, sib npaug, 256 rau lub zog thib peb. Piv txwv li, yog tias peb tab tom tham txog IP chaw nyob 192.168.1.1 (nws yog feem ntau pom nyob hauv cov koom tes hauv zos me), tom qab ntawd tom qab muab tus naj npawb 192 los ntawm 16777216 koj tau 3221225472.

Kauj ruam 2

Tshaj tawm tus lej thib ob ntawm 65536 - qhov ntawd yog qhov koj yuav tau ntau npaum li cas yog tias koj nce 256 rau lub zog thib ob. Piv txwv, qhov chaw nyob 192.168.1.1, koj yuav tsum khoo 168 ntawm 65536, thiab koj tau txais 11010048.

Kauj ruam 3

Tshaj tawm tus thib peb octet los ntawm 256 rau thawj lub zog - uas yog, los ntawm tus xov tooj 256 nws tus kheej. Yog koj hloov IP chaw nyob 192.168.1.1 rau daim ntawv ntev, ces qhov txiaj ntsig ntawm qhov sib npaug yuav yog 256 * 1 = 256.

Kauj ruam 4

Cia tus xov tooj plaub tsis hloov, uas yog sib npaug rau sib npaug ntawm ib tus. Qhov no yog vim qhov tseeb tias yog tias koj nce tus lej 256 (lossis lwm tus lej) mus rau lub zog xoom, koj tau txais 1. Hauv IP chaw nyob 192.168.1.1, qhov tshwm sim ntawm cov sib npaug yuav yog 1 * 1 = 1.

Kauj ruam 5

Ntxiv tag nrho plaub tus lej sib tshooj ua ke. Rau qhov piv txwv tau xav txog ntawm no, tus nqi yuav zoo li no: 3232235777.

Kauj Ruam 6

Thaum sau cuv npe hauv PHP, siv qhov haujlwm tau npaj ua ip2 ntev los txhais qhov chaw nyob IP ua daim ntawv ntev. Lub luag haujlwm zoo sib xws hauv lub hom phiaj tuaj yeem tsim thiab suav nrog qhov program lossis lwm qhov qauv hauv lwm cov lus programming.

Kauj Ruam 7

Kev ua haujlwm txhais cov IP chaw nyob ntawm daim ntawv ntev ntev los ua luv luv tau tshwm sim ntau tsawg. Txhawm rau ua qhov no, faib qhov chaw nyob ntev los ntawm 16777216, thiab tag nrho ib feem ntawm qhov kev faib tawm tau los ua tus thawj octet. Sib faib cov seem (tsis txhob cuam tshuam nrog qhov feem me me) los ntawm 65536 kom tau txais qhov thib ob octet, thiab lwm yam. Ntawm kev siv lub tshuab ua lej, laij cov qauv raws li hauv qab no: [C] thawj tus lej [MOD] tus lej thib ob [=]. Cov laij lej yooj yim tsis muaj cov yam ntxwv no.

Kauj ruam 8

Thaum sau ib txoj haujlwm rau ua qhov kev hloov txhais lus ntawm cov lus programming tshwj xeeb, siv cov haujlwm rau cov lej sib faib thiab suav cov feem seem. Piv txwv li, hauv Pascal lawv yog hu ua div thiab mod, ntsig txog. Ib thooj ntawm cov kev pabcuam rau kev nqa tawm cov ntawv txhais lus yuav zoo li no:

Octet [1]: = longip div 16777216;

nextnumber: = ntev so mod 16777216;

Octet [2]: = txuas ntxiv tooj div 65536;

nextnumber: = txuas ntxiv qub mod 65536;

Octet [3]: = txuas ntxiv tooj div 256;

Lub kaum hli ntuj [4]: = nextnumber mod 256;

Pom zoo: