30 Ocak 2020 Perşembe

IPV6 Header

Giriş
IPV4 adresleri bitmek üzere, yüzden IPV6'ya geçmekte fayda var. Şeklen şöyledir.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class |           Flow Label                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Payload Length        |  Next Header  |   Hop Limit   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Source Address                        +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                      Destination Address                      +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Linux'ta şu satırı dahil ederiz.
#include <netinet/in.h>
#include <netinet/ip6.h>
Kod olarak şöyle. Traffic Class ve Priority aynı anlama gelir.
struct ipv6header {
  unsigned char priority:4, version:4;
  unsigned char flow[3];
  unsigned short int length;
  unsigned char nexthdr;
  unsigned char hoplimit;

  unsigned int saddr[4];
  unsigned int daddr[4];
};
IPV6 şöyle düşünülebilir. 8 byte kontrol bilgisi + 32 byte adres bilgisi. Yani toplam 40 byte. Kontrol bilgisi uzunluğu IPV4'e göre bayağı kısaltılmış durumda. IPV6 ile NAT gerekmiyor. Bir arayüze birden fazla IPV6 adresi atanabilir. Dahili kullanım için olan - yani Internete baglanmayan - adreslere Unique Local Address (ULA) deniliyor. ULA adres bloğunun ilk yarısı rezerve edilmiş durumda. Diğer yarısı ise isteyen herkes tarafından kullanılabilir. ULA prefix'inden sonra gelen 40 bit rastgele seçilir ve bir adres yaratılır.

Tasarım Komitesi
IPv6 tasarım komitesindeki ünlü isimlerden birisi de Tanenbaum. Kitabındaki bir açıklama şöyle.
One of the members of the committee designing ipv6, Andrew S Tanenbaum, wrote many about their decision processes and considerations in his book "Computer Networks". The for us important part is in the chapter 5.6.3:

1. Interplanetary communication is not even mentioned. Not even indirectly.
2.Nothing is mentioned what is a real problem of the current ipv4 system, not even indirectly.
3.Their "standard" "solved" a lot of problems (for example, the so-named "exhausting of the ipv4 address space"), which were solved long ago, without them.
4.On a "language of flowers", one can read upon the text, that this committee was very far from thinking even into the short future, and Tanenbaum, indirectly, admits it.
MTU
Açıklaması şöyle.
On the Internet the requirement is just a minimum link MTU of 68 bytes for IPv4 and 1280 bytes for IPv6. 
IPV4 ve IPV6 FARKI
- IPV4 is 32 bit ip address. IPV6 is 128 bit ip address
- IPV4 is numeric addressing method. IPV6 is alphanumeric addressing method
- IPV4 binary bits are separated by a dot. IPV6 binary bits are separated by a colon
- IPV4 offers 12 header fields. IPV6 offers 8 header fields
- IPV4 supports broadcast. IPV6 does not support broadcast
- IPV4 has checksum fields. IPV6 does not have checksum fields
- IPV4 supports VLSM (virtual length subnet mask). IPV6 does not support VLSM
- IPV4 uses ARP to map to MAC address. IPV6 uses NDP to map to MAC address

IPV4 Header ve IPV6 Header Farkı

Checksum Neden Artık Yok?
Açıklaması şöyle. Amaç paket yönlendirmeyi hızlandırmak. Zaten diğer katmanlardaki protokoller checksum işlevini de yerine getiriyor deniliyor.
One of the ideas around IPv6 was to speed up packet forwarding. To that end, several decisions were made. For example, the IPv6 header was greatly simplified and is a fixed length, unlike the variable length IPv4 header. Also, you cannot fragment IPv6 packets along the path, the way you can for IPv4, because packet fragmentation is resource intensive.

Not having a checksum in the IPv6 header means that an IPv6 router does not need to recalculate the checksum to see if the packet header is corrupt, and recalculate the checksum after decrementing the hop count. That saves processing time and speeds up the packet forwarding. The logic is that the layer-2 and layer-4 protocols each already have a checksum. The layer-2 checksum covers the entire IPv6 packet, and the layer-4 checksum covers the transport datagram.

Where UDP has an optional checksum for IPv4, it is required for IPv6.
1. Version Alanı
Şöyle yaparız.
ip->version = 6;

2. Traffic Class Alanı
Açıklaması şöyle
8-bits, the most significant 6 bits are Type of Service and the remaining 2 are used for Explicit Congestion Notification (ECN).
Şöyle yaparız.
ip->priority = 0;
3. Flow Label Alanı
Açıklaması şöyle
Used to maintain the sequential flow of the packets belonging to a communication. The source labels the sequence to help the router identify that a particular packet belongs to a specific flow of information. This field helps avoid re-ordering of data packets. It is designed for streaming/real-time media.
Şöyle yaparız.
(ip->flow)[0] = 0;
(ip->flow)[1] = 0;
(ip->flow)[2] = 0;
4. Payload Length Alanı
Açıklaması şöyle
Payload is composed of Extension Headers and Upper Layer data.
ICMPv6 gönderdiğimizi varsayarsak şöyle yaparız.

ip->length = ((unsigned short int) sizeof(struct icmpv6header));
5. Next Header Alanı
IPV4'teki Protocol alanı ile aynıdır. Açıklaması şöyle
Indicates either the type of Extension Header, or if the Extension Header is not present then it indicates the Upper Layer.
Açıklaması şöyle
You can check the IPv4 "Protocol" field, or the IPv6 "Next Header" field to determine the payload of the IP packets.
ICMPv6 gönderdiğimizi varsayarsak şöyle yaparız.
ip->nexthdr = 58;
6.  Hop Limit Alanı
Açıklaması şöyle
This is the same as TTL on IPv4.
Açıklaması şöyle
Hop Limit
8-bit unsigned integer. Decremented by 1 by each node that forwards the packet. The packet is discarded if Hop Limit is decremented to zero.
Açıklaması şöyle
8.2 Maximum Packet Lifetime
Unlike IPv4, IPv6 nodes are not required to enforce maximum packet lifetime. That is the reason the IPv4 "Time to Live" field was renamed "Hop Limit" in IPv6. In practice, very few, if any, IPv4 implementations conform to the requirement that they limit packet lifetime, so this is not a change in practice. Any upper-layer protocol that relies on the internet layer (whether IPv4 or IPv6) to limit packet lifetime ought to be upgraded to provide its own mechanisms for detecting and discarding obsolete packets.
Şöyle yaparız.
ip->hoplimit = 255;
7. Source Address Alanı (128-bits)
Açıklaması şöyle
Private IPv6 addresses allow you to design your network in such a way that some entirely local services simply can't communicate with the outside world.
IPv6 ile bir ağ arayüzüne birden fazla adres atanabiliyor. IPv4 ile bu yapılamıyordu. Şöyledir.
interface te 0/1/0/10
 ipv6 enable
 ipv6 address 24**:x:x:x:0:x:x:x/127
 ipv6 address 24**:x:x:x:1:x:x:x/127
end
IPV6 Adres Çeşitleri yazısına bakabilirsiniz.

8. Destination Address Alanı (128-bits)
Açıklama yaz

Hiç yorum yok:

Yorum Gönder