Sunday 24 May 2015

'Main program
pertanyaanawal()
ipprefixdetektor()
maskdetektor()
interestingoctet()
analyzing()

Sub pertanyaanawal
  TextWindow.WriteLine("1. Please enter the IP address group :")
  d = TextWindow.Read()
  TextWindow.WriteLine("")
  TextWindow.WriteLine("2. Please enter the slash (/). Can be number between 0 to 32 : ")
  s = TextWindow.Read()
EndSub

Sub ipprefixdetektor
'Memproses / mengolah prefix IP. Output sub : variabel f,g,h,i, input : variabel d
'1.1 Mengambil satu karakter persatu karakter dari IP prefix (termasuk tanda titik)
For i=0 To Text.GetLength(d)
  c[i] = text.GetSubText(d,i,1)
EndFor

'1.2 menandai posisi titik IP prefix dengan cara mengambil posisinya
j = 0
'untuk i = 0 hingga jumlah dari array c (jumlah angka IP prefix kan berubah-ubah)
For i = 0 To Array.GetItemCount(c)
  'TextWindow.WriteLine(c[i])
  If c[i] = "." Then
    e[j]=i
    'TextWindow.WriteLine(e[j])
    j = j + 1
  EndIf
EndFor

'menyimpan kedalam variabel f, g, h, dan i angka-angka yang dibatasi letak/posisi titik (e[0],...)
oct[0] = Text.GetSubText(d,1,e[0]-1)
oct[1] = Text.GetSubText(d,e[0]+1,e[1]-e[0]-1)
oct[2] = Text.GetSubText(d,e[1]+1,e[2]-e[1]-1)
oct[3] = Text.GetSubTextToEnd(d,e[2]+1)
EndSub

Sub maskdetektor
floor_s = Math.Floor(s/8)
i = 0

if floor_s <> 0 Then
For i = 0 To floor_s - 1
  mask[i] = 255
EndFor
EndIf

sisa_s = Math.Remainder(s,8)
kurang_8 = 8 - sisa_s
powkurang_8 = Math.Power(2,kurang_8)
nil = 256 - powkurang_8
mask[i] = nil

i = i + 1

loop = 4 - i

If loop <> 0 then
For j = 0 To loop
  mask[i] = 0
  i = i + 1
EndFor
EndIf

EndSub

Sub analyzing
  If f >= 128 And f <= 191 Then
  TextWindow.WriteLine("You entering a class B address. A class B address is 1st octet started from 128 to 191. ")
  defmask = 16
EndIf

If f >= 192 And f <= 223 Then
  TextWindow.WriteLine("You entering a class C address. A class C address is 1st octet started from 192 to 223. ")
  defmask = 24
EndIf

If f >= 224 And f <= 239 Then
  TextWindow.WriteLine("You entering a class D address")
  TextWindow.WriteLine("This block is dedicated to Multicasting and Newsgroup.")
EndIf

If f >= 240 And f <= 255 Then
  TextWindow.WriteLine("You entering a class E address.")
  TextWindow.WriteLine("This block is dedicated to Research and Development.") 
EndIf

If f > 255 Then
  TextWindow.WriteLine("You enter wrong an IP address ")
EndIf

expandbit = s - defmask
blocksize = Math.Power(expandbit, 2)

If f / blocksize <> 0 Then
  host_id =
 
EndIf


TextWindow.WriteLine("Interesting octet : octet" + intoct)
EndSub

If s > defmask Then
  'your are subnetting
  'your host id is
  'your subnet id is
  'you are subnet number ...
  'there are .... subnets in this group
EndIf
If s = defmask Then
EndIf
If s < defmask Then
EndIf

Sub interestingoctet
If s > 25 then
  intoct = 3
  'interesting octetnya octet keempat
ElseIf s >= 16  and s < 24 then 
  intoct = 2
  'interesting octetnya octet ketiga
elseif s >= 8 and s < 16 then
  intoct = 1
  'interesting octetnya octet kedua
elseif s >= 0 and s < 8 then
  intoct = 0
  'interestin octetnya octet pertama
Else
  TextWindow.WriteLine("error")
EndIf
EndSub


No comments:

Post a Comment