Masih pusing dengan cara menghitungnya.? Sobat bisa juga menggunakan cara yang instan untuk menghitung subnetting suatu jaringan yaitu menggunakan software bernama advance subnet calculator dari solarwind, tools gratis ini sangat akurat dalam penghitungan subnet yang sobat cari sobat hanya perlu memasukan nilai ip address lalu tinggal menekan.
Recently I wanted to develop a wake-on-lan application for my media center.
For that I needed the broadcast address of my local LAN.
So I decided to write a small but interesting library.. (you can leverage it for all kinds of network calculations like subnets, etc..).
What it does is do a lot of funny calculations around IPv4.
- Network Address: This is the first address of each network which is reserved to identify the entire network (or subnet).
If your ip address is 192.168.2.234
and your subnetmask 255.255.255.0
then your network address is 192.168.2.0. - Broadcast Address: This is the 'send-to-all' address. If any traffic is targeted for the broadcast address it is forwarded to all of the machines in the network.
If your ip address is 192.168.2.234
and your subnetmask 255.255.255.0
then your broadcast address is 192.168.2.255.
Are you interested in the calculations behind that? Visit my other blog post.
In .NET there is a class called System.Net.IPAddress, which is used for storing IPv4 addresses. So what I did is build a bunch of extension methods for this class:
The first two calculate the Broadcast- as well as the NetworkAddress. With the help of the network address you can then calculate whether two IP addresses are in the same subnet (simply by comparing the two network addresses). If they are.. fine, communication is done directly. If not, then the default gateway (a router) is used for the communication between them.
![Cara Menghitung Ip Address Cara Menghitung Ip Address](/uploads/1/2/3/4/123444694/459790401.jpg)
These extension methods (keep in mind they’re in a static class, are static methods and have the special this (extension) parameter) extend an existing type (at least it seems so to use when using Visual Studio). Now we can call..
I’ve used the GetBroadcastAddress method in another sample to send a Wake-On-Lan packet to ALL computers on my subnet.
The subnet mask indicates how large the network is. To ease work with it I’ve also built a helper class called Subnet.
This class provides constant subnet masks for Class A-C networks as well as methods for calculating subnet masks. A subnet mask is 32-bit long which consist of the network-part as well as the host-part. The methods create subnet masks either by the number of bits in the host- or network part or by the number of hosts, which should fit into the network.
creates a subnet mask with 24-bits network part, hence a class C subnet mask.
Have a lot of fun with IP calculations and visit my post about a wake-on-lan client.
Also feel free to download the sources here.