29 Nisan 2021 Perşembe

Yazılım Mimarisi - Cache

Giriş

Cache işlemi okumayı hızlandırır. Açıklaması şöyle
Caching is one of the two ways(the other is replication) to scale read heavy applications. 
Ancak kendi içinde de bazı problemler getirir. 

Yazılım Mimarisi - Replica ölçeklemek için kullanılan diğer yöntem olan replication konusunu ele alıyor

1. Race condition between delete and set
Önce veri tabanında değişiklik yapıp, daha sonra cache sistemde silme yaparsak bu problem olabiliyor. Açıklaması şöyle.
1. B got a cache miss and queried DB to get V0
2. A updated DB value from V0 to V1
3. A sent delete to cache, which was an no-op
4. B filled cache with V0

28 Nisan 2021 Çarşamba

National Maritime Electronics Association - NMEA SpeedLog Mesajları

Giriş
Açıklaması şöyle
This bridge equipment on a ship is used to measure the speed and the distance travelled by a ship from a set point. By calculating the same, ETA of the ship is adjusted or given to the port authority and agent.
Bu cihazın panelinde göstermek için şu mesajlarla beslenebilir.

GGA - Global Positioning System Fix Data, yani konum
VTG - Track made good and Ground speed, yani hız
ZDA - Time & Date - UTC, day, month, year and local time zone, yani takvim ve saat

1. MTW - Mean Temperature of Water
Celsius biriminden suyun sıcaklığını verir

 2. VBW - Dual Ground/Water Speed - Ground ve Suya Göre Hız
İki farklı hızı gösterir. Açıklaması şöyle
Longitudinal water speed, "-" means astern
Transverse water speed, "-" means port
Data Valid

Longitudinal ground speed, "-" means astern
Transverse ground speed, "-" means port
Data Valid
Açıklaması şöyle
- Speed over ground is the speed of the ship with respect to the ground or any other fixed object such as fixed buoy or island.
- Speed through water is the speed of the ship with respect to the water such as anything floating on water.
Speed over ground bir noktadan bir diğer noktaya varış süresi için hesaplanır. 
Speed through water ise "collision avoidance" için kullanılır.

Ground'a göre hız aynı zamanda GPS cihazının "VTG - Vector track an Speed over the Ground" mesajı ile de alınabilir. Ancak GPS her zaman her yer erişilebilir olmadığı için öncelikle VBW tercih edilmelidir.

Speed through water ölçümü zor bir iştir. Açıklaması şöyle
Measuring speed through water can be done using a speed log, which calculates the speed from a sensor mounted on the hull underwater, but it is not straightforward. There are a lot of variables to be considered. 

One of the most challenging issues is that the vessel itself creates a flow field around the hull. If speed through water is measured within this field, you can end up measuring the wrong speed. This field will vary dynamically with changes in vessel, speed, draft and trim.

A moving vessel also experiences pitch and roll – another factor that affects the readings. On top of this, flow patterns in the boundary layer around the hull created by the vessel’s movements need to be distinguished from ocean currents to ensure accurate speed measurement.

Speed logs – especially widely used electromagnetic (EM) logs – often have poor reliability and become less accurate over time. They are also difficult to recalibrate, and often provide poor data quality, logging and data transfer.

Adjusting log data to compensate for the resulting errors is both time-consuming and complex, using valuable resources that the industry could better employ elsewhere.  

3. VHW - Water speed and heading - Suya Göre Bağıl Hız
Açıklaması şöyle
degrees true
T=true
degrees Magnetic
M = Magnetic
Speed of vessel relative to water Knots/hour
N = Knots
Speed of vessel relative to waterKm/hour
K = Kilometers
4. VLW - Distance Traveled through Water
Aynı arabalardaki gibi bir yolculuğun mesafesini ölçer.

26 Nisan 2021 Pazartesi

National Maritime Electronics Association - NMEA GPS Mesajları

Giriş
Soru şöyle
Q : How can the GPS position update rate be 10 Hz?

Based on stuff on the web (Wikipedia and others) the GPS navigation message bit rate is 50 bit/s. That includes all data needed for user position calculation (time, ephemeris, almanac, etc.) It seems that the packet from a satellite should be much longer than 50 bits, so a complete packet must take longer than one second to completely broadcast (with a 50 bit/s rate.)

How is a 10 Hz position update rate (update each 100 milliseconds) possible?

A: 50 bps is indeed the bitrate at which the almanacs and ephemerides are transmitted. Given the size of this data as well as framing and other overhead, it takes far more than 0.1 seconds (and more than 1 sec) to transmit this data.

However, the actual position calculation is done using precise timing information derived from the PRN, and that's coming in at the chip rate (1.023 Mchip/second for L1 coarse acquisition (C/A) code), rather than at the 50 bps nav rate.

The PRN repeats once every millisecond (for L1 C/A) so even the most crude cross-correlation with the PRN could produce a new (noisy) timing measurement at 1 kHz. A lower rate like 10 Hz allows more time for measurement, filtering, and calculation (see analysis here)

A new set of ephemerides is not needed for each position update; in fact a single ephemeris is valid for hours [ref here as well as pg.157 of here]. The GPS receiver continues making calculations with respect to the existing ephemeris, just using new timing information as it comes in.
Soru şöyle. Burada önemli nokta three-spheres çözümü . Yani 3 tane uyduyu kullanarak konumu hesaplar.
Q : Why does GPS need the fourth satellite?
...
I understand that the GPS receiver knows its location by calculating its distances from 3 satellites, and by eliminating one of the two points of the intersection of the 3 spheres.

A : Your GPS cannot directly determine the distance from any satellite, it has to go indirectly. It gets a signal from the first satellite, say "it was exactly 10:30:25.123456789 seconds according to my extremely precise clock when this signal was sent", and it gets a signal from the second satellite, say "it was exactly 10:30:25.123556789 seconds according to my extremely precise clock when this signal was sent". The clocks are 0.0001 seconds apart. So the signal from the first satellite travelled 0.0001 seconds longer. At 299,792,458 meter/sec, that is 29,979.2458 meters difference. So you are 29,979 meters closer to the second satellite than to the first. And your GPS also knows the exact location of the satellites.

With the third satellite, you also learn how much closer or further away you are to the third satellite compared to the first and the second. You can turn that into three rather complicated equations, and try to solve those equations, but there is not just one solution: There is a whole curve of solutions.
Devamı şöyle. Yani 4. uydu ile çözüm sayısı azaltılıyor.
Now if three satellites is all you've got, your GPS can make a guess:
...
With a fourth satellite, there are four ways to take three satellites and calculate the curve where you should be, so you get four curves. And then the GPS picks the point that it is closest to all four curves. That gives you your location quite precisely, and at the same time, if the curves don't meet exactly in one point but are maybe ten meters apart, then you also know the precision of your location.
Modulasyon ile ilgili bir soru şöyle
The signal from GPS satellites is very faint - each satellite has to broadcast a signal to about half the planet, powered only by some solar panels! So the broadcast signal is modulated using a 'Gold Code' (in the case of the oldest public GPS signal) where part of the signal transmitted by the satellite is already known by the receiver - the GPS receiver can pick out the signal despite how faint it is, by tracking the cross-correlation between the received and expected signals.

This also means multiple satellites can transmit their signals at the same frequency - so long as they use different gold codes, the receiver can track both signals independently.

Newer GNSS signals replace gold codes with newer techniques - like 'multiplexed binary offset carriers' - which perform better, but do basically the same thing.

GPS cihazını normalde başka bir şeyle beslemek gerekmez. Bazı deniz sistemlerinde
Echo Sounder'dan gelen 
 DBT : Depth Below Transducer
 DPT : Depth of Water

GyroCompass'tan gelen
 HDT : Heading True

Speed Log'dan gelen
  VHW :  Water Speed and Heading - Suya Göre Bağıl Hız

ile besleniyor

GPS cihazlarından çok çeşitli mesajlar gelebiliyor. Bazı mesajlar şöyle. Ben konum için hep GGA kullandım
1. GGA - Konum
2. GLL - Konum
3. RMC - Konum 
4. GNS- Konum - Combined Navigation System (GPS, GLONASS) kullanarak konum
GPS kalitesi hakkında bazı mesajlar şöyle
1. GST - İstatistiki Bilgi
2. GSA - Uydu Sayısı
Diğer mesajlar şöyle
1. GSV - Pseudo Range Error Statistics yani İstatistiki Bilgi
2. VTG - Hız
3. ZDA - Saat ve Takvim
Bazı GPS cihazları sadece alıcı değil. Gidilen yerleri de kaydediyor ve USB ile cihaza bağlanınca, Internet/WIFI/Mobil bağlantı üzerinden merkeze aktarabiliyor.

1. GGA - Global Positioning System Fix Data - Konum
Bu cümleler arasında en önemlilerden biri GGA (Global Positioning System Fix Data) 'dır. GPS dilinde "Fix" o an bulunduğumuz noktanın belirlenmesidir.
Örnek bir cümle şöyle
$GPGGA,181908.00,3404.7041778,N,07044.3966270,W,4,13,1.00,495.144,M,29.200,M,0.10,0000*40
Açıklaması şöyle
181908.00
it is a timestamp value. we can reach hour, minute and second of location using this value.

3404.7041778,N
it is latitude of location. 34 degree and 04.7041778 minute

07044.3966270,W
it is longitude of location. 70 degree and 44.3966270 minute

4
it is a quality value of location. This value can be one of 0,1,2,3,4,5,6,7 and 8
each number represents the location’s precision. when this value is 4, it means that location’s accuracy is RTK-fix. if you need really reliable location, consider that this value have to be 4.

13
it represent number of satellites being tracked.

1.00
horizontal dilution of position.

495.144
it is altitude value as meters above sea level.

29.200
Height of geoid (mean sea level) above WGS84 ellipsoid
Burada dikkat edilmesi gereken nokta fix quality denilen şeydir. Eğer alanın değeri 1 ise veri uydulardan gelmektedir. Eğer değeri 2 ise DGPS (Differential Global Positioning System) kullanılmaktadır. DGPS kullanımını hiç görmedim. Sistem GPS koordinatını bilen bir yer istasyonu vasıtasıyla yapılıyor.

2. RMC - Recommended Minimum Specific GPS/Transit Data - Konum
Aslında GGA ile aynı işi görür. Açıklaması şöyle. Ancak RMC "Recommended" olduğu için tüm GPS cihazları gönderir.
The data in both will be the same. If they aren't, it has to do with the timing of sending the messages.

The reason they are both sent is for compatibility, and because they do contain different data for some fields. If you just need lat/lon and time, then either sentence is fine. I would go with GPRMC, as all NMEA GPS units should send this sentence.
Difference between GGA and RMC sentences in NMEA
Açıklaması şöyle. Yani GGA'dan farklı olarak RMC mesajında hareket edilen açı da veriliyor.
Track angle (field 6 in RMC) is the direction the vehicle is moving, not necessarily the direction it faces, although for a ground (wheeled or tracked) vehicle these are very likely the same.

Yes, it's relative to true north.
Alanları şöyle
UTC of position fix
Status A=active or V=void
Latitude 
Latitude N/S
Longitude 
Longitude E/W
Speed over the ground in knots
Track angle in degrees (True) veya Course Over Ground (True)
Date (ddmmyy
Magnetic variation in degrees
Magnetic variation E/W
Positioning System Mode Indicator
Örnek bir cümle şöyle. Burada Mode Indicator alanı yok
$GPRMC,081836,A,3751.65,S,14507.36,E,000.0,360.0,130998,011.3,E*62
Örnek bir cümle şöyle. Burada Mode Indicator alanı var. Ancak N = Data not valid
$GPRMC,073109.00,V,,,,,,,240220,,,N*77
Latitude ve Longitude (d)ddmm.mmmm formatında geliyor. Yani derece (degree), dakika (minute) milisaniye cinsinden. Bunu ondalık bir sayıya çevirmek için şöyle yaparız.

Latitude=35.15 N
35.15/60 = .5858 N

Longitude= 12849.52 E,
128+ 49.52/60 = 128.825333 E

3. GLL - Geographic Position – Latitude/Longitude
Alanları şöyle. Aslında bu mesaj GGA ve RMC ile aynı
Latitude 
Latitude N/S
Longitude 
Longitude E/W
UTC Time
Status A=active or V=void
Positioning System Mode Indicator

4. GNS - Fix Data
Cihazın farklı uydu sistemler için alıcısının olması gerekir. Açıklaması şöyle. Yani Talker Id olarak önce GN kullanılıyor. Daha sonra GPS için GP,  GLONASS için GL ile gönderiyor.
GNSS capable receivers will always output this message with the GN talker ID

GNSS capable receivers will also output this message with the GP and/or GL talker ID when using more than one constellation for the position fix

An example of the GNS message output from a GNSS capable receiver is:

$GNGNS,014035.00,4332.69262,S,17235.48549,E,RR,13,0.9,25.63,11.24,,*70<CR><LF>
$GPGNS,014035.00,,,,,,8,,,,1.0,23*76<CR><LF>
$GLGNS,014035.00,,,,,,5,,,,1.0,23*67<CR><LF>
Örnek bir cümle şöyle
$GPGNS,112257.00,3844.24011,N,00908.43828,W,AN,03,10.5,,,,*57

5. GST - Pseudo Range Error Statistics
İstatistiki bilgi yani kalite (quality) hakkında bilgi verir.
Örnek bir cümle şöyle
$GPGST,172814.0,0.006,0.023,0.020,273.6,0.023,0.020,0.031*6A
6. GSA - GPS DOP and active satellites
Uydu sayısı yani kalite (quality) hakkında bilgi verir

7. VTG - Vector track an Speed over the Ground - Hız
Bu mesajın yeni ismi "Course Over Ground and Ground Speed". Ground'a göre hız aynı zamanda SpeedLog cihazının "VBW - Dual Ground/Water Speed" mesajı ile de alınabilir.

8. ZDA - Time & Date - UTC, day, month, year and local time zone - Saat ve Takvim
Açıklaması şöyle. Burada TalkerId olarak GP yani GPS gösteriliyor.
An example of the ZDA message string is:

$GPZDA,172809.456,12,07,1996,00,00*45

ZDA message fields
Field Meaning
0         Message ID $GPZDA
1         UTC
2         Day, ranging between 01 and 31
3         Month, ranging between 01 and 12
4         Year
5         Local time zone offset from GMT, ranging from 00 through ±13 hours
6         Local time zone offset from GMT, ranging from 00 through 59 minutes
7         The checksum data, always begins with *
9. DTM - Datum Reference
Mesaj alanları şöyle
Local datum code.
Local datum subcode. May be blank.
Latitude offset (minutes)
N or S
Longitude offset (minutes)
E or W
Altitude offset in meters
Datum name. What’s usually seen here is "W84", the standard WGS84 datum used by GPS.

20 Nisan 2021 Salı

Automatic Identification System - AIS

Giriş
Açıklaması şöyle
AIS is also among the types of a navigation system which helps to pinpoint the location and other navigational statistics of ships. AIS uses VHF radio channels as transmitters and receivers to send and receive messages between ships which endeavors to fulfil a lot of responsibilities.

As per the regulation enforced by The International Maritime Organization (IMO), all passengers’ vessels and commercial ships over 299 Gross Tonnage (GT)  sailing in the international to carry a Class A AIS transponder.
AIS Cihaz Tipleri
Class A ve Class B olarak sınıflandırılıyorlar. Açıklaması şöyle
AIS Types

- Class A: Mandated for all vessels 300 GT and above engaged on international voyages as well as all passenger ships
- Class B: Provides limited functionality and intended for non SOLAS vessels. Primarily used for vessels such as pleasure crafts

AIS operates principally on two dedicated frequencies or VHF channels:

- AIS 1: Works on 161.975 MHz- Channel 87B (Simplex, for ship to ship)
- AIS 2: 162.025 MHz- Channel 88B (Duplex for ship to shore)

It uses Self Organizing Time Division Multiple Access (STDMA) technology to meet the high broadcast rate. This frequency has a limitation of line of sight which is about 40 miles or so.
Class A için açıklama şöyle
Shipborne mobile equipment intended to meet the performance standards and carriage requirements adopted by IMO. Class A stations report their position (message 1/2/3) autonomously every 2-10 seconds dependent on the vessel’s speed and/or course changes (every three minutes or less when at anchor or moored); and, the vessel’s static and voyage related information (message 5) every 6 minutes. Class A stations are also capable of text messaging safety related information (message 6/8) and AIS Application Specific Messages (message 6,8,25,26), such as meteorological and hydrological data, electronic Broadcast Notice to Mariners, and other marine safety information
Class B için açıklama şöyle
Shipborne mobile equipment which is interoperable with all other AIS stations, but, does not meet all the performance standards adopted by IMO. Similar to Class A stations, they report every three minutes or less when at anchor or moored, but, their position (message 6/8) is reported less often and at a lower power.  Likewise, they report the vessel’s static data (message 18/24) every 6 minutes, but, not any voyage related information. They can receive safety related text and application specific messages, but, cannot transmit them. There are two types of Class B AIS, those using carrier sense Time-Division Multiple Access (CS-TDMA) technology and those like the Class A using Self-Organizing Time-Division Multiple Access Technology (SO-TDMA).  Class B/SO is generally more capable; Class B/CS is generally less expensive.
AIS Mesajları ve Zaman Damgası
AIS mesajlarında zaman damgası bulunmaz. Açıklaması şöyle.
The AIS system was initially created as a collision avoidance system, and was supposed to be used in real time, hence there was no need to transmit a timestamp.
AIS ve MEA 0183 İlişkisi
AIS mesajları binary mesajlar olmalarına rağmen, NMEA içinde gönderilebiliyorlar. AIS taşıyan iki tane mesaj var. Bunlar VDM ve VDO mesajları. Açıklaması şöyle
!AIVDM (received data from other vessels)
!AIVDO (own vessel's information)
Açıklaması şöyle
!AIVDM   The NMEA message type, other NMEA device messages are restricted  
1              Number of sentences (some messages need more than one, maximum generally is 9) 
1              Sentence number (1 unless it is a multi-sentence message) 
MsgId      The blank is the sequential message ID (for multi-sentence messages) 
A              The AIS channel (A or B), for dual channel transponders it must match the channel used 
14eG;...   The encoded AIS data, using AIS-ASCII6 
0*             End of data, number of unused bits at end of encoded data (0-5)
7D            NMEA checksum (NMEA 0183 Standard CRC16)
Fragmentli Mesaj
Örnek
Şöyledir. Başka bir gemiden gelmektedir.
!AIVDM,2,1,8,A,56;OaD02B8EL990b221`P4v1T4pN0HDpN2222216HHN>B6U30A2hCDhD`888,0*4D
!AIVDM,2,2,8,A,88888888880,2*2C
Açıklaması şöyle
Consider a message sent using 2 fragments:

Field 2 will be 2, the number of fragments.
Field 3 will be 1 for the first fragment, and 2 for the second
Field 4 can be any digit between 0 and 9, but will be common for both messages. This number is incremented for each new multi-fragment message sent by a vessel. It allows the decoding program to match together fragments that belong to the same message
AIS Taşıyan NMEA Mesajları İçin Parser
aisparser kullanılabilir.
aismessages kullanılabilir
AisLib kullanılabilir

Mesajlar
Mesaj alanları 6 bit büyüklüğünde gruplanır ve bu altı bit özel bir şekilde ASCII karakterine çevriliyor. Ancak bir alan örneğin 8 bit olabilir. Bazı mesaj açıklamaları şöyle
1. Static Information (Every 6 minutes and on request):
- MMSI number
- IMO number
- Name and Call Sign
- Length and Beam
- Type of ship
- Location of position fixing antenna
2. Dynamic Information (Depends on speed and course alteration)
- Ship’s position with accuracy indication
- Position time stamp (in UTC)
- Course Over Ground (COG)
3. Voyage Related Information (Every 6 minutes, when data is amended, or on request)
- Ship’s draught
- Type of cargo
- Destination and ETA
- Route plan (Waypoints)
4. Short safety related messages
Free format text message addressed to one or many destinations or to all stations in the area. This content could be such as buoy missing, ice berg sighting etc
Mesajlar şöyle
Message 1 Position Report

Message 2 Position Report

Message 3 Position Report

Message 4 Base Station Report
Used by fixed-location base stations to periodically report a position and time reference.
Message 5 Static and Voyage Related Data
Message has a total of 424 bits, occupying two AIVDM sentences. In practice, the information in these fields (especially ETA and destination) is not reliable, as it has to be hand-updated by humans rather than gathered automatically from sensors.
Message 6 Binary Addressed Message
An addressed point-to-point message with unspecified binary payload. The St.Lawrence Seaway AIS system and the USG PAWSS system use this payload for local extension messages. It is variable in length up to a maximum of 1008 bits (up to 5 AIVDM sentence payloads).
Message 7 Binary Acknowledgement
A receipt acknowledgement to the senders of a previous messages of type 6. Total length varies between 72 and 168 bits by 32-bit increments, depending on the number of destination MMSIs included.
Message 8 Binary Broadcast Message

Message 9 Standard SAR Aircraft Position Report

Message 10 UTC/date inquiry 

Message 11 UTC/Date response 

Message 12 Addressed Safety Related Message

Message 13 Safety Related Acknowledge

Message 14 Safety Related Broadcast

Message 15 Interrogation 
Used by a base station to query one or two other AIS transceivers for status messages of specified types.
Message 16 Assignment mode command
Used by a base station with control authority to configure the scheduling of AIS informational messages from subordinate stations, either as a frequency per 10-minute interval or by specifying the TDMA slot(s) offset on which those messages should be transmitted.
Message 17 DGNSS Broadcast binary message
Used to broadcast differential corrections for GPS. The data in the payload is intended to be passed directly to GPS receivers capable of accepting such corrections.
Message 18 Standard Class B equipment position report

Message 19 Extended Class B Equipment Position Report
A less detailed report than types 1-3 for vessels using Class B transmitters. Omits navigational status and rate of turn.
Message 20 Data Link Management Message
This message is used to pre-allocate TDMA slots within an AIS base station network. It contains no navigational information, and is unlikely to be of interest unless you are implementing or studying an AIS base station network.
Message 21 Aids-to-Navigation Report
Identification and location message to be emitted by aids to navigation such as buoys and lighthouses.
Message 22 Channel Management

Message 23 Group Assignment
Intended to be broadcast by a competent authority (an AIS network-control base station) to set to set operational parameters for all mobile stations in an AIS coverage region
Message 24 Class B"CS" Static Data Report

Message 25 Single slot binary message

Message 26 Multiple slot binary message with Communications State
 
Message 27 Position report for long range applications

İz Bilgisi Olan Mesajlar
AIS mesajlarında tekil olan alan User ID yani MMSI number. Açıklaması şöyle
Maritime Mobile Service Identity (MMSI) is a unique 9 digit number that is assigned to a (Digital Selective Calling) DSC radio or an AIS unit. Similar to a cell phone number, your MMSI number is your unique calling number for DSC radios or an AIS unit. 
Bunlar şöyle
Message 1 Position Report
Message 2 Position Report
Message 3 Position Report
Message 5 Static and Voyage Related Data
Message 9 Standard SAR Aircraft Position Report
Message 18 Standard Class B equipment position report
Message 19 Extended Class B Equipment Position Report

BaseStationg Bilgisi Olan Mesajlar
Bunlar şöyle
Message 4 Base Station Report

Aids-to-navigation report Olan Mesajlar
Message 21 Aids-to-Navigation Report

19 Nisan 2021 Pazartesi

DDS DomainParticipantQos Sınıfı

participant_discovery_protocol Alanı
Discovery için kullanılacak multicast adresi belirtir.

Örnek
Şöyle yaparız
DomainParticipantQos qos = ...;
qos.participant_discovery_protocol.add("239.255.0.50");
Daha sonra şöyle yaparız
DomainParticipantFactory dpf = ...;
dpf.set_default_pariticipant_qos(qos);

15 Nisan 2021 Perşembe

Endianness Nedir?

Endianness Kelimesi Nereden Geliyor?
Açıklaması şöyle. Yani büyük adresten başlayınca Big Endian oluyor.
The terms big-endian and little-endian were introduced by Danny Cohen in 1980 in Internet Engineering Note 137, a memorandum entitled "On Holy Wars and a Plea for Peace", subsequently published in print form in IEEE Computer 14(10).48-57 (1981). He borrowed them from Jonathan Swift, who in Gulliver's Travels (1726) used them to describe the opposing positions of two factions in the nation of Lilliput. The Big-Endians, who broke their boiled eggs at the big end, rebelled against the king, who demanded that his subjects break their eggs at the little end.
Endianness Nedir?
Endianness bellekteki bir adresin CPU'daki registerlara hangi sırada yerleştirildiğidir. Örneğin 0x89ABCDEF değeri big endian mimarisinde okunurken ilk register'a 0x89, ikinci register'a 0xAB değeri yerleştirilir. Ancak register'lar üzerinden düşünmek insanlara zor geldiği için genellikle endiannes sanki bellekle alakalıymış gibi düşünülür. Aslında aynı belleği big endian ya da little endian iki işlemciye de taksak olurdu. Çünkü belleği kontrol eden çip endianness bilmez.

İki endian tipinin farkını 4 byte'lık 42 sayısının bellekte nasıl tutulduğunu görerek anlayabilirizGeleneksel olarak bellek byte[0] -> byte1 -> ... şeklinde gösterilir, burada da gelenek takip ediliyor.
|    | byte[0] | byte[1] | byte[2] | byte[3] |
|----+---------+---------+---------+---------|
| BE |       0 |       0 |       0 |      42 |
| LE |      42 |       0 |       0 |       0 |
Gösterim
Örneğin sistemin endiannes değerini anlamak için elimizde şöyle bir kod olsun
int main()
{
  int x = 1;

  char *y = (char*)&x;

  printf("%c\n",*y+48);
}
Bu kod little endian ise şöyle çalışır
       higher memory
          ----->
    +----+----+----+----+
    |0x01|0x00|0x00|0x00|
    +----+----+----+----+
    A
    |
   &x
Big endian ise şöyle çalışır
    +----+----+----+----+
    |0x00|0x00|0x00|0x01|
    +----+----+----+----+
    A
    |
   &x
Her iki durumda da geleneksel gösterim kullanılıyor ve byte lar soldan sağa olacak şekilde yazılırlar. 

İstisnai olarak byte yerine bit kullanan NATO dokümanları bulunur. Bu dokümanlardaki mesajlar bit-oriented oldukları için bitler sağdan sola olacak şekilde yazılıyorlar.  Bit shift işlemleri endian agnostic olduğu için, endianness belirtmek gerekmiyor.


Büyük Endian (Big Endian)
SPARC gibi işlemciler big endian çalışırlar. Yazmaya sağdan başlanır. Yukarıdaki örnekte 42 en sağdan başlanarak yazılıyor. Dolayısıyla geleneksek gösterim açısından değil ancak Big Endian açısından MSB byte[0], LSB ise byte[3]

Eğer ben bu veriyi göndermek istersem önce 3 sonra 2 sonra 1 ve en son 0 numaralı byte'lar gönderilir.

Küçük Endian (Little Endian)
x86 işlemciler ise küçük endian çalışırlar. MSB sağda, LSB ise solda gibi düşünülür. Yazmaya soldan başlanır. Yukarıdaki örnekte 42 en soldan başlanarak yazılıyor. Dolayısıyla geleneksek gösterim açısından değil ancak Little Endian açısından  MSB byte[3], LSB ise byte[0]

Internette Haberleşme
Internette haberleşmek için Big Endian kullanılır. Dolayısıyla Küçük Endian bir işlemci, veriyi gönderirken byte'ları yer değiştirerek gönderir.

Eğer ben bu veriyi göndermek istersem önce 0 sonra 1 sonra 2 ve en son 3 numaralı byte'lar gönderilir.

Örnek
Şu kod parçası c'ye yine ilk byte'ın değerini verir. Yani c = 1 olur
int a = 1;

char c = (char)a;
Örnek
Ağdan gelen bir veriyi - örneğin 4 byte'lık bir diziyi - küçük endian mimaride int'e cast edersek farklı bir sayı elde ederiz. Bir projede ARP isteği içindeki IP adresini int'e çevirip okurken şöyle bir kod kullandım ve bu başıma geldi.
struct sockaddr_in sai;
memcpy (&sai.sin_addr,buffer.data(), buffer.size());
int result = sai.sin_addr.s_addr;
Bit Oriented Mesajlar
Bit Oriented mesajlarda Endianness önemli değildir. Çünkü veri bitler şeklinde okunur ve yazılır. Bu durumda "Bit Numbering" gösterimi önemli hale geliyor.

1. LSB 0 bit numbering
Açıklaması şöyle
When the bit numbering starts at zero for the least significant bit (LSB) the numbering scheme is called "LSB 0".
Yani bitler şöyle gösterilir
7 - 6 - 5 - 4 - 3 - 2 - 1 - 0
2. MSB 0 bit numbering
Bitler şöyle gösterilir. MSB 0 aslında sadece gösterimsel bir şey. IPv4 örneğinde açıklaması görülebilir.
0 - 1 - 2- 3 - 4 - 5 - 6 - 7 
3. Word Olarak 2 Byte Kullanan Mesajlar
Burada da önce hangi byte'ın gönderildiği (transmission) önemli hale geliyor. 
Örnek - 1553
Bir örnek şöyle
Q: Are 1553 packets Big Endian like Ethernet?
A. No, little endian if we are talking about bits. Bit 15 is sent first (15, 14, 13, 12, ....2, 1, 0). Bit 15 - 8 is the Most significant Byte, while bits 7-0 are the least significant Byte.
Örnek - IPv4
Şeklen şöyle. Burada MSB 0 Numbering kullanılıyor.

Açıklaması şöyle
... for the diagram and discussion, the most significant bits are considered to come first (MSB 0 bit numbering). The most significant bit is numbered 0, so the version field is actually found in the four most significant bits of the first byte,
Açıklaması şöyle
The network byte order does not specify how bits are transmitted over the network. It specifies how values are stored in multi byte fields.

Example:

The Total Length field is composed of two bytes. It specifies in bytes the size of the packet.

Lets say we have the value 500 for that field. Using the Network Byte Order it will be seen over the wire like this, being transmitted transmission from left to right:

00000001 11110100
If we would use the little endian format then it would have been seen over the wire like this:

11110100 00000001
After the whole packet is constructed the bits will be sent starting with the lowest addressed bit of the header (bit 0), so the transmission will start with the Version field.
Örnek - NATO Dokümanları
Bu dokümanlarda bit gösterimi genellikle şöyle
15 - 14 - 13 - 12 - 11 - 10 - 9 - 8 - 7 - 6 - 5 - 4 - 3 - 2 - 1 - 0




5 Nisan 2021 Pazartesi

git bundle seçeneği

Örnek 
Açıklaması şöyle
A better way to share git repositories offline is to create a bundle file and send that to your friend, e.g.:
git bundle create /tmp/myrepo.bundle --all
Then you can send myrepo.bundle to your friend and they can clone from it like they would from any remote:
git clone myrepo.bundle 
That would be a better way to make sure that you're not sharing loose objects that aren't intended to be seen by others.