Make your own eBooks

Use our Remix App to mix & match content. In minutes make your own course packs, training bundles, custom travel guides, you name it. Even add your own title & cover.

Education
Research
Travel
Health

Slices & Articles Get by the slice or add to your own ebook

Medium 9780596800956

25. Native and COM Interoperability

Joseph Albahari O'Reilly Media ePub

This chapter describes how to integrate with native (unmanaged) DLLs and COM components. Unless otherwise stated, the types mentioned in this chapter exist in either the System or the System.Runtime.InteropServices namespace.

P/Invoke, short for Platform Invocation Services, allows you to access functions, structs, and callbacks in unmanaged DLLs. For example, consider the MessageBox function, defined in the Windows DLL user32.dll as follows:

You can call this function directly by declaring a static method of the same name, applying the extern keyword, and adding the DllImport attribute:

The MessageBox classes in the System.Windows and System.Windows.Forms namespaces themselves call similar unmanaged methods.

The CLR includes a marshaler that knows how to convert parameters and return values between .NET types and unmanaged types. In this example, the int parameters translate directly to 4-byte integers that the function expects, and the string parameters are converted into null-terminated arrays of 2-byte Unicode characters. IntPtr is a struct designed to encapsulate an unmanaged handle, and is 32 bits wide on 32-bit platforms and 64 bits wide on 64-bit platforms.

See All
Medium 9780596510039

8. Network Address Translation

Stefan Brunner O'Reilly Media ePub

Network Address Translation (NAT) was developed as an interim strategy to address Transmission Control Protocol/Internet Protocol (TCP/IP) network address space depletionone of the main drivers for the IPv6 protocol.

In 1994, K. Egevang and Paul Francis introduced NAT in RFC 1631. With NAT, it is possible to recycle address spacemultiple hosts can use the same address space as long as they communicate over a unique address space. The Network Address Translator, a function within a router (or a firewall with routing capability) would perform the translation to the unique address space, usually on the border between the private portion of a network and the public Internet. In 1994, a "recyclable" address space was defined in RFC 1597, and was obsoleted by RFC 1918 in 1996. Dedicated for private use were one Class A network within 10/8, 16 Class B networks within 172.16/12, and 255 Class C networks within 192.168/16.

NAT is not just a method for fighting address space depletion. It was also quickly adopted by security engineers, who liked the idea that thousands of hosts were able to hide behind a single IP address by using NAT with Port Address Translation (PAT). This helps prevent simple port scanning and other attack techniques on those hosts, but you should not consider it as anything but a part of an overall security strategy.

See All
Medium 9781616139742

First Album

Sarah Tieck Big Buddy Books PDF
Medium 9780596002541

6. Traffic Engineering

Iljitsch van Beijnum O'Reilly Media ePub

Being multihomed means you have two (or more) routes to any destination connected to the Internet. In other words, you need a way to decide which route is better. When left to its own devices, a BGP router will try to send traffic over the route with the shortest AS path. Depending on the connectivity of your upstream ISPs and traffic patterns, this will suit the available bandwidth of the respective connections to varying degrees. Even though bandwidth is getting cheaper all the time, its usually advantageous to try to balance the traffic so that it takes advantage of all the available bandwidth in a multihomed setup. Thus, if BGP decides that most of the outgoing traffic should go through the smallest pipe, you will have to tell it that this isnt what you want by tweaking one or more BGP attributes. Ideally, more traffic will then flow over the under-used connection. At the same time, youll want the traffic to take the best route to a destination, if possible, whatever best may be. This type of activity is called traffic engineering.

See All
Medium 9781780420905

Pablo Picasso (1881-1973)

Victoria Charles Parkstone International PDF

See All Slices