Configure player

Close

WWDC Index does not host video files

If you have access to video files, you can configure a URL pattern to be used in a video player.

URL pattern

preview

Use any of these variables in your URL pattern, the pattern is stored in your browsers' local storage.

$id
ID of session: wwdc2008-328
$eventId
ID of event: wwdc2008
$eventContentId
ID of session without event part: 328
$eventShortId
Shortened ID of event: wwdc08
$year
Year of session: 2008
$extension
Extension of original filename: m4v
$filenameAlmostEvery
Filename from "(Almost) Every..." gist: [2008] [Session 328] Networking ...

WWDC08 • Session 328

Networking with Bonjour

Essentials • 51:25

Bonjour is a key networking technology used in all of Apple's network products, from iMacs and MacBooks to AirPort Extreme, Apple TV and iPhone. Come find out how to use the Bonjour APIs to make your network application work with Back to My Mac and how to use the Bonjour APIs on iPhone and iPod touch to make amazing handheld network applications.

Speakers: Stuart Cheshire, Rory McGuire, Craig Keithley

Unlisted on Apple Developer site

Downloads from Apple

SD Video (623.7 MB)

Transcript

This transcript was generated using Whisper, it has known transcription errors. We are working on an improved version.

Welcome to the Apple Developer Conference. Thanks for coming to our Bonjour networking session this morning. Why are you here? You're here because you are the guys that make really cool networking software and networking hardware, and you want it to be reliable and easy to use without users having to type in host names and IP addresses and port numbers and nonsense like that. You want to do screen sharing, you want to do file sharing, you want to print over the network, you want to access music and photos and movies and other media over the network. And Bonjour makes that reliable and easy to use.

Sometimes your client and your server or your communicating peers might not be on the same network. They might be on opposite sides of the internet. Sometimes there might be NAT gateways in the middle, rewriting the packets as they go through. Wide area Bonjour makes that easy for you as well.

So I'll start with an outline of what we're going to talk about today. A lot of you here know all about Bonjour, but more than half of the attendees this year are first time at the developer conference, so we're going to have a quick recap of what Bonjour is and how it works.

Then Roary is going to tell you all about the really cool new stuff we have using Bonjour on iPhone and iPod touch. And he's got some cool demos, which I think you're really going to love. We'll also talk to you about how Back to My Mac works, which is built on Bonjour.

So Back to My Mac is not just for screen sharing and file sharing. Your applications can use Back to My Mac as well. We'll wrap up with some tips and reminders, cover some frequent mistakes that we see that we want to encourage you not to make, and then we'll have time for Q&A at the end.

So, summing it up in one sentence, this is what it's all about. We want networking with TCP IP to be as easy to use as plugging in a USB cable. And standing here today saying this to you, this doesn't sound too surprising. I think this idea has become accepted. But five, ten years ago, this was like heresy.

When you suggested that you would want to do things using IP networking, the reaction most people had was, you must be crazy, typing in IP addresses and subnet masks and default gateways and all that nonsense. I just want to plug my printer in the USB port. Well, in the five years since that, we've seen Bonjour get adopted in the marketplace.

And now, for under $200, you can buy a network printer with Bonjour and you plug it in and it shows up in the print dialog just as easily. And that's what we want to see more of. Some of you are probably thinking, but AppleTalk is really good for this. Well, we're here to tell you today, officially, AppleTalk is dead.

AppleTalk is no longer in Snow Leopard. And if you want to make a device, the only network browsing to discover printers on the Mac is going to be Bonjour. So that's what you need to be doing. This slide used to be the whole talk, now we've condensed it down to one slide to make room for other stuff.

These are the three technological legs that make the foundation of Bonjour or zero configuration networking. And Bonjour is not about this technology. What Bonjour is about is the user experience that we want people to have. This is not a protocol that we designed and then slap a user interface on top of it.

Stuart Cheshire, Rory McGuire, Craig Keithley We started out with the user experience we wanted people to have. But then to make that a reality, we had to build the technologies to make that work. Stuart Cheshire, Rory McGuire, Craig Keithley The first one is link local addressing. DHCP is great. Nothing wrong with DHCP servers. But if you don't have one, the device shouldn't fall on its face and call for an administrator to come and help it.

It needs to be able to get on the network on its own. Stuart Cheshire, Rory McGuire, Craig Keithley So if you don't find a DHCP server, it's very simple. Stuart Cheshire, Rory McGuire, Craig Keithley We looked at what AppleTalk did and we applied the same principles. Stuart Cheshire, Rory McGuire, Craig Keithley You pick a random address in a range reserved for this purpose. You send an ARP request.

If somebody answers that, it means they have the address and you pick a different one. If nobody answers, it's yours. Stuart Cheshire, Rory McGuire, Craig Keithley So that's how devices can just plug into an Ethernet hub and all get unique addresses, which is great. Stuart Cheshire, Rory McGuire, Craig Keithley But you need to know what the address is, and you don't want to be typing in addresses. So multicast DNS is the next layer of the three-layer cake.

In standard internet applications, DNS is the name service that we're familiar with. And just like I said with DHCP, nothing wrong with DHCP servers, there's nothing wrong with DNS servers as long as you have one and you know how to administer it. But we want a lightweight solution. We want a safety net for when that's not available. So multicast DNS takes the same packet formats and the same names and the same record types of standard DNS but sends them over multicast.

So every device has a little responder listening for these packets and when it sees a query for its name, it says, hey, that's me and gives a standard DNS answer. So that's good. So now you can type in a name, something.local, and have that resolved by multicast. And you can type in a name, something.local, and have that resolved by multicast. The URLs there tell you where you can find more details and all the specifications.

So this is our architecture that we launched five or six years ago. It is the DNS service discovery semantics delivered using multicast DNS packets, completely zero configuration. But the day we launched that, we knew that the first question we were going to have once it became popular was people would say, this is great, but I want to scale it beyond the subnet.

So there's a reason we picked DNS packet formats and records and naming in the first place, because DNS is the world's largest scale distributed database. It scales beyond the enterprise to the whole planet. So using the same DNS service discovery semantics, we can perform those operations using wide area unicast DNS. So we register using standard DNS dynamic update to put those records on the name server, and we discover using DNS queries.

And those of you who've got your laptops out, if you look in Safari and look under Bonjour bookmarks, you will see three pages that are being advertised here with information. So if you forget the URL, it doesn't matter. You don't have to remember the URL. You can just look in Bonjour bookmarks and find those.

Standard DNS is good, but there were some extra things we wanted to do. Standard DNS updates stay on the server indefinitely, so if you unplug your laptop from the Ethernet cable and walk away, nobody's going to delete those records. And we didn't want an administrator to have to clean those up, so we added a lease mechanism. Just like when you get a DHCP address from a DHCP server, it's not permanent, it has a time on it.

And if you don't renew it before it expires, then you lose the address and it goes back into the pool of available addresses. When we do updates on the server, we have an extension to the DNS protocol that puts a lifetime on those updates. And as long as the client machine is active and on the network and running, then it renews those records and keeps them live. But if you unplug and walk away, then when the records expire, they get deleted automatically.

Another reality of today's world is a lot of users are behind NAT gateways at home. And NAT gateways rewrite the packets so that you only have one public address. And roughly speaking, the client machine doesn't even know what the public address is. It doesn't know the packets are being rewritten.

So we added support to Bonjour so that when your application running on Mac OS X or on Windows or on Linux registers its service, we detect if there's a NAT gateway and we talk to the NAT gateway. We set up a port mapping automatically so the users no longer have to do that manual port mapping that's very hard to explain. We find the public address, we get a public port mapping, and then we put that external information into the DNS so that you can run a web server at home. You can run... photo sharing, you can run whatever applications you want.