WWDC2001 Session 303

Transcript

Kind: captions
Language: en
never configuration and mobility
architecture on Mac os10 in particular
going to be talking about the particular
pieces that we have and how they
interact and not going to be talking
about api's today unfortunately because
what we have today is all private and
it's a work in progress so what we're
looking what we're looking from you guys
today in particular is some feedback on
the kinds of configuration questions
you'd like to answer we have some api's
and I'll talk about that a little bit
later so what are some of the goals that
we have and we'd like to support dynamic
network configuration changes on Mac OS
9 everybody was used to the idea that
you know you don't have to reboot your
computer to make a change so Mac OS 10
has that now as well the other thing
that we wanted on top of what we have in
nine is the ability to configure
multiple network interfaces at the same
time and actually make use of them in a
sensible way the other goal that we have
is to avoid user intervention when it's
possible so a couple of examples you've
got a laptop that you're using for work
and at home and you're working on some
project at home and you're using the
network you put the systems asleep you
bring it to work you plug it in and it
just works because using DHCP and it
figures out a new address and it just
works or if that's not possible you
switch locations and you pick up your
new config just like on nine another
config that uses a multihoming is the
LAN and Airport configured
simultaneously so your system prefers
land over airport wild land is connected
but when land excuse me this connects
the system switches over to using
airport automatically so to be able to
support this kind of thing we have a set
of requirements the first thing that we
need some sort of low-level Network
events so when the link status changes
we need to be able to find out about it
and do something we need some sort of
persistent storage to be able to store
the never configs
we also knew we needed some sort of
dynamic store
just to be able to store temporary
information or dynamic information as
its generated such as information from a
DHCP client a server or a PPP server the
other thing we need is some mechanism to
be able to apply some configuration to
the system together requirement we have
is some sort of flexible schema in both
the persistent and dynamic store to be
able to allow for future expansion so
what we've come up with is a system
configuration architecture and we've
decided to call it system configuration
architecture not the network
configuration architecture because we
wanted to generalize the concepts we
knew where we're going to solve some
general problems and wanted to make the
services general our solution leverages
core foundation pretty heavily using run
loop source technology and all the
property list types and objects the
other point about the network
configuration architecture is that it's
open source all the source code we have
today that shipping and Mac os10 is
available in Darwin you can check out
the projects and see what it does
unfortunately as I mentioned before it's
all private API so you can't technically
really rely on it but it's there for you
to look at and understand so the system
configuration architecture contains
three main pieces the dynamic store
system configuration preferences and the
configuration agents the dynamic store
stores the current system configuration
information it's a snapshot of the state
of the system the other thing the
dynamic store provides is notification
services the system configuration
preferences provides system persistent
storage for configuration information
this is where the sets and different
locations are stored the configuration
agents apply the configuration that the
user is chosen to the system and
interact with a dynamic store so here's
a little diagram that illustrates the
relationship between the agents the
dynamic store and the preferences where
each of the individual agents are
interact
the dynamic store and some configuration
source hmm so what is the dynamic store
then a dynamic store contains the
current system configuration information
it's a snapshot of basically how the
system is configured it's not persistent
across reboots so every time the system
starts up the contents are regenerated
it's a dictionary so it's a set of key
value pairs where the key is a CS string
this format is a hierarchical namespace
much like a URL we've encoded it using a
domain prefix in a path so in the
example there there's a state : prefix
and the path is network Global DNS the
value is any CF property list type
normally a CF dictionary so that you can
contain multiple properties within a
specific key so the way the dynamic
store notifications work is a client
decides that it's interested in a
particular key and registers to receive
notifications and the notifications are
level triggered rather than edge
triggered what we mean here is when a
key changes you aren't provided a key
and its value you're provided that the
key has changed and then it's up to you
to go and verify what the value is we're
trying to avoid creating big long
streams of event buffers that you know
when the system gets really busy may
over run mm-hmm
the dynamic store is hosted by the
system configuration server which is
actually daemon in the system called
config D and I call it the heart of the
mobility architecture because everything
that happens with respect to networking
goes through the dynamic store so the
second major piece of our architecture
is the system configuration preferences
it's a persistent storage as I mentioned
before for the system setup information
like CF preferences but it actually has
notifications when things change the
other thing that it has is that it's
accessible easily
from system Damon's and the source code
for it is in Darwin whereas CF
preference currently is not in Darwin we
use CF property list types for just
about everything and when the file is
written out to disk it's serialized as
XML and the default preferences for the
system that are used to store all the
network configurations is in VAR DB
system configuration preferences XML so
what do the system preferences contain
currently we've defined four main
preferences the current set Network
Services sets and system the current set
contains a link to the currently active
set it's free Matala contains the
network services contains a complete
list of all the network services that
have been defined across all sets and
assets the set preference is just that
it's a list of sets and system contains
the items that are not location
sensitive such as the computer name so
what's a set in the set is the complete
configuration for a single location
it contains the list of network services
that are defined for that location and
also contains the order of the network
services for that location so here's
where you would prefer LAN / built-in
airport a network service what we mean
by that as a collection of network
entities which are just a set of
properties for a specific area of
interest which I'll mention in the next
slide but it's the the network service
is the the configuration for a single
network connection or interface and it's
identified by a unique network service
ID a network entity is a list of
properties for a single protocol or area
of interest an example there would be
ipv4 or PPP there's a set of properties
that are associated with the protocol or
the area of interest
so here's a diagram of what we have in
terms of the preferences and their
relationships to each other you can see
the current set contains a path to a a
property inside sets that points to
which set is currently active so when
you go into the location popup on the
under the Apple menu the thing that it's
meant manipulating is the current set
and so you notice there we're pointing
at set K set K is a dictionary that
contains a sub dictionary called Network
and the subjection area network contains
two sub dictionaries itself one called
service and the other global inside
service we have links to the individual
services that are active for that set so
you notice I D X points to IDX in
network services and inside I D X and
network services we have a set of
network entities in this case the
configuration method for ipv4 is set the
DHCP and the interface entity has a
device name of en 0 so we've identified
the vise and the configuration method
inside system there's a computer name
that's pretty much all we store there
now but it's there for anything that
doesn't change depending on location so
the third main category of the
architecture is the configuration agent
configuration agent manages some aspect
of the configuration it's associated
with one or more configuration sources
basically things that can be configured
or provide configuration information and
it has a well defined role so from the
original diagram the relationship is
that the agent interacts with the
dynamic store and it manages some
configuration source or multiple
configuration sources so here's the list
of a number of the agents we have in Mac
OS 10 today first one is the kernel
event monitor
and the second is the Preferences
monitor the IP configuration server IP
monitor and PvP controller I'm going to
go into more detail on each of these in
the upcoming slides so we'll start with
the colonel event monitor colonel event
monitor is an agent whose sole purpose
in life is to maintain the link status
and the interface state of all the
interfaces in the system so what happens
is it opens up a colonel event socket
and receives colonel events that
interfaces are added the link status has
changed addressing has changed and when
it receives those events it populates
the dynamic store with the values in
this case the link status on zn0 has
changed and the colonel event monitor is
updated a key in the dynamic store that
says that the link status is done active
so as I mentioned before it maintains
the network interface state and it
manages the colonel event socket it
maintains a list of network interface
names in a key that's encoded as state :
network interface that's actually a
dictionary that contains an interfaces
array that contains the name of each
interface that's defined in the system
so if you want to know an interface has
changed has been added to the system you
would receive notifications on that key
the other thing that it maintains
currently is the link status of each
interface and we've encoded that as
state : network interface interface name
link which is a dictionary that contains
inactive property which is a boolean by
updating the dynamic store in such a way
the colonel event monitor provides
notifications for other agents in
particular the IP configuration agent as
we'll see in an upcoming slide
the second configuration agent and I'd
like to talk about is the Preferences
monitor preferences monitors sole
purpose in life is to take the current
set dictionary and load it into the
dynamic store so it's configuration
sources the system configuration
preferences it maps the current set
dictionary into the de flat into the
dynamic store and the mapping process
amounts to a flattening process and the
next couple of slides try to illustrate
that so here's the dictionary before we
flatten it so if you look at it we've
got a dictionary that contains property
that's a string called user visible name
and it's set the work land it also
contains a sub dictionary called DNS the
DNS contain server addresses at a domain
name after flattening that'll become two
dictionaries the first dictionary is
encoded as the dictionary at that root
node and the second dictionary is
encoded as just the dictionary at that
second node with all the other elements
removed so if you look at it again we go
from that to that and the key and the
key that's generated for the the mapped
the dictionary encodes its path so the
mapping excuse me the mapping amounts to
a dictionary tree traversal where we
start at the root and at Dick edek each
dictionary no we compute a key and a
value the key is the path of the
dictionary within the preference and the
value is the node with all the sub
dictionaries removed mmm
also part of the mapping process we
resolve all the references and links so
there's pasta there's a possibility that
there are links inside the preference
will resolve those and fully populate
them
the other thing that it does is it
eliminates dictionaries that are
inactive that have been marked by the
user interface or some other entity and
it also eliminates empty dictionary so
if you have a dictionary that doesn't
contain any keys effectively the the
entire keys just just just destroyed mmm
and before putting it into the dynamic
store it adds a set up colon prefix to
the to the key that's its name space
within the dynamic store so why do we do
the mapping the reason why we do the
mapping is to provide finer grain that
is per dictionary notifications the
other notifications that we would get
without it would just be simply that the
preferences had changed so instead of
doing that we we I can actually generate
fine-grain notifications by keeping
track of the current mapping and the new
mapping and computing a difference
between the new and the old and
triggering notifications on the keys
that have changed so the benefits of
doing this are that a single agent
understands the preferences layout and
other agents only have to know the
dynamic store layout so it provides a
layer of abstraction
so I'm going to talk about the next
agent which is the IP configuration
agent type II configuration agent
configures Ethernet devices for IP using
a manual DHCP and boopie the way it
works is it's triggered off of
notifications out of setup so anytime
someone switches locations it reads the
configuration at a setup that the
Preferences monitor loaded and applies
the configuration to the interface
that's associated with the particular
config anytime the user goes into the
control panel and changes a key the IP
configuration agent wakes up and applies
to the new config to the system I mean
once it's configured an interface it
writes the dynamic store keys to
indicate that it's done its
configuration and the configuration is
active in particular it writes the IP
address and subnet mask and for bootp
and dhcp it supplies router and dns info
the other feature of the IP
configuration agent is that it detects
the link status so the kernel event
monitor is providing notifications that
the link status is going up and down the
IP configuration agent notices when the
link goes down and stays down for some
period currently set at four seconds and
Dee configures the interface when that
period is expired and when the link
becomes active again it knows that it's
going to retry the configuration method
so you can take a computer and plug it
into one network and then plug it into
another it'll retry the configuration
method and if you're using DHCP you can
grab a new address automatically the
fourth age and I'm going to talk about
is the PvP controller agent pvp
controller does a similar task to the IP
configuration agent except that it
manages pvp interfaces for IP so it does
dial-up modem connections and PPP over
ethernet it's just like the IP
configuration agent it reads its
configuration from the setup keys and
it's notified when the user makes
changes as well and once the interface
has been brought up and configured it
writes dynamic store state keys when the
configuration is applied so it's going
to supply IP address destination address
and a router and when the PPP server
supplies it it's going to supply DNS as
well the other thing it does is it
creates PPP interfaces as it needs it
and interacts with dialers which brings
us to the fifth agent epi monitor agent
it's actually the thing that decides
which interface or service is going to
be primary and what we mean by a primary
service interface we mean the one that's
associated with the default route and
the default DNS for the system since the
system currently can only make use of a
single DNS in the system you have to
pick some interface and so what we do is
we allow the user to select which one
they want by ordering them so it
consumes the information provided by the
IP configuration in PvP controller
agents and waits for changes to appear
when a service comes online decides that
okay that's the interface or service I'm
going to use and it'll exit a primary
and takes the configuration that's
supplied both in the backend the the
permanent preferences and the dynamic
information and applies it to the system
as I mentioned before there's a service
order array that decides which service
is going to be primary when you're in a
multi home situation so now I'm going to
call my colleague Allen Nathanson up
here to do a demo for you and show you
some of the things I've been talking
about so döner went over and sort of
gave a good overview of what we've got
and my job is to sort of show you a
little bit of the stuff under the covers
and show you that it's real so the first
thing that I like to do is crank up
system preferences and I've already
picked the network pane here and we have
pre-configured a couple of different
locations automatic is the one that you
would get first time you go over and
crank up your system I've got a service
called none and if you could look at the
the Advanced tab you can see that all of
the three ports have been turned off
this is the one that I use when I'm
flying from the east coast to the west
coast and don't want to go over and
disturb the the airplanes networking and
then I've got a couple other
configurations here the WWDC air and LAN
and this configuration has got all three
network services enabled with the
airport interface having a little bit of
priority over the the built-in Ethernet
which has priority over the internal
modem and the idea here is that if the
airport interface is available we'll use
that
and if not we'll try going going over
and using the built-in Ethernet and if
that's not there off to the internal
modem and a very similar configuration
is the WWDC LAN and air and if you go
over and look at the difference this
one's got the the built-in Ethernet
being on
so these are the configurations that
I've got a couple other things to look
at in the built in Ethernet
configuration it's set up from manual IP
addressing IP address subnet mask a
router some DNS information this is what
you'd have to do if you didn't have a
DHCP server available to to provide all
the information for you in the airport
case we're set up for using DHCP and
nothing else has been provided so we're
sort of like relying on the DHCP server
to provide the configuration information
so this is what we've got from the the
top side of the the view this is what
you as a user what government set up for
your configuration preferences and all
of this gets stored in that
configuration store in the preferences
store which is the next thing that I'm
going to go over and show you it's all
stored in an XML file and happen to have
a handy dandy reference the the route
dictionary of the Preferences file has
got four preferences that we've
currently defined the current set the
network services is a dictionary of
services that we've got the sets is a
dictionary of the sets which have
currently been defined and then the
system so the current set says that well
let's go let's go over and look at sets
for a second for different services were
configured set zero is the automatic set
you can tell that based on its user
defined name set one is the WWDC LAN LAN
has priority over airport service set
two is the airport services got priority
over the land and set three is my none
so if we go over and chase down current
sets pointing to sets one we can open
this up and within the network
configuration of the circuit of this set
we've got a couple of pieces of
information the global information which
Dieterle alluded to within the ipv4
configuration here's the service order
array and it goes over and says
that the prior relative priority of the
services for this set is service ID 1
followed by service ID 2 followed by
service ID 0 and these are all strings
so that's the global state and then
within the services again we have the
three services service 0 1 & 2 and one
of the things that dieter mentioned was
that we have the ability to put in some
links so service ID 0 is really gonna be
grabbed from network services 3 imagine
going over and chasing this that's why
we have programs service ID 1 is network
services for and service ID 2 is network
services 5 and we can go over and go
into network services and here's 3 4 & 5
3 if you go look at its user defined
name this is the configuration for the
internal modem 4 is the configuration
for the built-in Ethernet and 5 jumps
around along is the configuration for
the airport within the the airport
configuration we go look at the ipv4 and
how it's going to be configured and set
up for DHCP if you remember the airport
configuration we didn't have any
information for DNS so there's an empty
dns dictionary one thing that you'll see
if you go over and look at the
preferences as they're stored right now
there's a couple of dictionaries which
sort of like why is this here and the
big reason behind that is we're trying
to go over and remember things for the
UI there's a an active flag that we'll
go over and show up which the
preferences monitor looks at and says
ignore this for now it's not relevant to
the configuration so the airport
configuration is set up for DHCP and the
built-in Ethernet configuration is set
up for manual addressing
and the addresses that will get applied
there's the IP address
there's the subnet mask and there's the
default route and then up here in the
dns dictionary you have the domains that
are being searched and a list of
addresses for the DNS servers so this is
what sort of at the very bottom of the
food chain is stored preferences so the
next thing to do is to go over and look
at what's in the dynamic store and when
putting all of this stuff together I
wrote a little command line tool to go
take a peek into the dynex dynamic store
and exercise the api's and it's just
something that comes in real handy so
this is the system configuration utility
gives you a little prompt and you go
over and open up a session with config D
with the system configuration server and
there's a whole bunch of commands that
you can do and I'm gonna go over and
show you a small handful of them there's
a list command which you can go over and
say show me a list of keys in the
dynamic store that match this prefix so
here's keys that relate to the current
state of the system and here's a list of
keys that relate to the stored
preferences and what you end up doing is
we do a get of a given key
and then we go over and show the results
of what that information gets fetched
out of the dynamic store and you can see
that we've got the subnet masks we've
got the addresses the config method is
manual the default route is here so this
is really just a me it's the flattened
version of what's stored in the
configuration preferences if you want to
go over and look at things like what the
current link status is
get the state it goes over and says oh
the active flag and a boolean value and
this version of this command doesn't
split out things as well as I'd like
there's a couple of other things you can
do as far as notifications and what I'm
going to do here is I want to go over
and say let's go over and watch for a
notification of something changing so I
see do a notification ad and I want to
go over and watch for changes to the
built-in Ethernet so at this point the
command is sitting here it'll go over
and it's told the system configuration
daemon to let it know when something
happens to the link status on en0 and if
I reach behind here and yank out the
cable an event just happened and it
turns out everything else is going on
behind the scenes and it's going over
and reconfiguring things you plug it
back in again and link status comes back
up it's flexible and that you can go
over and specify which keys you want to
go over and watch for and you can use it
for one configuration or another so if I
want to go over and say let's watch for
another key and now we're watching for
this key also let me go over and bring
up another window
and open a connection to the server and
we'll go over and create a new
dictionary
this is a key-value hello is the key and
the the value is everyone so the
contents of the dictionary so the key is
hello the value is everyone and then
when we go over and say let's go add
this key to the dynamic store do you go
over and watch the top window when I go
over to add the key it sees the change
so you go over in tile this together
with the link status coming up and down
and what's been configured and
everything sort of just puts - puts
itself together so the last thing to go
over and show you there's a little app
that I put together to watch what's
happening on the system and what you
have here on on the left side is a list
of the services as they've been
configured so this is the information
that comes from the network setup from
the system preferences network pane it's
the information that's stored in the
preferences that XML file that was
loaded into the dynamics door and the
right side is the current status of the
network interfaces so here we've got the
built in Ethernet
it's config method was manual there's
the addressing information and airport
was configured for DHCP the built in
Ethernet state goes over has the same
addresses that were requested you can
see the link status is up the airport
interface also is up because we've got
an airport within range these are the
addresses that were picked up from the
DHCP server and and the router that came
with it also up on the top here we go
over and see which location we're
currently set to and the service order
so service order ID one is going to be
the primary interface if it's available
and service I do you want us to built in
Ethernet and you go over and see that
since the Ethernet is up it is the
primary interface if I go and actually
change the location I'm going to switch
this to B instead of being the land
having priority with the airport
following I'll switch it to
at the airport interface having priority
with the land and you notice that the
primary interface changed to en 1 the
nice thing about watching this is it if
you go over and said Lana's got priority
over the airport and you go over and
unplug the cable if you watch the
primary interface which is currently the
Ethernet when I disconnect it
it sees the link status go down it waits
4 seconds and the primary interface
switches and if you plug it back in
again it goes over and revalue what
really waits what needs to be primary
interface comes up you've got new
addresses it goes over and switch a
state
and right before you get on the plane
you go over to turn off all your network
services everything gets turned off so
that's what I've got
thanks Alan
so what do we have in terms of API today
well what we have is we have a system
configuration framework it contains
mostly low-level api is to access the
dynamic store and the preferences we
have some higher-level api's we have
reach ability api is that parallel the
OT will dial api is that i'm sure some
of you are familiar with as i mentioned
when i started out all of these aps are
currently private and we are working
very hard to make some api's public what
can you what can so one of the things
that we realize is that since we have
mostly low-level api s there's not much
in the way of isolation between you and
the you know preferences format or the
dynamic store format so you're kind of
running pretty bare to the metal in
terms of knowing exactly how we've
implemented things so we'd like to
implement some more higher level api is
to provide some isolation here so that
you avoid having schema specific
information embedded in your code the
other thing is to avoid duplicating code
so we're definitely viewing this as
something that's going to evolve evolve
and grow as needs become apparent to us
and we can provide some common api's
that
now are useful to many developers so the
networking some related sessions that it
actually one of them has already
happened that was this morning the
network overview we're talking about
network configuration etwork protocols
and api's the other one if you want to
get more information on core foundation
there's a core foundation overview over
at the civic auditorium across the
street friday morning at 9:00 so who can
you contact if you have questions about
this thomas wires the man you'll be back
up on stage in a couple more slides
for if you want to take a look at the
api's that we have today you're welcome
to go to Darwin and check out the source
code there are four projects that we
have that are implementing pretty much
everything that I've talked about today
config D contains the system
configuration framework which contains
api's for the dynamic store and the
preferences and it also contains source
code for config D which is the
configuration server
the other thing project to check out is
config D plugins this contains the most
of the agents it contains the IP monitor
in the Preferences monitor that I talked
about today third project is bootp bootp
contains the IP configuration agent and
PPP contains the PPP controller
you